@@ -8,10 +8,10 @@ import kotlin.test.assertTrue
8
8
9
9
internal class CollectionsTest {
10
10
11
- private val numbers: List <Int > = listOf ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 )
11
+ private val numbers: List <Int > = ( 1 .. 10 ).toList( )
12
12
private val numbersIterable: Iterable <Int > = IntRange (1 , 10 )
13
- private val chars: List <Char > = listOf (' A' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' )
14
- private val charsIterable: Iterable <Char > = CharRange (' A' , ' F ' )
13
+ private val chars: List <Char > = (' A' .. ' Z ' ).toList( )
14
+ private val charsIterable: Iterable <Char > = CharRange (' A' , ' Z ' )
15
15
private val empty: List <Char > = emptyList()
16
16
private val emptyIterable: Iterable <Char > = CharRange .EMPTY
17
17
@@ -89,17 +89,112 @@ internal class CollectionsTest {
89
89
assertTrue { emptyIterable.fifthOrNull() == null }
90
90
}
91
91
92
+ @Test
93
+ fun collection_sixth () {
94
+ assertTrue { numbers.sixth() == 6 }
95
+ assertTrue { numbersIterable.sixth() == 6 }
96
+ assertTrue { numbers.sixthOrNull() == 6 }
97
+ assertTrue { numbersIterable.sixthOrNull() == 6 }
98
+
99
+ assertTrue { chars.sixth() == ' F' }
100
+ assertTrue { charsIterable.sixth() == ' F' }
101
+ assertTrue { chars.sixthOrNull() == ' F' }
102
+ assertTrue { charsIterable.sixthOrNull() == ' F' }
103
+
104
+ assertFailsWith<NoSuchElementException > { empty.sixth() }
105
+ assertFailsWith<NoSuchElementException > { emptyIterable.sixth() }
106
+
107
+ assertTrue { empty.sixthOrNull() == null }
108
+ assertTrue { emptyIterable.sixthOrNull() == null }
109
+ }
110
+
111
+ @Test
112
+ fun collection_seventh () {
113
+ assertTrue { numbers.seventh() == 7 }
114
+ assertTrue { numbersIterable.seventh() == 7 }
115
+ assertTrue { numbers.seventhOrNull() == 7 }
116
+ assertTrue { numbersIterable.seventhOrNull() == 7 }
117
+
118
+ assertTrue { chars.seventh() == ' G' }
119
+ assertTrue { charsIterable.seventh() == ' G' }
120
+ assertTrue { chars.seventhOrNull() == ' G' }
121
+ assertTrue { charsIterable.seventhOrNull() == ' G' }
122
+
123
+ assertFailsWith<NoSuchElementException > { empty.seventh() }
124
+ assertFailsWith<NoSuchElementException > { emptyIterable.seventh() }
125
+
126
+ assertTrue { empty.seventhOrNull() == null }
127
+ assertTrue { emptyIterable.seventhOrNull() == null }
128
+ }
129
+
130
+ @Test
131
+ fun collection_eighth () {
132
+ assertTrue { numbers.eighth() == 8 }
133
+ assertTrue { numbersIterable.eighth() == 8 }
134
+ assertTrue { numbers.eighthOrNull() == 8 }
135
+ assertTrue { numbersIterable.eighthOrNull() == 8 }
136
+
137
+ assertTrue { chars.eighth() == ' H' }
138
+ assertTrue { charsIterable.eighth() == ' H' }
139
+ assertTrue { chars.eighthOrNull() == ' H' }
140
+ assertTrue { charsIterable.eighthOrNull() == ' H' }
141
+
142
+ assertFailsWith<NoSuchElementException > { empty.eighth() }
143
+ assertFailsWith<NoSuchElementException > { emptyIterable.eighth() }
144
+
145
+ assertTrue { empty.eighthOrNull() == null }
146
+ assertTrue { emptyIterable.eighthOrNull() == null }
147
+ }
148
+
149
+ @Test
150
+ fun collection_ninth () {
151
+ assertTrue { numbers.ninth() == 9 }
152
+ assertTrue { numbersIterable.ninth() == 9 }
153
+ assertTrue { numbers.ninthOrNull() == 9 }
154
+ assertTrue { numbersIterable.ninthOrNull() == 9 }
155
+
156
+ assertTrue { chars.ninth() == ' I' }
157
+ assertTrue { charsIterable.ninth() == ' I' }
158
+ assertTrue { chars.ninthOrNull() == ' I' }
159
+ assertTrue { charsIterable.ninthOrNull() == ' I' }
160
+
161
+ assertFailsWith<NoSuchElementException > { empty.ninth() }
162
+ assertFailsWith<NoSuchElementException > { emptyIterable.ninth() }
163
+
164
+ assertTrue { empty.ninthOrNull() == null }
165
+ assertTrue { emptyIterable.ninthOrNull() == null }
166
+ }
167
+
168
+ @Test
169
+ fun collection_tenth () {
170
+ assertTrue { numbers.tenth() == 10 }
171
+ assertTrue { numbersIterable.tenth() == 10 }
172
+ assertTrue { numbers.tenthOrNull() == 10 }
173
+ assertTrue { numbersIterable.tenthOrNull() == 10 }
174
+
175
+ assertTrue { chars.tenth() == ' J' }
176
+ assertTrue { charsIterable.tenth() == ' J' }
177
+ assertTrue { chars.tenthOrNull() == ' J' }
178
+ assertTrue { charsIterable.tenthOrNull() == ' J' }
179
+
180
+ assertFailsWith<NoSuchElementException > { empty.tenth() }
181
+ assertFailsWith<NoSuchElementException > { emptyIterable.tenth() }
182
+
183
+ assertTrue { empty.tenthOrNull() == null }
184
+ assertTrue { emptyIterable.tenthOrNull() == null }
185
+ }
186
+
92
187
@Test
93
188
fun collection_penultimate () {
94
189
assertTrue { numbers.penultimate() == 9 }
95
190
assertTrue { numbersIterable.penultimate() == 9 }
96
191
assertTrue { numbers.penultimateOrNull() == 9 }
97
192
assertTrue { numbersIterable.penultimateOrNull() == 9 }
98
193
99
- assertTrue { chars.penultimate() == ' E ' }
100
- assertTrue { charsIterable.penultimate() == ' E ' }
101
- assertTrue { chars.penultimateOrNull() == ' E ' }
102
- assertTrue { charsIterable.penultimateOrNull() == ' E ' }
194
+ assertTrue { chars.penultimate() == ' Y ' }
195
+ assertTrue { charsIterable.penultimate() == ' Y ' }
196
+ assertTrue { chars.penultimateOrNull() == ' Y ' }
197
+ assertTrue { charsIterable.penultimateOrNull() == ' Y ' }
103
198
104
199
assertFailsWith<NoSuchElementException > { empty.penultimate() }
105
200
assertFailsWith<NoSuchElementException > { emptyIterable.penultimate() }
0 commit comments