ref: be1ed4d2e0a785d303433ed7b1807e283889d81d
parent: e60e9f802f649aa139e3d3b0ec7d17c851634e3f
author: Ori Bernstein <[email protected]>
date: Tue Dec 17 20:32:36 EST 2013
Add bio-delim tests.
--- /dev/null
+++ b/test/bio-delim.myr
@@ -1,0 +1,50 @@
+use std
+use bio
+
+const main = {
+ var f
+ var d
+
+ match bio.open("data/lines", bio.Rd)
+ | `std.Some bio: f = bio
+ | `std.None: std.fatal(1, "Unable to open data file\n")
+ ;;
+
+ /* read first line */
+ d = bio.readln(f)
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ /* read second line, should not include \n */
+ d = bio.readln(f)
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ /* read to ';' */
+ d = bio.readto(f, ";")
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ /* read to ';' again */
+ d = bio.readto(f, ";")
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ /* '--' this time */
+ d = bio.readto(f, "--")
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ /* and without the terminator, we should get the remaining text */
+ d = bio.readto(f, "not-there")
+ std.write(1, d)
+ std.write(1, "\n")
+ std.slfree(d)
+
+ bio.close(f)
+}
--- /dev/null
+++ b/test/data/bio-delim-expected
@@ -1,0 +1,8 @@
+first line
+second line
+data with
+semicolons
+
+and
+no-terminator
+