forked from MarkusAmshove/Kluent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShouldContainNoneWithCheckShould.kt
129 lines (109 loc) · 4.07 KB
/
ShouldContainNoneWithCheckShould.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package org.amshove.kluent.tests.collections
import org.amshove.kluent.shouldContainNone
import kotlin.test.Test
import kotlin.test.assertFails
class ShouldContainNoneWithCheckShould {
@Test
fun passWhenTestingAListWithNoMatchingValue() {
val list = listOf("Hello", "World", "Wide", "Web")
list shouldContainNone { it == "Cat" }
}
@Test
fun failWhenTestingAListWithAtLeastOneMatchingValue() {
val list = listOf("Hello", "World", "Wide", "Web")
assertFails { list shouldContainNone { it == "Hello" } }
}
@Test
fun passWhenTestingAnIntListWithNoMatchingValue() {
val list = listOf(1, 3, 5)
list shouldContainNone { it == 2 }
list shouldContainNone { it % 2 == 0 }
}
@Test
fun failWhenTestingAnIntListWithAtLeastOneMatchingValue() {
val list = listOf(1, 3, 5)
assertFails { list shouldContainNone { it == 3 } }
assertFails { list shouldContainNone { it == 5 } }
}
@Test
fun passWhenTestingABooleanListWithNoMatchingValue() {
val list = listOf(true)
list shouldContainNone { !it }
}
@Test
fun failWhenTestingABooleanListWithAtLeastOneMatchingValue() {
val list = listOf(false, true)
assertFails { list shouldContainNone { !it } }
assertFails { list shouldContainNone { it } }
}
@Test
fun passWhenTestingAByteListWithNoMatchingValue() {
val list = listOf<Byte>(3, 4)
list shouldContainNone { it == 9.toByte() }
}
@Test
fun failWhenTestingAByteListWithAtLeastOneMatchingValue() {
val list = listOf<Byte>(5, 7, 8)
assertFails { list shouldContainNone { it == 5.toByte() } }
assertFails { list shouldContainNone { it == 7.toByte() } }
}
@Test
fun passWhenTestingACharListWithNoMatchingValue() {
val list = listOf('a', 'o', 'e', 'i', 'u')
list shouldContainNone { it == 'b' }
}
@Test
fun failWhenTestingACharListWithAtLeastOneMatchingValue() {
val list = listOf('a', 'o', 'e', 'i', 'u')
assertFails { list shouldContainNone { it == 'o' } }
assertFails { list shouldContainNone { it in listOf('o', 'u') } }
}
@Test
fun passWhenTestingADoubleListWithNoMatchingValue() {
val list = listOf(5.6, 7.8, 8.0)
list shouldContainNone { it == 1.2 }
list shouldContainNone { it in listOf(1.2, 3.9) }
}
@Test
fun failWhenTestingADoubleArrayWithAtLeastOneMatchingValue() {
val list = listOf(8.9, 9.1, 12.3)
assertFails { list shouldContainNone { it == 12.3 } }
assertFails { list shouldContainNone { it in listOf(12.3, 1.0) } }
}
@Test
fun passWhenTestingAFloatListWithNoMatchingValue() {
val list = listOf(0f, 1f, 2f)
list shouldContainNone { it == 3f }
list shouldContainNone { it in listOf(3f, 4f) }
}
@Test
fun failWhenTestingAFloatListWithAtLeastOneMatchingValue() {
val list = listOf(2f, 5f, 7f)
assertFails { list shouldContainNone { it == 5f } }
assertFails { list shouldContainNone { it in listOf(5f, 2f, 7f) } }
}
@Test
fun passWhenTestingALongListWithNoMatchingValue() {
val list = listOf(2L, 100L, 200L)
list shouldContainNone { it == 3L }
list shouldContainNone { it in listOf(3L, 50L, 75L) }
}
@Test
fun failWhenTestingALongListWithAtLeastOneMatchingValue() {
val list = listOf(1L, 4L)
assertFails { list shouldContainNone { it == 4L } }
assertFails { list shouldContainNone { it in listOf(4L, 5L, 89L) } }
}
@Test
fun passWhenTestingAShortListWithNoMatchingValue() {
val list = listOf<Short>(5, 8, 12)
list shouldContainNone { it == 7.toShort() }
list shouldContainNone { it in listOf<Short>(7, 6, -1) }
}
@Test
fun failWhenTestingAShortListWithAtLeastOneMatchingValue() {
val list = listOf<Short>(2, 14, 3)
assertFails { list shouldContainNone { it == 14.toShort() } }
assertFails { list shouldContainNone { it in listOf<Short>(14, 1, 7) } }
}
}