Skip to content

Commit

Permalink
Add kotlin-test-junit and kotlin-test-junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Jul 14, 2022
1 parent ca44570 commit deaeba4
Show file tree
Hide file tree
Showing 765 changed files with 1,806 additions and 87 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

### Added

- `kotlin-test-junit` artifact
- `kotlin-test-juni5` artifact

### Changed

### Deprecated

### Removed

- `kotlin-test` artifact

### Fixed

### Updated
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
android = "7.2.1"
hubdle = "0.2.0-alpha.23"
hubdle = "0.2.0-alpha.24"
kotlin = "1.7.10"

[libraries]
Expand Down
10 changes: 2 additions & 8 deletions kotlin-stdlib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ hubdle {
multiplatform {
features {
extendedStdlib(enabled = false)
extendedTesting(enabled = false)
}

common {
main {
dependencies {
implementation(jetbrainsKotlinTest())
implementation(jetbrainsKotlinTestJunit())
}
}
}
common()

android()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package com.javiersc.kotlin.stdlib

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.matchers.shouldBe
import kotlin.test.Test
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue

class CollectionsTest {

Expand All @@ -15,84 +15,97 @@ class CollectionsTest {

@Test
fun collection_second() {
numbers.second().shouldBe(2)
numbers.secondOrNull().shouldBe(2)
assertTrue { numbers.second() == 2 }
assertTrue { numbers.secondOrNull() == 2 }

chars.second().shouldBe('B')
chars.secondOrNull().shouldBe('B')
assertTrue { chars.second() == 'B' }
assertTrue { chars.secondOrNull() == 'B' }

shouldThrow<NoSuchElementException> { empty.second() }
shouldThrow<NoSuchElementException> { emptyIterable.second() }
empty.secondOrNull().shouldBe(null)
emptyIterable.secondOrNull().shouldBe(null)
assertFailsWith<NoSuchElementException> { empty.second() }
assertFailsWith<NoSuchElementException> { emptyIterable.second() }

assertTrue { empty.secondOrNull() == null }
assertTrue { emptyIterable.secondOrNull() == null }
}

@Test
fun collection_third() {
numbers.third().shouldBe(3)
numbers.thirdOrNull().shouldBe(3)
assertTrue { numbers.third() == 3 }
assertTrue { numbers.thirdOrNull() == 3 }

assertTrue { chars.third() == 'C' }
assertTrue { chars.thirdOrNull() == 'C' }

chars.third().shouldBe('C')
chars.thirdOrNull().shouldBe('C')
assertFailsWith<NoSuchElementException> { empty.third() }
assertFailsWith<NoSuchElementException> { emptyIterable.third() }

shouldThrow<NoSuchElementException> { empty.third() }
shouldThrow<NoSuchElementException> { emptyIterable.third() }
empty.thirdOrNull().shouldBe(null)
emptyIterable.thirdOrNull().shouldBe(null)
assertTrue { empty.thirdOrNull() == null }
assertTrue { emptyIterable.thirdOrNull() == null }
}

@Test
fun collection_forth() {
numbers.forth().shouldBe(4)
numbers.forthOrNull().shouldBe(4)
assertTrue { numbers.forth() == 4 }
assertTrue { numbers.forthOrNull() == 4 }

assertTrue { chars.forth() == 'D' }
assertTrue { chars.forthOrNull() == 'D' }

chars.forth().shouldBe('D')
chars.forthOrNull().shouldBe('D')
assertFailsWith<NoSuchElementException> { empty.forth() }
assertFailsWith<NoSuchElementException> { emptyIterable.forth() }

shouldThrow<NoSuchElementException> { empty.forth() }
shouldThrow<NoSuchElementException> { emptyIterable.forth() }
empty.forthOrNull().shouldBe(null)
emptyIterable.forthOrNull().shouldBe(null)
assertTrue { empty.forthOrNull() == null }
assertTrue { emptyIterable.forthOrNull() == null }
}

@Test
fun collection_fifth() {
numbers.fifth().shouldBe(5)
numbers.fifthOrNull().shouldBe(5)
assertTrue { numbers.fifth() == 5 }
assertTrue { numbers.fifthOrNull() == 5 }

chars.fifth().shouldBe('E')
chars.fifthOrNull().shouldBe('E')
assertTrue { chars.fifth() == 'E' }
assertTrue { chars.fifthOrNull() == 'E' }

shouldThrow<NoSuchElementException> { empty.fifth() }
shouldThrow<NoSuchElementException> { emptyIterable.fifth() }
empty.fifthOrNull().shouldBe(null)
emptyIterable.fifthOrNull().shouldBe(null)
assertFailsWith<NoSuchElementException> { empty.fifth() }
assertFailsWith<NoSuchElementException> { emptyIterable.fifth() }

assertTrue { empty.fifthOrNull() == null }
assertTrue { emptyIterable.fifthOrNull() == null }
}

@Test
fun collection_penultimate() {
numbers.penultimate().shouldBe(9)
numbers.penultimateOrNull().shouldBe(9)
assertTrue { numbers.penultimate() == 9 }
assertTrue { numbers.penultimateOrNull() == 9 }

assertTrue { chars.penultimate() == 'E' }
assertTrue { chars.penultimateOrNull() == 'E' }

chars.penultimate().shouldBe('E')
chars.penultimateOrNull().shouldBe('E')
assertFailsWith<NoSuchElementException> { empty.penultimate() }
assertFailsWith<NoSuchElementException> { emptyIterable.penultimate() }

shouldThrow<NoSuchElementException> { empty.penultimate() }
shouldThrow<NoSuchElementException> { emptyIterable.penultimate() }
empty.penultimateOrNull().shouldBe(null)
emptyIterable.penultimateOrNull().shouldBe(null)
assertTrue { empty.penultimateOrNull() == null }
assertTrue { emptyIterable.penultimateOrNull() == null }

shouldThrow<NoSuchElementException> { listOf(1).penultimate() }
shouldThrow<NoSuchElementException> { listOf(1).asIterable().penultimate() }
assertFailsWith<NoSuchElementException> { listOf(1).penultimate() }
assertFailsWith<NoSuchElementException> { listOf(1).asIterable().penultimate() }
}

@Test
fun remove_duplicate_empty_lines() {
listOf("a", "b", "", "", "c", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
listOf("a", "b", "", "", "", "c", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
listOf("a", "b", "", "", "c", "", "").removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
listOf("a", "", "", "", "b", "", "").removeDuplicateEmptyLines().shouldBe("a\n\nb\n")
emptyList<String>().removeDuplicateEmptyLines().shouldBe("")
listOf("").removeDuplicateEmptyLines().shouldBe("")
assertTrue {
listOf("a", "b", "", "", "c", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
}
assertTrue {
listOf("a", "b", "", "", "", "c", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
}
assertTrue {
listOf("a", "b", "", "", "c", "", "").removeDuplicateEmptyLines() == "a\nb\n\nc\n"
}
assertTrue {
listOf("a", "", "", "", "b", "", "").removeDuplicateEmptyLines() == "a\n\nb\n"
}
assertTrue { emptyList<String>().removeDuplicateEmptyLines() == "" }
assertTrue { listOf("").removeDuplicateEmptyLines() == "" }
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package com.javiersc.kotlin.stdlib

import io.kotest.matchers.booleans.shouldBeFalse
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldBeEmpty
import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class StringsTest {

@Test
fun string_remove() {
"Hello, World".remove("Hello, ").shouldBe("World")
"Hello, World".remove("bla").shouldBe("Hello, World")
"Hello, World".remove("llo", "rld").shouldBe("He, Wo")
assertTrue { "Hello, World".remove("Hello, ") == "World" }
assertTrue { "Hello, World".remove("bla") == "Hello, World" }
assertTrue { "Hello, World".remove("llo", "rld") == "He, Wo" }
}

@Test
fun string_replace() {
"Hello, World".replace("ello" to "ELLO", "orld" to "ORLD").shouldBe("HELLO, WORLD")
assertTrue { "Hello, World".replace("ello" to "ELLO", "orld" to "ORLD") == "HELLO, WORLD" }
}

@Test
Expand All @@ -27,36 +25,36 @@ class StringsTest {
val empty = ""
val notBlank = "Hello, World"

nullable.isNotNullNorBlank().shouldBeFalse()
nullable.isNotNullNorEmpty().shouldBeFalse()
blank.isNotNullNorBlank().shouldBeFalse()
blank.isNotNullNorEmpty().shouldBeTrue()
empty.isNotNullNorBlank().shouldBeFalse()
empty.isNotNullNorEmpty().shouldBeFalse()
notBlank.isNotNullNorBlank().shouldBeTrue()
notBlank.isNotNullNorEmpty().shouldBeTrue()
assertFalse { nullable.isNotNullNorBlank() }
assertFalse { nullable.isNotNullNorEmpty() }
assertFalse { blank.isNotNullNorBlank() }
assertTrue { blank.isNotNullNorEmpty() }
assertFalse { empty.isNotNullNorBlank() }
assertFalse { empty.isNotNullNorEmpty() }
assertTrue { notBlank.isNotNullNorBlank() }
assertTrue { notBlank.isNotNullNorEmpty() }
}

@Test
fun empty_string() {
String.Empty.shouldBeEmpty()
assertTrue { String.Empty == "" }
}

@Test
fun remove_duplicate_empty_lines() {
"a\nb\n\n\nc\n".removeDuplicateEmptyLines().shouldBe("a\nb\n\nc\n")
"a\n\nb\n\n\nc\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n\nc\n")
"a\n\nb\n\n\nc\n\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n\nc\n")
"a\n\n\n\n\nb\n\n".removeDuplicateEmptyLines().shouldBe("a\n\nb\n")
assertTrue { "a\nb\n\n\nc\n".removeDuplicateEmptyLines() == "a\nb\n\nc\n" }
assertTrue { "a\n\nb\n\n\nc\n".removeDuplicateEmptyLines() == "a\n\nb\n\nc\n" }
assertTrue { "a\n\nb\n\n\nc\n\n".removeDuplicateEmptyLines() == "a\n\nb\n\nc\n" }
assertTrue { "a\n\n\n\n\nb\n\n".removeDuplicateEmptyLines() == "a\n\nb\n" }
}

@Test
fun end_with_new_line() {
"a".endWithNewLine().shouldBe("a\n")
"a\n".endWithNewLine().shouldBe("a\n")
"".endWithNewLine().shouldBe("")
"a\nb".endWithNewLine().shouldBe("a\nb\n")
"".endWithNewLine().shouldBe("")
"\n".endWithNewLine().shouldBe("\n")
assertTrue { "a".endWithNewLine() == "a\n" }
assertTrue { "a\n".endWithNewLine() == "a\n" }
assertTrue { "".endWithNewLine() == "" }
assertTrue { "a\nb".endWithNewLine() == "a\nb\n" }
assertTrue { "".endWithNewLine() == "" }
assertTrue { "\n".endWithNewLine() == "\n" }
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ hubdle {
multiplatform {
features {
extendedStdlib(enabled = false)
extendedTesting(enabled = false)
}

common {
main {
dependencies {
implementation(jetbrainsKotlinTest())
implementation(jetbrainsKotlinTestAnnotationsCommon())
implementation(jetbrainsKotlinTestJunit())
}
}
Expand Down
Loading

0 comments on commit deaeba4

Please sign in to comment.