Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion test/strbuf.carp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Loading