(t *testing.T)
| 419 | ` |
| 420 | |
| 421 | func Test_colorDiffLines(t *testing.T) { |
| 422 | inputs := []struct { |
| 423 | input, output string |
| 424 | }{ |
| 425 | { |
| 426 | input: "", |
| 427 | output: "", |
| 428 | }, |
| 429 | { |
| 430 | input: "\n", |
| 431 | output: "\n", |
| 432 | }, |
| 433 | { |
| 434 | input: "foo\nbar\nbaz\n", |
| 435 | output: "foo\nbar\nbaz\n", |
| 436 | }, |
| 437 | { |
| 438 | input: "foo\nbar\nbaz", |
| 439 | output: "foo\nbar\nbaz\n", |
| 440 | }, |
| 441 | { |
| 442 | input: fmt.Sprintf("+foo\n-b%sr\n+++ baz\n", strings.Repeat("a", 2*lineBufferSize)), |
| 443 | output: fmt.Sprintf( |
| 444 | "%[4]s+foo%[2]s\n%[5]s-b%[1]sr%[2]s\n%[3]s+++ baz%[2]s\n", |
| 445 | strings.Repeat("a", 2*lineBufferSize), |
| 446 | "\x1b[m", |
| 447 | "\x1b[1;37m", |
| 448 | "\x1b[32m", |
| 449 | "\x1b[31m", |
| 450 | ), |
| 451 | }, |
| 452 | } |
| 453 | for _, tt := range inputs { |
| 454 | buf := bytes.Buffer{} |
| 455 | if err := colorDiffLines(&buf, strings.NewReader(tt.input)); err != nil { |
| 456 | t.Fatalf("unexpected error: %s", err) |
| 457 | } |
| 458 | if got := buf.String(); got != tt.output { |
| 459 | t.Errorf("expected: %q, got: %q", tt.output, got) |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | func Test_changedFileNames(t *testing.T) { |
| 465 | inputs := []struct { |
nothing calls this directly
no test coverage detected