(t *testing.T)
| 591 | } |
| 592 | |
| 593 | func TestDifferFancyReplaceAndHelper(t *testing.T) { |
| 594 | diff := NewDiffer() |
| 595 | // Test identical sync point, both full |
| 596 | aLst := stringsToBytes("one\n", "asdf\n", "three\n") |
| 597 | bLst := stringsToBytes("one\n", "two2\n", "three\n") |
| 598 | out, err := diff.FancyReplace(aLst, 0, 3, bLst, 0, 3) |
| 599 | if err != nil { |
| 600 | t.Fatal("Differ FancyReplace() error:", err) |
| 601 | } |
| 602 | out2 := bytesToStrings(out...) |
| 603 | if reflect.DeepEqual(out2, |
| 604 | []string{" one\n", "- asdf\n", "+ two2\n", " three\n"}) != true { |
| 605 | t.Fatal("Differ FancyReplace() failure:", out2) |
| 606 | } |
| 607 | // Test close sync point, both full |
| 608 | aLst = stringsToBytes("one\n", "two123456\n", "asdf\n", "three\n") |
| 609 | bLst = stringsToBytes("one\n", "two123457\n", "qwerty\n", "three\n") |
| 610 | out, err = diff.FancyReplace(aLst, 1, 3, bLst, 1, 3) |
| 611 | if err != nil { |
| 612 | t.Fatal("Differ FancyReplace() error:", err) |
| 613 | } |
| 614 | out2 = bytesToStrings(out...) |
| 615 | if reflect.DeepEqual(out2, []string{ |
| 616 | "- two123456\n", |
| 617 | "? ^\n", |
| 618 | "+ two123457\n", |
| 619 | "? ^\n", |
| 620 | "- asdf\n", |
| 621 | "+ qwerty\n", |
| 622 | }) != true { |
| 623 | t.Fatal("Differ FancyReplace() failure:", out2) |
| 624 | } |
| 625 | // Test no identical no close |
| 626 | aLst = stringsToBytes("one\n", "asdf\n", "three\n") |
| 627 | bLst = stringsToBytes("one\n", "qwerty\n", "three\n") |
| 628 | out, err = diff.FancyReplace(aLst, 1, 2, bLst, 1, 2) |
| 629 | if err != nil { |
| 630 | t.Fatal("Differ FancyReplace() error:", err) |
| 631 | } |
| 632 | out2 = bytesToStrings(out...) |
| 633 | if reflect.DeepEqual(out2, []string{ |
| 634 | "- asdf\n", |
| 635 | "+ qwerty\n", |
| 636 | }) != true { |
| 637 | t.Fatal("Differ FancyReplace() failure:", out2) |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | func TestDifferQFormat(t *testing.T) { |
| 642 | diff := NewDiffer() |
nothing calls this directly
no test coverage detected