From fe1c8bdfd910d58200186fbdbfec05c267bad536 Mon Sep 17 00:00:00 2001 From: "carpentry-heartbeat[bot]" Date: Sun, 5 Jul 2026 00:53:51 +0200 Subject: [PATCH 1/2] Add test coverage for StringBuf.with-capacity --- test/strbuf.carp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/strbuf.carp b/test/strbuf.carp index 5a244a6..b8ac5c2 100644 --- a/test/strbuf.carp +++ b/test/strbuf.carp @@ -135,4 +135,17 @@ (StringBuf.delete sb) (StringBuf.delete sb2) s)) - "copy produces independent clone")) + "copy produces independent clone") + + (assert-equal test + "hello" + &(let-do [sb (StringBuf.with-capacity 4)] + (StringBuf.append-str &sb "hello") + (let-do [s (StringBuf.to-string &sb)] (StringBuf.delete sb) s)) + "with-capacity grows past initial capacity") + + (assert-equal test + 0 + (let [sb (StringBuf.with-capacity 0)] + (let-do [l (StringBuf.length &sb)] (StringBuf.delete sb) l)) + "with-capacity 0 falls back to default capacity")) From e1c717e8cc90b0dbb88eaedc4885069d13cb785b Mon Sep 17 00:00:00 2001 From: "carpentry-heartbeat[bot]" Date: Sun, 5 Jul 2026 06:54:08 +0200 Subject: [PATCH 2/2] Rename misleading with-capacity 0 test and add a usability check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `with-capacity 0` test only asserted length == 0, which is trivially true for any fresh buffer (`with_capacity` sets len = 0 unconditionally), so it never exercised the `cap > 0 ? cap : DEFAULT` fallback its name claimed — and that fallback has no observable effect through the public API. Rename it to say what it actually checks (an empty buffer), and add a test that appends to a 0-capacity buffer and verifies the content, so growth from a zero initial capacity is genuinely covered. --- test/strbuf.carp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/strbuf.carp b/test/strbuf.carp index b8ac5c2..1eeb8df 100644 --- a/test/strbuf.carp +++ b/test/strbuf.carp @@ -148,4 +148,11 @@ 0 (let [sb (StringBuf.with-capacity 0)] (let-do [l (StringBuf.length &sb)] (StringBuf.delete sb) l)) - "with-capacity 0 falls back to default capacity")) + "with-capacity 0 yields an empty buffer") + + (assert-equal test + "hello" + &(let-do [sb (StringBuf.with-capacity 0)] + (StringBuf.append-str &sb "hello") + (let-do [s (StringBuf.to-string &sb)] (StringBuf.delete sb) s)) + "with-capacity 0 buffer grows and is usable"))