MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestEditFileOverlappingOldString

Function TestEditFileOverlappingOldString

internal/tools/edit_test.go:100–114  ·  view source on GitHub ↗

TestEditFileOverlappingOldString: strings.Count sees only one non-overlapping "==" in "a === b", but it matches at two positions with different results; the exactly-once guarantee must reject it.

(t *testing.T)

Source from the content-addressed store, hash-verified

98// non-overlapping "==" in "a === b", but it matches at two positions with
99// different results; the exactly-once guarantee must reject it.
100func TestEditFileOverlappingOldString(t *testing.T) {
101 dir := t.TempDir()
102 path := filepath.Join(dir, "f.txt")
103 if err := os.WriteFile(path, []byte("a === b"), 0o644); err != nil {
104 t.Fatal(err)
105 }
106 s := EditFile(path, "==", "XX")
107 if !strings.Contains(s, "(ambiguous") {
108 t.Fatalf("self-overlapping old_string must be ambiguous, got %q", s)
109 }
110 got, _ := os.ReadFile(path)
111 if string(got) != "a === b" {
112 t.Fatalf("file modified on ambiguity: %q", got)
113 }
114}
115
116func TestEditFileNoOp(t *testing.T) {
117 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected