Skip to content

Commit 9403586

Browse files
authored
Update KotlinTest to Kotest (#79)
KotlinTest was renamed to Kotest a while ago, and these tests can be upgraded to the new version. With that, writing new tests and maintaining current ones will be easier and more feature-rich.
1 parent 47e71bf commit 9403586

File tree

9 files changed

+773
-819
lines changed

9 files changed

+773
-819
lines changed

build.gradle.kts

+5-9
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ val dokkaJar = task<Jar>("dokkaJar") {
3030

3131
kotlin {
3232
jvm {
33-
val main by compilations.getting {
34-
kotlinOptions {
35-
jvmTarget = "1.8"
36-
}
33+
compilations.forEach {
34+
it.kotlinOptions.jvmTarget = "1.8"
3735
}
3836
//https://docs.gradle.org/current/userguide/publishing_maven.html
3937
mavenPublication {
@@ -68,10 +66,8 @@ kotlin {
6866
}
6967
jvm().compilations["test"].defaultSourceSet {
7068
dependencies {
71-
implementation(kotlin("test"))
72-
implementation(kotlin("test-junit"))
7369
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
74-
implementation("io.kotlintest:kotlintest-runner-junit5:3.3.2")
70+
implementation("io.kotest:kotest-runner-junit5-jvm:4.4.1")
7571
}
7672
}
7773
js().compilations["main"].defaultSourceSet {
@@ -87,8 +83,8 @@ kotlin {
8783
}
8884
}
8985

90-
val jvmTest by tasks.getting(Test::class) {
91-
useJUnitPlatform { }
86+
tasks.withType<Test>() {
87+
useJUnitPlatform()
9288
}
9389

9490

Original file line numberDiff line numberDiff line change
@@ -1,73 +1,68 @@
11
package com.github.doyaaaaaken.kotlincsv.client
22

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
55

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+
}
1915

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+
}
2824

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+
}
3733

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+
}
4642

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+
}
5551

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+
}
6460

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
7267
}
73-
}
68+
})

0 commit comments

Comments
 (0)