summaryrefslogtreecommitdiff
path: root/io/bufio_test.ts
diff options
context:
space:
mode:
authorDmitry Sharshakov <d3dx12.xx@gmail.com>2019-09-22 20:04:46 +0300
committerRyan Dahl <ry@tinyclouds.org>2019-09-22 13:04:46 -0400
commit9739ba55df5afef922f96b107f91dbb37128bf5a (patch)
tree69ad53e718ee8b5846f9d1c1c79740b31c464325 /io/bufio_test.ts
parentf545f1d571a154c53f6bda3a30bd69a298d63846 (diff)
Implement readString (denoland/deno_std#607)
Original: https://github.com/denoland/deno_std/commit/20b6408e105f5dd1dbcd0a252d1956b3de1024ca
Diffstat (limited to 'io/bufio_test.ts')
-rw-r--r--io/bufio_test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/io/bufio_test.ts b/io/bufio_test.ts
index 6f50e2876..9d1ffc307 100644
--- a/io/bufio_test.ts
+++ b/io/bufio_test.ts
@@ -160,6 +160,23 @@ test(async function bufioBufferFull(): Promise<void> {
assertEquals(actual, "world!");
});
+test(async function bufioReadString(): Promise<void> {
+ const string = "And now, hello, world!";
+ const buf = new BufReader(stringsReader(string), MIN_READ_BUFFER_SIZE);
+
+ const line = assertNotEOF(await buf.readString(","));
+ assertEquals(line, "And now,");
+ assertEquals(line.length, 8);
+
+ try {
+ await buf.readString("deno");
+
+ fail("should throw");
+ } catch (err) {
+ assert(err.message, "Delimiter should be a single character");
+ }
+});
+
const testInput = encoder.encode(
"012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy"
);