@@ -13,18 +13,21 @@ import kotlinx.coroutines.test.runTest
1313
1414class FlowTest {
1515 // region isEmpty
16- @Test fun isEmpty_empty_passes () = runTest {
16+ @Test
17+ fun isEmpty_empty_passes () = runTest {
1718 assertThat(flowOf<Any ?>()).isEmpty()
1819 }
1920
20- @Test fun isEmpty_non_empty_fails () = runTest {
21+ @Test
22+ fun isEmpty_non_empty_fails () = runTest {
2123 val error = assertFailsWith<AssertionError > {
2224 assertThat(flowOf<Any ?>(null )).isEmpty()
2325 }
2426 assertEquals(" expected to be empty but received:<null>" , error.message)
2527 }
2628
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 {
2831 val error = assertFailsWith<AssertionError > {
2932 assertThat(nonCompletingFlowOf(null )).isEmpty()
3033 }
@@ -33,11 +36,13 @@ class FlowTest {
3336 // endregion
3437
3538 // region isNotEmpty
36- @Test fun isNotEmpty_non_empty_passes () = runTest {
39+ @Test
40+ fun isNotEmpty_non_empty_passes () = runTest {
3741 assertThat(flowOf<Any ?>(null )).isNotEmpty()
3842 }
3943
40- @Test fun isNotEmpty_empty_fails () = runTest {
44+ @Test
45+ fun isNotEmpty_empty_fails () = runTest {
4146 val error = assertFailsWith<AssertionError > {
4247 assertThat(flowOf<Any ?>()).isNotEmpty()
4348 }
@@ -46,11 +51,13 @@ class FlowTest {
4651 // endregion
4752
4853 // region hasCount
49- @Test fun hasSize_correct_size_passes () = runTest {
54+ @Test
55+ fun hasSize_correct_size_passes () = runTest {
5056 assertThat(flowOf<Any ?>()).hasCount(0 )
5157 }
5258
53- @Test fun hasSize_wrong_size_fails () = runTest {
59+ @Test
60+ fun hasSize_wrong_size_fails () = runTest {
5461 val flow = flowOf<Any ?>()
5562 val error = assertFailsWith<AssertionError > {
5663 assertThat(flow).hasCount(1 )
@@ -60,15 +67,18 @@ class FlowTest {
6067 // endregion
6168
6269 // region contains
63- @Test fun contains_element_present_passes () = runTest {
70+ @Test
71+ fun contains_element_present_passes () = runTest {
6472 assertThat(flowOf(1 , 2 )).contains(2 )
6573 }
6674
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 {
6877 assertThat(nonCompletingFlowOf(1 , 2 )).contains(2 )
6978 }
7079
71- @Test fun contains_element_missing_fails () = runTest {
80+ @Test
81+ fun contains_element_missing_fails () = runTest {
7282 val error = assertFailsWith<AssertionError > {
7383 assertThat(flowOf<Any ?>()).contains(1 )
7484 }
@@ -77,18 +87,21 @@ class FlowTest {
7787 // endregion
7888
7989 // region doesNotContain
80- @Test fun doesNotContain_element_missing_passes () = runTest {
90+ @Test
91+ fun doesNotContain_element_missing_passes () = runTest {
8192 assertThat(flowOf<Any ?>()).doesNotContain(1 )
8293 }
8394
84- @Test fun doesNotContain_element_present_fails () = runTest {
95+ @Test
96+ fun doesNotContain_element_present_fails () = runTest {
8597 val error = assertFailsWith<AssertionError > {
8698 assertThat(flowOf(1 , 2 )).doesNotContain(2 )
8799 }
88100 assertEquals(" expected to not contain:<2> but received:<[1, 2]>" , error.message)
89101 }
90102
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 {
92105 val error = assertFailsWith<AssertionError > {
93106 assertThat(nonCompletingFlowOf(1 , 2 )).doesNotContain(2 )
94107 }
@@ -97,11 +110,13 @@ class FlowTest {
97110 // endregion
98111
99112 // region containsNone
100- @Test fun containsNone_missing_elements_passes () = runTest {
113+ @Test
114+ fun containsNone_missing_elements_passes () = runTest {
101115 assertThat(flowOf<Any ?>()).containsNone(1 )
102116 }
103117
104- @Test fun containsNone_present_element_fails () = runTest {
118+ @Test
119+ fun containsNone_present_element_fails () = runTest {
105120 val error = assertFailsWith<AssertionError > {
106121 assertThat(flowOf(1 , 2 )).containsNone(2 , 3 )
107122 }
@@ -112,7 +127,8 @@ class FlowTest {
112127 )
113128 }
114129
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 {
116132 val error = assertFailsWith<AssertionError > {
117133 assertThat(nonCompletingFlowOf(1 , 2 )).containsNone(2 , 3 )
118134 }
@@ -125,15 +141,18 @@ class FlowTest {
125141 // region
126142
127143 // region containsAtLeast
128- @Test fun containsAtLeast_all_elements_passes () = runTest {
144+ @Test
145+ fun containsAtLeast_all_elements_passes () = runTest {
129146 assertThat(flowOf(1 , 2 )).containsAtLeast(2 , 1 )
130147 }
131148
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 {
133151 assertThat(nonCompletingFlowOf(1 , 2 )).containsAtLeast(2 , 1 )
134152 }
135153
136- @Test fun containsAtLeast_some_elements_fails () = runTest {
154+ @Test
155+ fun containsAtLeast_some_elements_fails () = runTest {
137156 val error = assertFailsWith<AssertionError > {
138157 assertThat(flowOf(1 )).containsAtLeast(1 , 2 )
139158 }
@@ -146,11 +165,13 @@ class FlowTest {
146165 // endregion
147166
148167 // region containsOnly
149- @Test fun containsOnly_only_elements_passes () = runTest {
168+ @Test
169+ fun containsOnly_only_elements_passes () = runTest {
150170 assertThat(flowOf(1 , 2 )).containsOnly(2 , 1 )
151171 }
152172
153- @Test fun containsOnly_more_elements_fails () = runTest {
173+ @Test
174+ fun containsOnly_more_elements_fails () = runTest {
154175 val error = assertFailsWith<AssertionError > {
155176 assertThat(flowOf(1 , 2 , 3 )).containsOnly(2 , 1 )
156177 }
@@ -161,7 +182,8 @@ class FlowTest {
161182 )
162183 }
163184
164- @Test fun containsOnly_less_elements_fails () = runTest {
185+ @Test
186+ fun containsOnly_less_elements_fails () = runTest {
165187 val error = assertFailsWith<AssertionError > {
166188 assertThat(flowOf(1 , 2 , 3 )).containsOnly(2 , 1 , 3 , 4 )
167189 }
@@ -173,7 +195,8 @@ class FlowTest {
173195 )
174196 }
175197
176- @Test fun containsOnly_different_elements_fails () = runTest {
198+ @Test
199+ fun containsOnly_different_elements_fails () = runTest {
177200 val error = assertFailsWith<AssertionError > {
178201 assertThat(flowOf(1 )).containsOnly(2 )
179202 }
@@ -188,11 +211,13 @@ class FlowTest {
188211 // endregion
189212
190213 // 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 {
192216 assertThat(flowOf(1 , 2 )).containsExactly(1 , 2 )
193217 }
194218
195- @Test fun containsExactly_all_elements_in_different_order_fails () = runTest {
219+ @Test
220+ fun containsExactly_all_elements_in_different_order_fails () = runTest {
196221 val error = assertFailsWith<AssertionError > {
197222 assertThat(flowOf(1 , 2 )).containsExactly(2 , 1 )
198223 }
@@ -204,7 +229,8 @@ class FlowTest {
204229 )
205230 }
206231
207- @Test fun containsExactly_elements_in_different_order_fails2 () = runTest {
232+ @Test
233+ fun containsExactly_elements_in_different_order_fails2 () = runTest {
208234 val error = assertFailsWith<AssertionError > {
209235 assertThat(flowOf(" 1" , " 2" , " 3" )).containsExactly(" 2" , " 3" , " 1" )
210236 }
@@ -216,7 +242,8 @@ class FlowTest {
216242 )
217243 }
218244
219- @Test fun containsExactly_same_indexes_are_together () = runTest {
245+ @Test
246+ fun containsExactly_same_indexes_are_together () = runTest {
220247 val error = assertFailsWith<AssertionError > {
221248 assertThat(flowOf(1 , 1 )).containsExactly(2 , 2 )
222249 }
@@ -230,7 +257,8 @@ class FlowTest {
230257 )
231258 }
232259
233- @Test fun containsExactly_missing_element_fails () = runTest {
260+ @Test
261+ fun containsExactly_missing_element_fails () = runTest {
234262 val error = assertFailsWith<AssertionError > {
235263 assertThat(flowOf(1 , 2 )).containsExactly(3 )
236264 }
@@ -243,7 +271,8 @@ class FlowTest {
243271 )
244272 }
245273
246- @Test fun containsExactly_extra_element_fails () = runTest {
274+ @Test
275+ fun containsExactly_extra_element_fails () = runTest {
247276 val error = assertFailsWith<AssertionError > {
248277 assertThat(flowOf(1 , 2 )).containsExactly(1 , 2 , 3 )
249278 }
@@ -254,7 +283,8 @@ class FlowTest {
254283 )
255284 }
256285
257- @Test fun containsExactly_missing_element_in_middle_fails () = runTest {
286+ @Test
287+ fun containsExactly_missing_element_in_middle_fails () = runTest {
258288 val error = assertFailsWith<AssertionError > {
259289 assertThat(flowOf(1 , 3 )).containsExactly(1 , 2 , 3 )
260290 }
@@ -265,7 +295,8 @@ class FlowTest {
265295 )
266296 }
267297
268- @Test fun containsExactly_extra_element_in_middle_fails () = runTest {
298+ @Test
299+ fun containsExactly_extra_element_in_middle_fails () = runTest {
269300 val error = assertFailsWith<AssertionError > {
270301 assertThat(flowOf(1 , 2 , 3 )).containsExactly(1 , 3 )
271302 }
0 commit comments