@@ -3,10 +3,27 @@ package de.joshuagleitze.stringnotation
3
3
import ch.tutteli.atrium.api.fluent.en_GB.asIterable
4
4
import ch.tutteli.atrium.api.fluent.en_GB.containsExactly
5
5
import 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
6
8
import ch.tutteli.atrium.api.verbs.expect
7
9
import org.junit.jupiter.api.Test
8
10
9
11
class 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
+
10
27
@Test
11
28
fun `exposes parts as list` () {
12
29
expect(Word (" with" , " parts" )).feature(Word ::partsList).containsExactly(" with" , " parts" )
@@ -24,22 +41,34 @@ class WordTest {
24
41
@Test
25
42
fun `allows to add parts` () {
26
43
expect((Word (" with" ) + " more" + " parts" ))
27
- .feature(Word ::partsList)
28
- .containsExactly(" with" , " more" , " parts" )
44
+ .toBe(Word (" with" , " more" , " parts" ))
29
45
}
30
46
31
47
@Test
32
48
fun `allows to add words` () {
33
49
expect(Word (" with" ) + Word (" more" , " parts" ))
34
- .feature(Word ::partsList)
35
- .containsExactly(" with" , " more" , " parts" )
50
+ .toBe(Word (" with" , " more" , " parts" ))
36
51
}
37
52
38
53
@Test
39
- fun `allows to transform parts` () {
54
+ fun `allows to map parts` () {
40
55
expect(Word (" a" , " b" , " c" ))
41
56
.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" ))
44
73
}
45
74
}
0 commit comments