Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 8, 11, 17, 21, 25 ]
java-version: [ 11, 17, 21, 25 ]
steps:
- name: Checkout
uses: actions/checkout@v5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build/

### IntelliJ
/.idea/

### Kotlin
/.kotlin/
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
testImplementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:0.15.0")
testImplementation("ch.tutteli.atrium:atrium-fluent:1.2.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.14.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.14.1")

Expand All @@ -31,7 +31,7 @@ dependencies {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.14.1")
}

val compilationTargetJavaVersion = JavaLanguageVersion.of(8)
val compilationTargetJavaVersion = JavaLanguageVersion.of(11)

java {
toolchain {
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/BaseNotationTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.joshuagleitze.stringnotation

import ch.tutteli.atrium.api.fluent.en_GB.feature
import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.verbs.expect
import org.junit.jupiter.api.Assumptions.assumeTrue
import org.junit.jupiter.api.TestInstance
Expand All @@ -22,7 +22,7 @@ abstract class BaseNotationTest(
fun `parses words correctly`(minimumJavaVersion: Int, input: String, expectedWord: Word) {
assumeTrue(currentJavaVersion >= minimumJavaVersion, "Requires at least Java $minimumJavaVersion")
expect(input.fromNotation(notation)) {
feature(Word::partsList).toBe(expectedWord.partsList)
feature(Word::partsList).toEqual(expectedWord.partsList)
}
}

Expand All @@ -31,7 +31,7 @@ abstract class BaseNotationTest(
fun `prints words correctly`(minimumJavaVersion: Int, expectedResult: String, sourceWord: Word) {
assumeTrue(currentJavaVersion >= minimumJavaVersion, "Requires at least Java $minimumJavaVersion")
expect(sourceWord) {
feature(Word::toNotation, notation).toBe(expectedResult)
feature(Word::toNotation, notation).toEqual(expectedResult)
}
}

Expand All @@ -41,7 +41,7 @@ abstract class BaseNotationTest(
assumeTrue(currentJavaVersion >= minimumJavaVersion, "Requires at least Java $minimumJavaVersion")
expect(word) {
feature(String::fromNotation, notation) {
feature(Word::toNotation, notation).toBe(word)
feature(Word::toNotation, notation).toEqual(word)
}
}
}
Expand Down
34 changes: 17 additions & 17 deletions src/test/kotlin/WordTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,65 @@ class WordTest {
@Test
fun `implements #equals`() {
val aInstance = Word("a")
expect(aInstance).toBe(aInstance)
expect(aInstance).toBe(Word("a"))
expect(Word("a")).notToBe(Word("A"))
expect(aInstance).toEqual(aInstance)
expect(aInstance).toEqual(Word("a"))
expect(Word("a")).notToEqual(Word("A"))
}

@Test
fun `implements #hashCode`() {
expect(Word("a"))
.feature(Word::hashCode)
.toBe(Word("a").hashCode())
.toEqual(Word("a").hashCode())
}

@Test
fun `exposes parts as list`() {
expect(Word("with", "parts")).feature(Word::partsList).containsExactly("with", "parts")
expect(Word(listOf("with", "parts"))).feature(Word::partsList).containsExactly("with", "parts")
expect(Word(sequenceOf("with", "parts"))).feature(Word::partsList).containsExactly("with", "parts")
expect(Word("with", "parts")).feature(Word::partsList).toContainExactly("with", "parts")
expect(Word(listOf("with", "parts"))).feature(Word::partsList).toContainExactly("with", "parts")
expect(Word(sequenceOf("with", "parts"))).feature(Word::partsList).toContainExactly("with", "parts")
}

@Test
fun `exposes parts as sequence`() {
expect(Word("with", "parts")).feature(Word::parts).asIterable().containsExactly("with", "parts")
expect(Word(listOf("with", "parts"))).feature(Word::parts).asIterable().containsExactly("with", "parts")
expect(Word(sequenceOf("with", "parts"))).feature(Word::parts).asIterable().containsExactly("with", "parts")
expect(Word("with", "parts")).feature(Word::parts).asIterable().toContainExactly("with", "parts")
expect(Word(listOf("with", "parts"))).feature(Word::parts).asIterable().toContainExactly("with", "parts")
expect(Word(sequenceOf("with", "parts"))).feature(Word::parts).asIterable().toContainExactly("with", "parts")
}

@Test
fun `allows to add parts`() {
expect((Word("with") + "more" + "parts"))
.toBe(Word("with", "more", "parts"))
.toEqual(Word("with", "more", "parts"))
expect(Word("with").plus("more", "parts"))
.toBe(Word("with", "more", "parts"))
.toEqual(Word("with", "more", "parts"))
}

@Test
fun `allows to add words`() {
expect(Word("with") + Word("more", "parts"))
.toBe(Word("with", "more", "parts"))
.toEqual(Word("with", "more", "parts"))
}

@Test
fun `allows to map parts`() {
expect(Word("a", "b", "c"))
.feature(Word::mapParts, String::uppercase)
.toBe(Word("A", "B", "C"))
.toEqual(Word("A", "B", "C"))
}

@Test
fun `allows to flatMap parts`() {
expect(Word("a", "b"))
.feature(Word::flatMapParts) { it -> sequenceOf("${it}1", "${it}2") }
.toBe(Word("a1", "a2", "b1", "b2"))
.feature(Word::flatMapParts) { sequenceOf("${it}1", "${it}2") }
.toEqual(Word("a1", "a2", "b1", "b2"))
}

@Test
fun `allows to parse parts from a notation`() {
expect("these are words with UpperCamelCase")
.feature(String::fromNotation, NormalWords)
.feature(Word::partsFromNotation, UpperCamelCase)
.toBe(Word("these", "are", "words", "with", "upper", "camel", "case"))
.toEqual(Word("these", "are", "words", "with", "upper", "camel", "case"))
}
}