@@ -3,10 +3,27 @@ package de.joshuagleitze.stringnotation
33import ch.tutteli.atrium.api.fluent.en_GB.asIterable
44import ch.tutteli.atrium.api.fluent.en_GB.containsExactly
55import ch.tutteli.atrium.api.fluent.en_GB.feature
6+ import ch.tutteli.atrium.api.fluent.en_GB.notToBe
7+ import ch.tutteli.atrium.api.fluent.en_GB.toBe
68import ch.tutteli.atrium.api.verbs.expect
79import org.junit.jupiter.api.Test
810
911class WordTest {
12+ @Test
13+ fun `implements #equals` () {
14+ val aInstance = Word (" a" )
15+ expect(aInstance).toBe(aInstance)
16+ expect(aInstance).toBe(Word (" a" ))
17+ expect(Word (" a" )).notToBe(Word (" A" ))
18+ }
19+
20+ @Test
21+ fun `implements #hashCode` () {
22+ expect(Word (" a" ))
23+ .feature(Word ::hashCode)
24+ .toBe(Word (" a" ).hashCode())
25+ }
26+
1027 @Test
1128 fun `exposes parts as list` () {
1229 expect(Word (" with" , " parts" )).feature(Word ::partsList).containsExactly(" with" , " parts" )
@@ -24,22 +41,34 @@ class WordTest {
2441 @Test
2542 fun `allows to add parts` () {
2643 expect((Word (" with" ) + " more" + " parts" ))
27- .feature(Word ::partsList)
28- .containsExactly(" with" , " more" , " parts" )
44+ .toBe(Word (" with" , " more" , " parts" ))
2945 }
3046
3147 @Test
3248 fun `allows to add words` () {
3349 expect(Word (" with" ) + Word (" more" , " parts" ))
34- .feature(Word ::partsList)
35- .containsExactly(" with" , " more" , " parts" )
50+ .toBe(Word (" with" , " more" , " parts" ))
3651 }
3752
3853 @Test
39- fun `allows to transform parts` () {
54+ fun `allows to map parts` () {
4055 expect(Word (" a" , " b" , " c" ))
4156 .feature(Word ::mapParts, String ::toUpperCase)
42- .feature(Word ::partsList)
43- .containsExactly(" A" , " B" , " C" );
57+ .toBe(Word (" A" , " B" , " C" ))
58+ }
59+
60+ @Test
61+ fun `allows to flatMap parts` () {
62+ expect(Word (" a" , " b" ))
63+ .feature(Word ::flatMapParts) { it -> sequenceOf(" ${it} 1" , " ${it} 2" ) }
64+ .toBe(Word (" a1" , " a2" , " b1" , " b2" ))
65+ }
66+
67+ @Test
68+ fun `allows to parse parts from a notation` () {
69+ expect(" these are words with UpperCamelCase" )
70+ .feature(String ::fromNotation, NormalWords )
71+ .feature(Word ::partsFromNotation, UpperCamelCase )
72+ .toBe(Word (" these" , " are" , " words" , " with" , " upper" , " camel" , " case" ))
4473 }
4574}
0 commit comments