@@ -13,18 +13,21 @@ import kotlinx.coroutines.test.runTest
13
13
14
14
class FlowTest {
15
15
// region isEmpty
16
- @Test fun isEmpty_empty_passes () = runTest {
16
+ @Test
17
+ fun isEmpty_empty_passes () = runTest {
17
18
assertThat(flowOf<Any ?>()).isEmpty()
18
19
}
19
20
20
- @Test fun isEmpty_non_empty_fails () = runTest {
21
+ @Test
22
+ fun isEmpty_non_empty_fails () = runTest {
21
23
val error = assertFailsWith<AssertionError > {
22
24
assertThat(flowOf<Any ?>(null )).isEmpty()
23
25
}
24
26
assertEquals(" expected to be empty but received:<null>" , error.message)
25
27
}
26
28
27
- @Test fun isEmpty_non_empty_in_flow_that_doesnt_complete_fails () = runTest {
29
+ @Test
30
+ fun isEmpty_non_empty_in_flow_that_doesnt_complete_fails () = runTest {
28
31
val error = assertFailsWith<AssertionError > {
29
32
assertThat(nonCompletingFlowOf(null )).isEmpty()
30
33
}
@@ -33,11 +36,13 @@ class FlowTest {
33
36
// endregion
34
37
35
38
// region isNotEmpty
36
- @Test fun isNotEmpty_non_empty_passes () = runTest {
39
+ @Test
40
+ fun isNotEmpty_non_empty_passes () = runTest {
37
41
assertThat(flowOf<Any ?>(null )).isNotEmpty()
38
42
}
39
43
40
- @Test fun isNotEmpty_empty_fails () = runTest {
44
+ @Test
45
+ fun isNotEmpty_empty_fails () = runTest {
41
46
val error = assertFailsWith<AssertionError > {
42
47
assertThat(flowOf<Any ?>()).isNotEmpty()
43
48
}
@@ -46,11 +51,13 @@ class FlowTest {
46
51
// endregion
47
52
48
53
// region hasCount
49
- @Test fun hasSize_correct_size_passes () = runTest {
54
+ @Test
55
+ fun hasSize_correct_size_passes () = runTest {
50
56
assertThat(flowOf<Any ?>()).hasCount(0 )
51
57
}
52
58
53
- @Test fun hasSize_wrong_size_fails () = runTest {
59
+ @Test
60
+ fun hasSize_wrong_size_fails () = runTest {
54
61
val flow = flowOf<Any ?>()
55
62
val error = assertFailsWith<AssertionError > {
56
63
assertThat(flow).hasCount(1 )
@@ -60,15 +67,18 @@ class FlowTest {
60
67
// endregion
61
68
62
69
// region contains
63
- @Test fun contains_element_present_passes () = runTest {
70
+ @Test
71
+ fun contains_element_present_passes () = runTest {
64
72
assertThat(flowOf(1 , 2 )).contains(2 )
65
73
}
66
74
67
- @Test fun contains_element_present_in_flow_that_doesnt_complete_passes () = runTest {
75
+ @Test
76
+ fun contains_element_present_in_flow_that_doesnt_complete_passes () = runTest {
68
77
assertThat(nonCompletingFlowOf(1 , 2 )).contains(2 )
69
78
}
70
79
71
- @Test fun contains_element_missing_fails () = runTest {
80
+ @Test
81
+ fun contains_element_missing_fails () = runTest {
72
82
val error = assertFailsWith<AssertionError > {
73
83
assertThat(flowOf<Any ?>()).contains(1 )
74
84
}
@@ -77,18 +87,21 @@ class FlowTest {
77
87
// endregion
78
88
79
89
// region doesNotContain
80
- @Test fun doesNotContain_element_missing_passes () = runTest {
90
+ @Test
91
+ fun doesNotContain_element_missing_passes () = runTest {
81
92
assertThat(flowOf<Any ?>()).doesNotContain(1 )
82
93
}
83
94
84
- @Test fun doesNotContain_element_present_fails () = runTest {
95
+ @Test
96
+ fun doesNotContain_element_present_fails () = runTest {
85
97
val error = assertFailsWith<AssertionError > {
86
98
assertThat(flowOf(1 , 2 )).doesNotContain(2 )
87
99
}
88
100
assertEquals(" expected to not contain:<2> but received:<[1, 2]>" , error.message)
89
101
}
90
102
91
- @Test fun doesNotContain_element_present_in_flow_that_doesnt_complete_fails () = runTest {
103
+ @Test
104
+ fun doesNotContain_element_present_in_flow_that_doesnt_complete_fails () = runTest {
92
105
val error = assertFailsWith<AssertionError > {
93
106
assertThat(nonCompletingFlowOf(1 , 2 )).doesNotContain(2 )
94
107
}
@@ -97,11 +110,13 @@ class FlowTest {
97
110
// endregion
98
111
99
112
// region containsNone
100
- @Test fun containsNone_missing_elements_passes () = runTest {
113
+ @Test
114
+ fun containsNone_missing_elements_passes () = runTest {
101
115
assertThat(flowOf<Any ?>()).containsNone(1 )
102
116
}
103
117
104
- @Test fun containsNone_present_element_fails () = runTest {
118
+ @Test
119
+ fun containsNone_present_element_fails () = runTest {
105
120
val error = assertFailsWith<AssertionError > {
106
121
assertThat(flowOf(1 , 2 )).containsNone(2 , 3 )
107
122
}
@@ -112,7 +127,8 @@ class FlowTest {
112
127
)
113
128
}
114
129
115
- @Test fun containsNone_present_element_in_flow_that_doesnt_complete_fails () = runTest {
130
+ @Test
131
+ fun containsNone_present_element_in_flow_that_doesnt_complete_fails () = runTest {
116
132
val error = assertFailsWith<AssertionError > {
117
133
assertThat(nonCompletingFlowOf(1 , 2 )).containsNone(2 , 3 )
118
134
}
@@ -125,15 +141,18 @@ class FlowTest {
125
141
// region
126
142
127
143
// region containsAtLeast
128
- @Test fun containsAtLeast_all_elements_passes () = runTest {
144
+ @Test
145
+ fun containsAtLeast_all_elements_passes () = runTest {
129
146
assertThat(flowOf(1 , 2 )).containsAtLeast(2 , 1 )
130
147
}
131
148
132
- @Test fun containsAtLeast_all_elements_in_flow_that_doesnt_complete_passes () = runTest {
149
+ @Test
150
+ fun containsAtLeast_all_elements_in_flow_that_doesnt_complete_passes () = runTest {
133
151
assertThat(nonCompletingFlowOf(1 , 2 )).containsAtLeast(2 , 1 )
134
152
}
135
153
136
- @Test fun containsAtLeast_some_elements_fails () = runTest {
154
+ @Test
155
+ fun containsAtLeast_some_elements_fails () = runTest {
137
156
val error = assertFailsWith<AssertionError > {
138
157
assertThat(flowOf(1 )).containsAtLeast(1 , 2 )
139
158
}
@@ -146,11 +165,13 @@ class FlowTest {
146
165
// endregion
147
166
148
167
// region containsOnly
149
- @Test fun containsOnly_only_elements_passes () = runTest {
168
+ @Test
169
+ fun containsOnly_only_elements_passes () = runTest {
150
170
assertThat(flowOf(1 , 2 )).containsOnly(2 , 1 )
151
171
}
152
172
153
- @Test fun containsOnly_more_elements_fails () = runTest {
173
+ @Test
174
+ fun containsOnly_more_elements_fails () = runTest {
154
175
val error = assertFailsWith<AssertionError > {
155
176
assertThat(flowOf(1 , 2 , 3 )).containsOnly(2 , 1 )
156
177
}
@@ -161,7 +182,8 @@ class FlowTest {
161
182
)
162
183
}
163
184
164
- @Test fun containsOnly_less_elements_fails () = runTest {
185
+ @Test
186
+ fun containsOnly_less_elements_fails () = runTest {
165
187
val error = assertFailsWith<AssertionError > {
166
188
assertThat(flowOf(1 , 2 , 3 )).containsOnly(2 , 1 , 3 , 4 )
167
189
}
@@ -173,7 +195,8 @@ class FlowTest {
173
195
)
174
196
}
175
197
176
- @Test fun containsOnly_different_elements_fails () = runTest {
198
+ @Test
199
+ fun containsOnly_different_elements_fails () = runTest {
177
200
val error = assertFailsWith<AssertionError > {
178
201
assertThat(flowOf(1 )).containsOnly(2 )
179
202
}
@@ -188,11 +211,13 @@ class FlowTest {
188
211
// endregion
189
212
190
213
// region containsExactly
191
- @Test fun containsExactly_all_elements_in_same_order_passes () = runTest {
214
+ @Test
215
+ fun containsExactly_all_elements_in_same_order_passes () = runTest {
192
216
assertThat(flowOf(1 , 2 )).containsExactly(1 , 2 )
193
217
}
194
218
195
- @Test fun containsExactly_all_elements_in_different_order_fails () = runTest {
219
+ @Test
220
+ fun containsExactly_all_elements_in_different_order_fails () = runTest {
196
221
val error = assertFailsWith<AssertionError > {
197
222
assertThat(flowOf(1 , 2 )).containsExactly(2 , 1 )
198
223
}
@@ -204,7 +229,8 @@ class FlowTest {
204
229
)
205
230
}
206
231
207
- @Test fun containsExactly_elements_in_different_order_fails2 () = runTest {
232
+ @Test
233
+ fun containsExactly_elements_in_different_order_fails2 () = runTest {
208
234
val error = assertFailsWith<AssertionError > {
209
235
assertThat(flowOf(" 1" , " 2" , " 3" )).containsExactly(" 2" , " 3" , " 1" )
210
236
}
@@ -216,7 +242,8 @@ class FlowTest {
216
242
)
217
243
}
218
244
219
- @Test fun containsExactly_same_indexes_are_together () = runTest {
245
+ @Test
246
+ fun containsExactly_same_indexes_are_together () = runTest {
220
247
val error = assertFailsWith<AssertionError > {
221
248
assertThat(flowOf(1 , 1 )).containsExactly(2 , 2 )
222
249
}
@@ -230,7 +257,8 @@ class FlowTest {
230
257
)
231
258
}
232
259
233
- @Test fun containsExactly_missing_element_fails () = runTest {
260
+ @Test
261
+ fun containsExactly_missing_element_fails () = runTest {
234
262
val error = assertFailsWith<AssertionError > {
235
263
assertThat(flowOf(1 , 2 )).containsExactly(3 )
236
264
}
@@ -243,7 +271,8 @@ class FlowTest {
243
271
)
244
272
}
245
273
246
- @Test fun containsExactly_extra_element_fails () = runTest {
274
+ @Test
275
+ fun containsExactly_extra_element_fails () = runTest {
247
276
val error = assertFailsWith<AssertionError > {
248
277
assertThat(flowOf(1 , 2 )).containsExactly(1 , 2 , 3 )
249
278
}
@@ -254,7 +283,8 @@ class FlowTest {
254
283
)
255
284
}
256
285
257
- @Test fun containsExactly_missing_element_in_middle_fails () = runTest {
286
+ @Test
287
+ fun containsExactly_missing_element_in_middle_fails () = runTest {
258
288
val error = assertFailsWith<AssertionError > {
259
289
assertThat(flowOf(1 , 3 )).containsExactly(1 , 2 , 3 )
260
290
}
@@ -265,7 +295,8 @@ class FlowTest {
265
295
)
266
296
}
267
297
268
- @Test fun containsExactly_extra_element_in_middle_fails () = runTest {
298
+ @Test
299
+ fun containsExactly_extra_element_in_middle_fails () = runTest {
269
300
val error = assertFailsWith<AssertionError > {
270
301
assertThat(flowOf(1 , 2 , 3 )).containsExactly(1 , 3 )
271
302
}
0 commit comments