-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcases_test.go
More file actions
49 lines (40 loc) · 1.21 KB
/
testcases_test.go
File metadata and controls
49 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"os"
"path/filepath"
"strings"
"testing"
"go-reloaded/internal/transformations"
)
func TestCases(t *testing.T) {
testDir := "testdata/comprehensive"
// Find all input files
inputFiles, err := filepath.Glob(filepath.Join(testDir, "*_input.txt"))
if err != nil {
t.Fatalf("Failed to find input files: %v", err)
}
for _, inputFile := range inputFiles {
// Extract case name (e.g., "case01_basic" from "case01_basic_input.txt")
baseName := strings.TrimSuffix(filepath.Base(inputFile), "_input.txt")
expectedFile := filepath.Join(testDir, baseName+"_expected_output.txt")
t.Run(baseName, func(t *testing.T) {
// Read input
input, err := os.ReadFile(inputFile)
if err != nil {
t.Fatalf("Failed to read input file %s: %v", inputFile, err)
}
// Read expected output
expected, err := os.ReadFile(expectedFile)
if err != nil {
t.Fatalf("Failed to read expected file %s: %v", expectedFile, err)
}
// Run pipeline
actual := transformations.RunPipeline(string(input))
// Compare
if actual != string(expected) {
t.Errorf("Case %s failed:\nInput:\n%s\nExpected:\n%s\nActual:\n%s",
baseName, string(input), string(expected), actual)
}
})
}
}