(t *testing.T)
| 351 | ` |
| 352 | |
| 353 | func Test_colorDiffLines(t *testing.T) { |
| 354 | inputs := []struct { |
| 355 | input, output string |
| 356 | }{ |
| 357 | { |
| 358 | input: "", |
| 359 | output: "", |
| 360 | }, |
| 361 | { |
| 362 | input: "\n", |
| 363 | output: "\n", |
| 364 | }, |
| 365 | { |
| 366 | input: "foo\nbar\nbaz\n", |
| 367 | output: "foo\nbar\nbaz\n", |
| 368 | }, |
| 369 | { |
| 370 | input: "foo\nbar\nbaz", |
| 371 | output: "foo\nbar\nbaz\n", |
| 372 | }, |
| 373 | { |
| 374 | input: fmt.Sprintf("+foo\n-b%sr\n+++ baz\n", strings.Repeat("a", 2*lineBufferSize)), |
| 375 | output: fmt.Sprintf( |
| 376 | "%[4]s+foo%[2]s\n%[5]s-b%[1]sr%[2]s\n%[3]s+++ baz%[2]s\n", |
| 377 | strings.Repeat("a", 2*lineBufferSize), |
| 378 | "\x1b[m", |
| 379 | "\x1b[1;37m", |
| 380 | "\x1b[32m", |
| 381 | "\x1b[31m", |
| 382 | ), |
| 383 | }, |
| 384 | } |
| 385 | for _, tt := range inputs { |
| 386 | buf := bytes.Buffer{} |
| 387 | if err := colorDiffLines(&buf, strings.NewReader(tt.input)); err != nil { |
| 388 | t.Fatalf("unexpected error: %s", err) |
| 389 | } |
| 390 | if got := buf.String(); got != tt.output { |
| 391 | t.Errorf("expected: %q, got: %q", tt.output, got) |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | func Test_changedFileNames(t *testing.T) { |
| 397 | inputs := []struct { |
nothing calls this directly
no test coverage detected