Skip to content

Commit 38a0d9d

Browse files
committed
test: add regression tests for read offset=0 and limit=0
Covers the fixes from #4: offset=0 returns a 1-indexed error, and limit=0 no longer produces a bogus '[Showing lines 1-0 ...]' note.
1 parent 9e71990 commit 38a0d9d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_tools.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ async def test_read_offset_beyond_eof(tmp_path):
6868
assert result.details["linesReturned"] == 0
6969

7070

71+
async def test_read_offset_zero_is_an_error(tmp_path):
72+
f = tmp_path / "zero.txt"
73+
f.write_text("a\nb\nc\nd")
74+
result = await READ_TOOL.execute("t7", ReadArgs(path=str(f), offset=0))
75+
text = text_of(result)
76+
assert "1-indexed" in text
77+
assert result.details["linesReturned"] == 0
78+
79+
80+
async def test_read_limit_zero_has_no_bogus_note(tmp_path):
81+
f = tmp_path / "lim.txt"
82+
f.write_text("a\nb\nc\nd")
83+
result = await READ_TOOL.execute("t8", ReadArgs(path=str(f), limit=0))
84+
text = text_of(result)
85+
assert result.details["linesReturned"] == 0
86+
assert "1-0" not in text
87+
88+
7189
async def test_read_not_found(tmp_path):
7290
result = await READ_TOOL.execute("t6", ReadArgs(path=str(tmp_path / "nope.txt")))
7391
assert "not found" in text_of(result)

0 commit comments

Comments
 (0)