|
1 | 1 | package com.github.doyaaaaaken.kotlincsv.client
|
2 | 2 |
|
3 |
| -import io.kotlintest.shouldBe |
4 |
| -import io.kotlintest.specs.StringSpec |
| 3 | +import io.kotest.core.spec.style.StringSpec |
| 4 | +import io.kotest.matchers.shouldBe |
5 | 5 |
|
6 |
| -/** |
7 |
| - * @author doyaaaaaken |
8 |
| - */ |
9 |
| -class BufferedLineReaderTest : StringSpec() { |
10 |
| - init { |
11 |
| - "regard \\n as line terminator" { |
12 |
| - val str = "a,b,c\nd,e,f" |
13 |
| - val br = str.byteInputStream().bufferedReader() |
14 |
| - val blr = BufferedLineReader(br) |
15 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\n" |
16 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
17 |
| - blr.readLineWithTerminator() shouldBe null |
18 |
| - } |
| 6 | +class BufferedLineReaderTest : StringSpec({ |
| 7 | + "regard \\n as line terminator" { |
| 8 | + val str = "a,b,c\nd,e,f" |
| 9 | + val br = str.byteInputStream().bufferedReader() |
| 10 | + val blr = BufferedLineReader(br) |
| 11 | + blr.readLineWithTerminator() shouldBe "a,b,c\n" |
| 12 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 13 | + blr.readLineWithTerminator() shouldBe null |
| 14 | + } |
19 | 15 |
|
20 |
| - "regard \\r\\n as line terminator" { |
21 |
| - val str = "a,b,c\r\nd,e,f" |
22 |
| - val br = str.byteInputStream().bufferedReader() |
23 |
| - val blr = BufferedLineReader(br) |
24 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\r\n" |
25 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
26 |
| - blr.readLineWithTerminator() shouldBe null |
27 |
| - } |
| 16 | + "regard \\r\\n as line terminator" { |
| 17 | + val str = "a,b,c\r\nd,e,f" |
| 18 | + val br = str.byteInputStream().bufferedReader() |
| 19 | + val blr = BufferedLineReader(br) |
| 20 | + blr.readLineWithTerminator() shouldBe "a,b,c\r\n" |
| 21 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 22 | + blr.readLineWithTerminator() shouldBe null |
| 23 | + } |
28 | 24 |
|
29 |
| - "regard \\r as line terminator" { |
30 |
| - val str = "a,b,c\rd,e,f" |
31 |
| - val br = str.byteInputStream().bufferedReader() |
32 |
| - val blr = BufferedLineReader(br) |
33 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\r" |
34 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
35 |
| - blr.readLineWithTerminator() shouldBe null |
36 |
| - } |
| 25 | + "regard \\r as line terminator" { |
| 26 | + val str = "a,b,c\rd,e,f" |
| 27 | + val br = str.byteInputStream().bufferedReader() |
| 28 | + val blr = BufferedLineReader(br) |
| 29 | + blr.readLineWithTerminator() shouldBe "a,b,c\r" |
| 30 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 31 | + blr.readLineWithTerminator() shouldBe null |
| 32 | + } |
37 | 33 |
|
38 |
| - "regard \\u2028 as line terminator" { |
39 |
| - val str = "a,b,c\u2028d,e,f" |
40 |
| - val br = str.byteInputStream().bufferedReader() |
41 |
| - val blr = BufferedLineReader(br) |
42 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\u2028" |
43 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
44 |
| - blr.readLineWithTerminator() shouldBe null |
45 |
| - } |
| 34 | + "regard \\u2028 as line terminator" { |
| 35 | + val str = "a,b,c\u2028d,e,f" |
| 36 | + val br = str.byteInputStream().bufferedReader() |
| 37 | + val blr = BufferedLineReader(br) |
| 38 | + blr.readLineWithTerminator() shouldBe "a,b,c\u2028" |
| 39 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 40 | + blr.readLineWithTerminator() shouldBe null |
| 41 | + } |
46 | 42 |
|
47 |
| - "regard \\u2029 as line terminator" { |
48 |
| - val str = "a,b,c\u2029d,e,f" |
49 |
| - val br = str.byteInputStream().bufferedReader() |
50 |
| - val blr = BufferedLineReader(br) |
51 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\u2029" |
52 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
53 |
| - blr.readLineWithTerminator() shouldBe null |
54 |
| - } |
| 43 | + "regard \\u2029 as line terminator" { |
| 44 | + val str = "a,b,c\u2029d,e,f" |
| 45 | + val br = str.byteInputStream().bufferedReader() |
| 46 | + val blr = BufferedLineReader(br) |
| 47 | + blr.readLineWithTerminator() shouldBe "a,b,c\u2029" |
| 48 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 49 | + blr.readLineWithTerminator() shouldBe null |
| 50 | + } |
55 | 51 |
|
56 |
| - "regard \\u0085 as line terminator" { |
57 |
| - val str = "a,b,c\u0085d,e,f" |
58 |
| - val br = str.byteInputStream().bufferedReader() |
59 |
| - val blr = BufferedLineReader(br) |
60 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\u0085" |
61 |
| - blr.readLineWithTerminator() shouldBe "d,e,f" |
62 |
| - blr.readLineWithTerminator() shouldBe null |
63 |
| - } |
| 52 | + "regard \\u0085 as line terminator" { |
| 53 | + val str = "a,b,c\u0085d,e,f" |
| 54 | + val br = str.byteInputStream().bufferedReader() |
| 55 | + val blr = BufferedLineReader(br) |
| 56 | + blr.readLineWithTerminator() shouldBe "a,b,c\u0085" |
| 57 | + blr.readLineWithTerminator() shouldBe "d,e,f" |
| 58 | + blr.readLineWithTerminator() shouldBe null |
| 59 | + } |
64 | 60 |
|
65 |
| - "deal with \\r at the end of file" { |
66 |
| - val str = "a,b,c\r" |
67 |
| - val br = str.byteInputStream().bufferedReader() |
68 |
| - val blr = BufferedLineReader(br) |
69 |
| - blr.readLineWithTerminator() shouldBe "a,b,c\r" |
70 |
| - blr.readLineWithTerminator() shouldBe null |
71 |
| - } |
| 61 | + "deal with \\r at the end of file" { |
| 62 | + val str = "a,b,c\r" |
| 63 | + val br = str.byteInputStream().bufferedReader() |
| 64 | + val blr = BufferedLineReader(br) |
| 65 | + blr.readLineWithTerminator() shouldBe "a,b,c\r" |
| 66 | + blr.readLineWithTerminator() shouldBe null |
72 | 67 | }
|
73 |
| -} |
| 68 | +}) |
0 commit comments