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

Function TestDifferPlainReplace

texteditor/difflib/difflib_test.go:515–536  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

513}
514
515func TestDifferPlainReplace(t *testing.T) {
516 diff := NewDiffer()
517 aLst := []string{"one\n", "two\n", "three\n", "four\n", "five\n"}
518 bLst := []string{"one\n", "two2\n", "three\n", "extra\n"}
519 // Test a then b
520 out, err := diff.PlainReplace(aLst, 1, 2, bLst, 1, 2)
521 if err != nil {
522 t.Fatal("Differ PlainReplace() error:", err)
523 }
524 if reflect.DeepEqual(out, []string{"- two\n", "+ two2\n"}) != true {
525 t.Fatal("Differ PlainReplace() failure:", out)
526 }
527 // Test b then a
528 out, err = diff.PlainReplace(aLst, 3, 5, bLst, 3, 4)
529 if err != nil {
530 t.Fatal("Differ PlainReplace() error:", err)
531 }
532 if reflect.DeepEqual(out,
533 []string{"+ extra\n", "- four\n", "- five\n"}) != true {
534 t.Fatal("Differ PlainReplace() failure:", out)
535 }
536}
537
538func TestDifferFancyReplaceAndHelper(t *testing.T) {
539 diff := NewDiffer()

Callers

nothing calls this directly

Calls 2

PlainReplaceMethod · 0.95
NewDifferFunction · 0.70

Tested by

no test coverage detected