diff --git a/test/strbuf.carp b/test/strbuf.carp index 5a244a6..1eeb8df 100644 --- a/test/strbuf.carp +++ b/test/strbuf.carp @@ -135,4 +135,24 @@ (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 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"))