(t *testing.T)
| 158 | |
| 159 | // TestEditFileOverlappingOldString: strings.Count sees only one |
| 160 | // non-overlapping "==" in "a === b", but it matches at two positions with |
| 161 | // different results; the exactly-once guarantee must reject it. |
| 162 | func TestEditFileOverlappingOldString(t *testing.T) { |
| 163 | dir := t.TempDir() |
| 164 | path := filepath.Join(dir, "f.txt") |
| 165 | if err := os.WriteFile(path, []byte("a === b"), 0o644); err != nil { |
| 166 | t.Fatal(err) |
| 167 | } |
| 168 | s := EditFile(path, "==", "XX") |
| 169 | if !strings.Contains(s, "(ambiguous") { |
| 170 | t.Fatalf("self-overlapping old_string must be ambiguous, got %q", s) |
| 171 | } |
| 172 | got, _ := os.ReadFile(path) |
| 173 | if string(got) != "a === b" { |
| 174 | t.Fatalf("file modified on ambiguity: %q", got) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | func TestEditFileNoOp(t *testing.T) { |
nothing calls this directly
no test coverage detected