summaryrefslogtreecommitdiff
path: root/libstd/test/strbuf.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-20 19:51:00 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-20 19:51:00 -0700
commit7596ee5f651a67a62de4b009d8647f5b2cf729fb (patch)
tree980f5a7720e8ff3e86335473b04fcc5d977fa662 /libstd/test/strbuf.myr
parenta44d4b5e4d8e265df68194dadc0fa8410a77e7f8 (diff)
downloadmc-7596ee5f651a67a62de4b009d8647f5b2cf729fb.tar.gz
Add, enable, and test strbuf.myr
Diffstat (limited to 'libstd/test/strbuf.myr')
-rw-r--r--libstd/test/strbuf.myr24
1 files changed, 24 insertions, 0 deletions
diff --git a/libstd/test/strbuf.myr b/libstd/test/strbuf.myr
new file mode 100644
index 0000000..92c5a7c
--- /dev/null
+++ b/libstd/test/strbuf.myr
@@ -0,0 +1,24 @@
+use std
+
+const main = {
+ var sb
+
+ sb = std.mksb()
+ std.assert(std.sleq(std.sbpeek(sb), ""), "mismatched empty str\n")
+ std.sbputs(sb, "hello")
+ std.assert(std.sleq(std.sbpeek(sb), "hello"), "mismatched hello\n")
+ std.sbputs(sb, ", hello")
+ std.assert(std.sleq(std.sbpeek(sb), "hello, hello"), "mismatched double hello\n")
+ std.sbtrim(sb, 7)
+ std.assert(std.sleq(std.sbpeek(sb), "hello, "), "mismatched trim\n")
+ std.sbputs(sb, "world")
+ std.assert(std.sleq(std.sbpeek(sb), "hello, world"), "mismatched hello world\n")
+ std.sbtrim(sb, -5)
+ std.assert(std.sleq(std.sbpeek(sb), "hello, "), "mismatched rtrim\n")
+ std.sbputc(sb, '世')
+ std.sbputc(sb, '界')
+ std.assert(std.sleq(std.sbpeek(sb), "hello, 世界"), "mismatched unicode\n")
+ std.sbputb(sb, 10)
+ std.assert(std.sleq(std.sbpeek(sb), "hello, 世界\n"), "mismatched byte\n")
+}
+