loadTestCases loads test cases from a YAML file. The path is relative to the caller's directory.
(t *testing.T, relativePath string, callerDepth int)
| 60 | // loadTestCases loads test cases from a YAML file. |
| 61 | // The path is relative to the caller's directory. |
| 62 | func loadTestCases(t *testing.T, relativePath string, callerDepth int) []SplitTestCase { |
| 63 | t.Helper() |
| 64 | |
| 65 | // Get the caller's file path to resolve relative paths |
| 66 | _, callerFile, _, ok := runtime.Caller(callerDepth) |
| 67 | require.True(t, ok, "failed to get caller info") |
| 68 | |
| 69 | callerDir := filepath.Dir(callerFile) |
| 70 | fullPath := filepath.Join(callerDir, relativePath) |
| 71 | |
| 72 | data, err := os.ReadFile(fullPath) |
| 73 | require.NoError(t, err, "failed to read test file: %s", fullPath) |
| 74 | |
| 75 | var testCases []SplitTestCase |
| 76 | err = yaml.Unmarshal(data, &testCases) |
| 77 | require.NoError(t, err, "failed to parse YAML test file: %s", fullPath) |
| 78 | |
| 79 | return testCases |
| 80 | } |
| 81 | |
| 82 | // assertStatementsEqual compares actual statements against expected results. |
| 83 | func assertStatementsEqual(t *testing.T, expected []StatementResult, actual []Statement, msgAndArgs ...any) { |
no test coverage detected