MCPcopy Create free account
hub / github.com/cogentcore/core / TestGetUnifiedDiffString

Function TestGetUnifiedDiffString

texteditor/difflib/bytes/bytes_test.go:659–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

657}
658
659func TestGetUnifiedDiffString(t *testing.T) {
660 A := []byte("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
661 B := []byte("one\ntwo\nthr33\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
662 // Build diff
663 diff := UnifiedDiff{A: SplitLines(A),
664 FromFile: "file", FromDate: "then",
665 B: SplitLines(B),
666 ToFile: "tile", ToDate: "now", Eol: []byte{}, Context: 1}
667 // Run test
668 diffStr, err := GetUnifiedDiffString(diff)
669 if err != nil {
670 t.Fatal("GetUnifiedDiffString error:", err)
671 }
672 exp := []byte("--- file\tthen\n+++ tile\tnow\n@@ -2,3 +2,3 @@\n two\n-three\n+thr33\n four\n")
673 if !bytes.Equal(diffStr, exp) {
674 t.Fatal("GetUnifiedDiffString failure:", diffStr)
675 }
676}

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
SplitLinesFunction · 0.70
GetUnifiedDiffStringFunction · 0.70

Tested by

no test coverage detected