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

Function TestDifferPlainReplace

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

Source from the content-addressed store, hash-verified

566}
567
568func TestDifferPlainReplace(t *testing.T) {
569 diff := NewDiffer()
570 aLst := stringsToBytes("one\n", "two\n", "three\n", "four\n", "five\n")
571 bLst := stringsToBytes("one\n", "two2\n", "three\n", "extra\n")
572 // Test a then b
573 out, err := diff.PlainReplace(aLst, 1, 2, bLst, 1, 2)
574 if err != nil {
575 t.Fatal("Differ PlainReplace() error:", err)
576 }
577 out2 := bytesToStrings(out...)
578 if reflect.DeepEqual(out2, []string{"- two\n", "+ two2\n"}) != true {
579 t.Fatal("Differ PlainReplace() failure:", out2)
580 }
581 // Test b then a
582 out, err = diff.PlainReplace(aLst, 3, 5, bLst, 3, 4)
583 if err != nil {
584 t.Fatal("Differ PlainReplace() error:", err)
585 }
586 out2 = bytesToStrings(out...)
587 if reflect.DeepEqual(out2,
588 []string{"+ extra\n", "- four\n", "- five\n"}) != true {
589 t.Fatal("Differ PlainReplace() failure:", out2)
590 }
591}
592
593func TestDifferFancyReplaceAndHelper(t *testing.T) {
594 diff := NewDiffer()

Callers

nothing calls this directly

Calls 4

PlainReplaceMethod · 0.95
stringsToBytesFunction · 0.85
bytesToStringsFunction · 0.85
NewDifferFunction · 0.70

Tested by

no test coverage detected