MCPcopy Create free account
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 t.Fatalf("want fuzzy apply, got %q", s)
99 }
100 want := "def f():\n if y:\n do(1)\n do(2)\n return\n"
101 if got, _ := os.ReadFile(path); string(got) != want {
102 t.Fatalf("bad fuzzy apply result: %q", got)
103 }
104}
105
106// TestEditFileWhitespaceNearMissMidLineStillHints: a whitespace near-miss that
107// is NOT a run of whole lines (the match covers only part of a line) must not
108// fuzzy-apply; it keeps the diagnostic hint and the file stays untouched.
109func TestEditFileWhitespaceNearMissMidLineStillHints(t *testing.T) {
110 dir := t.TempDir()
111 path := filepath.Join(dir, "f.go")
112 const orig = "x := f(a, b) + g()\n" // double space inside the call
113 if err := os.WriteFile(path, []byte(orig), 0o644); err != nil {
114 t.Fatal(err)
115 }
116 s := EditFile(path, "f(a, b)", "f(a, b, c)") // fields of the line != fields of old_string
117 if !strings.Contains(s, "not found") {

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected