MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestReadFileSchemaShape

Function TestReadFileSchemaShape

internal/tools/read_test.go:59–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57 t.Fatalf("windowed read should name the next offset, got %d bytes without it", len(got))
58 }
59 if strings.Contains(got, "───── truncated") {
60 t.Fatalf("windowed read must not fall through to head+tail truncation: %q", got[:200])
61 }
62 if len(got) >= chmctx.ToolOutputCap*4 {
63 t.Fatalf("window must stay under Truncate's cap, got %d bytes", len(got))
64 }
65 // The head is contiguous: line 0 present, and no gap before the last line
66 // shown. Anything else means the middle was dropped.
67 if !strings.HasPrefix(got, "line 0 ") {
68 t.Fatalf("window should start at line 0: %q", got[:60])
69 }
70}
71
72// TestReadFileOffsetLimitPagesWholeFile: following the continuation offsets
73// reconstructs the file exactly, with no gap and no overlap. This is the
74// property the whole change exists for.
75func TestReadFileOffsetLimitPagesWholeFile(t *testing.T) {
76 dir := t.TempDir()
77 path := filepath.Join(dir, "paged.txt")
78 var b strings.Builder
79 for i := range 900 {
80 fmt.Fprintf(&b, "line %d\n", i)
81 }
82 want := b.String()
83 if err := os.WriteFile(path, []byte(want), 0o644); err != nil {
84 t.Fatal(err)
85 }
86 var got strings.Builder

Callers

nothing calls this directly

Calls 1

ReadFileSchemaFunction · 0.85

Tested by

no test coverage detected