(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func TestFormatErrorList(t *testing.T) { |
| 286 | tests := []struct { |
| 287 | name string |
| 288 | errors []*Error |
| 289 | contains []string |
| 290 | }{ |
| 291 | { |
| 292 | name: "empty list", |
| 293 | errors: []*Error{}, |
| 294 | contains: []string{"No errors"}, |
| 295 | }, |
| 296 | { |
| 297 | name: "single error", |
| 298 | errors: []*Error{ |
| 299 | NewError(ErrCodeUnexpectedToken, "error 1", models.Location{Line: 1, Column: 1}), |
| 300 | }, |
| 301 | contains: []string{ |
| 302 | "Found 1 error(s)", |
| 303 | "Error 1:", |
| 304 | "error 1", |
| 305 | }, |
| 306 | }, |
| 307 | { |
| 308 | name: "multiple errors", |
| 309 | errors: []*Error{ |
| 310 | NewError(ErrCodeUnexpectedToken, "error 1", models.Location{Line: 1, Column: 1}), |
| 311 | NewError(ErrCodeExpectedToken, "error 2", models.Location{Line: 2, Column: 5}), |
| 312 | }, |
| 313 | contains: []string{ |
| 314 | "Found 2 error(s)", |
| 315 | "Error 1:", |
| 316 | "Error 2:", |
| 317 | "error 1", |
| 318 | "error 2", |
| 319 | }, |
| 320 | }, |
| 321 | } |
| 322 | |
| 323 | for _, tt := range tests { |
| 324 | t.Run(tt.name, func(t *testing.T) { |
| 325 | got := FormatErrorList(tt.errors) |
| 326 | for _, substr := range tt.contains { |
| 327 | if !strings.Contains(got, substr) { |
| 328 | t.Errorf("FormatErrorList() missing substring %q\nGot:\n%s", substr, got) |
| 329 | } |
| 330 | } |
| 331 | }) |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | func TestFormatErrorWithExample(t *testing.T) { |
| 336 | got := FormatErrorWithExample( |
nothing calls this directly
no test coverage detected