diff options
author | Iván Canales <kanales@users.noreply.github.com> | 2020-12-05 17:41:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 17:41:16 +0100 |
commit | c10280214e5e15fb31b83368082916b9f25470f9 (patch) | |
tree | c0ca3b76a688c625629f23e8e77a48f1dbfbbef8 /std/io/bufio_test.ts | |
parent | 2d5c742cf608b2ce0c5a51fb80f34cfd8ffd2e83 (diff) |
fix(std/bufio): Remove '\r' at the end of Windows lines (#8447)
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
Diffstat (limited to 'std/io/bufio_test.ts')
-rw-r--r-- | std/io/bufio_test.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/std/io/bufio_test.ts b/std/io/bufio_test.ts index 03f699d50..804d59e99 100644 --- a/std/io/bufio_test.ts +++ b/std/io/bufio_test.ts @@ -436,6 +436,10 @@ Deno.test("readStringDelimAndLines", async function (): Promise<void> { assertEquals(chunks_, ["Hello World", "Hello World 2", "Hello World 3"]); const linesData = new Deno.Buffer(enc.encode("0\n1\n2\n3\n4\n5\n6\n7\n8\n9")); + // consider data with windows newlines too + const linesDataWindows = new Deno.Buffer( + enc.encode("0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9"), + ); const lines_ = []; for await (const l of readLines(linesData)) { @@ -444,6 +448,14 @@ Deno.test("readStringDelimAndLines", async function (): Promise<void> { assertEquals(lines_.length, 10); assertEquals(lines_, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); + + // Now test for "windows" lines + lines_.length = 0; + for await (const l of readLines(linesDataWindows)) { + lines_.push(l); + } + assertEquals(lines_.length, 10); + assertEquals(lines_, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); }); Deno.test( |