Skip to content

Commit deaeba4

Browse files
Add kotlin-test-junit and kotlin-test-junit5
1 parent ca44570 commit deaeba4

File tree

765 files changed

+1806
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

765 files changed

+1806
-87
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
android = "7.2.1"
3-
hubdle = "0.2.0-alpha.23"
3+
hubdle = "0.2.0-alpha.24"
44
kotlin = "1.7.10"
55

66
[libraries]

kotlin-stdlib/build.gradle.kts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ hubdle {
1414
multiplatform {
1515
features {
1616
extendedStdlib(enabled = false)
17+
extendedTesting(enabled = false)
1718
}
1819

19-
common {
20-
main {
21-
dependencies {
22-
implementation(jetbrainsKotlinTest())
23-
implementation(jetbrainsKotlinTestJunit())
24-
}
25-
}
26-
}
20+
common()
2721

2822
android()
2923

kotlin-stdlib/common/test/kotlin/com/javiersc/kotlin/stdlib/CollectionsTest.kt

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
package com.javiersc.kotlin.stdlib
44

5-
import io.kotest.assertions.throwables.shouldThrow
6-
import io.kotest.matchers.shouldBe
75
import kotlin.test.Test
6+
import kotlin.test.assertFailsWith
7+
import kotlin.test.assertTrue
88

99
class CollectionsTest {
1010

@@ -15,84 +15,97 @@ class CollectionsTest {
1515

1616
@Test
1717
fun collection_second() {
18-
numbers.second().shouldBe(2)
19-
numbers.secondOrNull().shouldBe(2)
18+
assertTrue { numbers.second() == 2 }
19+
assertTrue { numbers.secondOrNull() == 2 }
2020

21-
chars.second().shouldBe('B')
22-
chars.secondOrNull().shouldBe('B')
21+
assertTrue { chars.second() == 'B' }
22+
assertTrue { chars.secondOrNull() == 'B' }
2323

24-
shouldThrow<NoSuchElementException> { empty.second() }
25-
shouldThrow<NoSuchElementException> { emptyIterable.second() }
26-
empty.secondOrNull().shouldBe(null)
27-
emptyIterable.secondOrNull().shouldBe(null)
24+
assertFailsWith<NoSuchElementException> { empty.second() }
25+
assertFailsWith<NoSuchElementException> { emptyIterable.second() }
26+
27+
assertTrue { empty.secondOrNull() == null }
28+
assertTrue { emptyIterable.secondOrNull() == null }
2829
}
2930

3031
@Test
3132
fun collection_third() {
32-
numbers.third().shouldBe(3)
33-
numbers.thirdOrNull().shouldBe(3)
33+
assertTrue { numbers.third() == 3 }
34+
assertTrue { numbers.thirdOrNull() == 3 }
35+
36+
assertTrue { chars.third() == 'C' }
37+
assertTrue { chars.thirdOrNull() == 'C' }
3438

35-
chars.third().shouldBe('C')
36-
chars.thirdOrNull().shouldBe('C')
39+
assertFailsWith<NoSuchElementException> { empty.third() }
40+
assertFailsWith<NoSuchElementException> { emptyIterable.third() }
3741

38-
shouldThrow<NoSuchElementException> { empty.third() }
39-
shouldThrow<NoSuchElementException> { emptyIterable.third() }
40-
empty.thirdOrNull().shouldBe(null)
41-
emptyIterable.thirdOrNull().shouldBe(null)
42+
assertTrue { empty.thirdOrNull() == null }
43+
assertTrue { emptyIterable.thirdOrNull() == null }
4244
}
4345

4446
@Test
4547
fun collection_forth() {
46-
numbers.forth().shouldBe(4)
47-
numbers.forthOrNull().shouldBe(4)
48+
assertTrue { numbers.forth() == 4 }
49+
assertTrue { numbers.forthOrNull() == 4 }
50+
51+
assertTrue { chars.forth() == 'D' }
52+
assertTrue { chars.forthOrNull() == 'D' }
4853

49-
chars.forth().shouldBe('D')
50-
chars.forthOrNull().shouldBe('D')
54+
assertFailsWith<NoSuchElementException> { empty.forth() }
55+
assertFailsWith<NoSuchElementException> { emptyIterable.forth() }
5156

52-
shouldThrow<NoSuchElementException> { empty.forth() }
53-
shouldThrow<NoSuchElementException> { emptyIterable.forth() }
54-
empty.forthOrNull().shouldBe(null)
55-
emptyIterable.forthOrNull().shouldBe(null)
57+
assertTrue { empty.forthOrNull() == null }
58+
assertTrue { emptyIterable.forthOrNull() == null }
5659
}
5760

5861
@Test
5962
fun collection_fifth() {
60-
numbers.fifth().shouldBe(5)
61-
numbers.fifthOrNull().shouldBe(5)
63+
assertTrue { numbers.fifth() == 5 }
64+
assertTrue { numbers.fifthOrNull() == 5 }
6265

63-
chars.fifth().shouldBe('E')
64-
chars.fifthOrNull().shouldBe('E')
66+
assertTrue { chars.fifth() == 'E' }
67+
assertTrue { chars.fifthOrNull() == 'E' }
6568

66-
shouldThrow<NoSuchElementException> { empty.fifth() }
67-
shouldThrow<NoSuchElementException> { emptyIterable.fifth() }
68-
empty.fifthOrNull().shouldBe(null)
69-
emptyIterable.fifthOrNull().shouldBe(null)
69+
assertFailsWith<NoSuchElementException> { empty.fifth() }
70+
assertFailsWith<NoSuchElementException> { emptyIterable.fifth() }
71+
72+
assertTrue { empty.fifthOrNull() == null }
73+
assertTrue { emptyIterable.fifthOrNull() == null }
7074
}
7175

7276
@Test
7377
fun collection_penultimate() {
74-
numbers.penultimate().shouldBe(9)
75-
numbers.penultimateOrNull().shouldBe(9)
78+
assertTrue { numbers.penultimate() == 9 }
79+
assertTrue { numbers.penultimateOrNull() == 9 }
80+
81+
assertTrue { chars.penultimate() == 'E' }
82+
assertTrue { chars.penultimateOrNull() == 'E' }
7683

77-
chars.penultimate().shouldBe('E')
78-
chars.penultimateOrNull().shouldBe('E')
84+
assertFailsWith<NoSuchElementException> { empty.penultimate() }
85+
assertFailsWith<NoSuchElementException> { emptyIterable.penultimate() }
7986

80-
shouldThrow<NoSuchElementException> { empty.penultimate() }
81-
shouldThrow<NoSuchElementException> { emptyIterable.penultimate() }
82-
empty.penultimateOrNull().shouldBe(null)
83-
emptyIterable.penultimateOrNull().shouldBe(null)
87+
assertTrue { empty.penultimateOrNull() == null }
88+
assertTrue { emptyIterable.penultimateOrNull() == null }
8489

85-
shouldThrow<NoSuchElementException> { listOf(1).penultimate() }
86-
shouldThrow<NoSuchElementException> { listOf(1).asIterable().penultimate() }
90+
assertFailsWith<NoSuchElementException> { listOf(1).penultimate() }
91+
assertFailsWith<NoSuchElementException> { listOf(1).asIterable().penultimate() }
8792
}
8893

8994
@Test
9095
fun remove_duplicate_empty_lines() {
91-
listOf("a", "b", "", "", "c", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
92-
listOf("a", "b", "", "", "", "c", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
93-
listOf("a", "b", "", "", "c", "", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
94-
listOf("a", "", "", "", "b", "", "").removeDuplicateEmptyLines().shouldBe("a\n\nb\n")
95-
emptyList<String>().removeDuplicateEmptyLines().shouldBe("")
96-
listOf("").removeDuplicateEmptyLines().shouldBe("")
96+
assertTrue {
97+
listOf("a", "b", "", "", "c", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
98+
}
99+
assertTrue {
100+
listOf("a", "b", "", "", "", "c", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
101+
}
102+
assertTrue {
103+
listOf("a", "b", "", "", "c", "", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
104+
}
105+
assertTrue {
106+
listOf("a", "", "", "", "b", "", "").removeDuplicateEmptyLines() == "a\n\nb\n"
107+
}
108+
assertTrue { emptyList<String>().removeDuplicateEmptyLines() == "" }
109+
assertTrue { listOf("").removeDuplicateEmptyLines() == "" }
97110
}
98111
}
Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
package com.javiersc.kotlin.stdlib
22

3-
import io.kotest.matchers.booleans.shouldBeFalse
4-
import io.kotest.matchers.booleans.shouldBeTrue
5-
import io.kotest.matchers.shouldBe
6-
import io.kotest.matchers.string.shouldBeEmpty
73
import kotlin.test.Test
4+
import kotlin.test.assertFalse
5+
import kotlin.test.assertTrue
86

97
class StringsTest {
108

119
@Test
1210
fun string_remove() {
13-
"Hello, World".remove("Hello, ").shouldBe("World")
14-
"Hello, World".remove("bla").shouldBe("Hello, World")
15-
"Hello, World".remove("llo", "rld").shouldBe("He, Wo")
11+
assertTrue { "Hello, World".remove("Hello, ") == "World" }
12+
assertTrue { "Hello, World".remove("bla") == "Hello, World" }
13+
assertTrue { "Hello, World".remove("llo", "rld") == "He, Wo" }
1614
}
1715

1816
@Test
1917
fun string_replace() {
20-
"Hello, World".replace("ello" to "ELLO", "orld" to "ORLD").shouldBe("HELLO, WORLD")
18+
assertTrue { "Hello, World".replace("ello" to "ELLO", "orld" to "ORLD") == "HELLO, WORLD" }
2119
}
2220

2321
@Test
@@ -27,36 +25,36 @@ class StringsTest {
2725
val empty = ""
2826
val notBlank = "Hello, World"
2927

30-
nullable.isNotNullNorBlank().shouldBeFalse()
31-
nullable.isNotNullNorEmpty().shouldBeFalse()
32-
blank.isNotNullNorBlank().shouldBeFalse()
33-
blank.isNotNullNorEmpty().shouldBeTrue()
34-
empty.isNotNullNorBlank().shouldBeFalse()
35-
empty.isNotNullNorEmpty().shouldBeFalse()
36-
notBlank.isNotNullNorBlank().shouldBeTrue()
37-
notBlank.isNotNullNorEmpty().shouldBeTrue()
28+
assertFalse { nullable.isNotNullNorBlank() }
29+
assertFalse { nullable.isNotNullNorEmpty() }
30+
assertFalse { blank.isNotNullNorBlank() }
31+
assertTrue { blank.isNotNullNorEmpty() }
32+
assertFalse { empty.isNotNullNorBlank() }
33+
assertFalse { empty.isNotNullNorEmpty() }
34+
assertTrue { notBlank.isNotNullNorBlank() }
35+
assertTrue { notBlank.isNotNullNorEmpty() }
3836
}
3937

4038
@Test
4139
fun empty_string() {
42-
String.Empty.shouldBeEmpty()
40+
assertTrue { String.Empty == "" }
4341
}
4442

4543
@Test
4644
fun remove_duplicate_empty_lines() {
47-
"a\nb\n\n\nc\n".removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
48-
"a\n\nb\n\n\nc\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n\nc\n")
49-
"a\n\nb\n\n\nc\n\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n\nc\n")
50-
"a\n\n\n\n\nb\n\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n")
45+
assertTrue { "a\nb\n\n\nc\n".removeDuplicateEmptyLines() == "a\nb\n\nc\n" }
46+
assertTrue { "a\n\nb\n\n\nc\n".removeDuplicateEmptyLines() == "a\n\nb\n\nc\n" }
47+
assertTrue { "a\n\nb\n\n\nc\n\n".removeDuplicateEmptyLines() == "a\n\nb\n\nc\n" }
48+
assertTrue { "a\n\n\n\n\nb\n\n".removeDuplicateEmptyLines() == "a\n\nb\n" }
5149
}
5250

5351
@Test
5452
fun end_with_new_line() {
55-
"a".endWithNewLine().shouldBe("a\n")
56-
"a\n".endWithNewLine().shouldBe("a\n")
57-
"".endWithNewLine().shouldBe("")
58-
"a\nb".endWithNewLine().shouldBe("a\nb\n")
59-
"".endWithNewLine().shouldBe("")
60-
"\n".endWithNewLine().shouldBe("\n")
53+
assertTrue { "a".endWithNewLine() == "a\n" }
54+
assertTrue { "a\n".endWithNewLine() == "a\n" }
55+
assertTrue { "".endWithNewLine() == "" }
56+
assertTrue { "a\nb".endWithNewLine() == "a\nb\n" }
57+
assertTrue { "".endWithNewLine() == "" }
58+
assertTrue { "\n".endWithNewLine() == "\n" }
6159
}
6260
}

0 commit comments

Comments
 (0)