Skip to content

Commit d641a47

Browse files
author
Silvio D'Alessandro
committed
Fix tests
1 parent 679d14e commit d641a47

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Diff for: assertk/src/commonTest/kotlin/test/assertk/assertions/IterableTest.kt

+22-22
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,14 @@ class IterableTest {
416416
}
417417

418418
@Test fun pair_extracting_function_passes() {
419-
assertThat(listOf(Thing("one", 1, '1'), Thing("two", 2, '2')) as Iterable<Thing>)
419+
assertThat(listOf(Thing("one", 1, listOf('1')), Thing("two", 2, listOf('2'))) as Iterable<Thing>)
420420
.extracting(Thing::one, Thing::two)
421421
.containsExactly("one" to 1, "two" to 2)
422422
}
423423

424424
@Test fun pair_extracting_function_fails() {
425425
val error = assertFails {
426-
assertThat(listOf(Thing("one", 1, '1'), Thing("two", 2, '2')) as Iterable<Thing>)
426+
assertThat(listOf(Thing("one", 1, listOf('1')), Thing("two", 2, listOf('2'))) as Iterable<Thing>)
427427
.extracting(Thing::one, Thing::two)
428428
.containsExactly("one" to 2, "two" to 1)
429429
}
@@ -432,51 +432,51 @@ class IterableTest {
432432
| at index:0 expected:<("one", 2)>
433433
| at index:0 unexpected:<("one", 1)>
434434
| at index:1 expected:<("two", 1)>
435-
| at index:1 unexpected:<("two", 2)> ([Thing(one=one, two=1, three=1), Thing(one=two, two=2, three=2)])""".trimMargin(),
435+
| at index:1 unexpected:<("two", 2)> ([Thing(one=one, two=1, three=[1]), Thing(one=two, two=2, three=[2])])""".trimMargin(),
436436
error.message
437437
)
438438
}
439439

440440
@Test fun triple_extracting_function_passes() {
441-
assertThat(listOf(Thing("one", 1, '1'), Thing("two", 2, '2')) as Iterable<Thing>)
441+
assertThat(listOf(Thing("one", 1, listOf('1')), Thing("two", 2, listOf('2'))) as Iterable<Thing>)
442442
.extracting(Thing::one, Thing::two, Thing::three)
443-
.containsExactly(Triple("one", 1, '1'), Triple("two", 2, '2'))
443+
.containsExactly(Triple("one", 1, listOf('1')), Triple("two", 2, listOf('2')))
444444
}
445445

446446
@Test fun triple_extracting_function_fails() {
447447
val error = assertFails {
448-
assertThat(listOf(Thing("one", 1, '1'), Thing("two", 2, '2')) as Iterable<Thing>)
448+
assertThat(listOf(Thing("one", 1, listOf('1')), Thing("two", 2, listOf('2'))) as Iterable<Thing>)
449449
.extracting(Thing::one, Thing::two, Thing::three)
450-
.containsExactly(Triple("one", 1, '2'), Triple("two", 2, '3'))
450+
.containsExactly(Triple("one", 1, listOf('2')), Triple("two", 2, listOf('3')))
451451
}
452452
assertEquals(
453-
"""expected to contain exactly:<[("one", 1, '2'), ("two", 2, '3')]> but was:<[("one", 1, '1'), ("two", 2, '2')]>
454-
| at index:0 expected:<("one", 1, '2')>
455-
| at index:0 unexpected:<("one", 1, '1')>
456-
| at index:1 expected:<("two", 2, '3')>
457-
| at index:1 unexpected:<("two", 2, '2')> ([Thing(one=one, two=1, three=1), Thing(one=two, two=2, three=2)])""".trimMargin(),
453+
"""expected to contain exactly:<[("one", 1, ['2']), ("two", 2, ['3'])]> but was:<[("one", 1, ['1']), ("two", 2, ['2'])]>
454+
| at index:0 expected:<("one", 1, ['2'])>
455+
| at index:0 unexpected:<("one", 1, ['1'])>
456+
| at index:1 expected:<("two", 2, ['3'])>
457+
| at index:1 unexpected:<("two", 2, ['2'])> ([Thing(one=one, two=1, three=[1]), Thing(one=two, two=2, three=[2])])""".trimMargin(),
458458
error.message
459459
)
460460
}
461461
//region extracting
462462

463463
//region flatExtracting
464464
@Test fun flat_extracting_function_passes() {
465-
val thing = Thing("one", 2, '3', listOf("A", "B"))
466-
assertThat(listOf(thing) as Iterable<Thing>).flatExtracting { it.four }.containsExactly("A", "B")
465+
val thing = Thing("one", 2, listOf('A', 'B'))
466+
assertThat(listOf(thing) as Iterable<Thing>).flatExtracting { it.three }.containsExactly('A', 'B')
467467
}
468468

469469
@Test fun flat_extracting_function_fails() {
470-
val thing = Thing("one", 2, '3', listOf("A", "B"))
470+
val thing = Thing("one", 2, listOf('A', 'B'))
471471
val error = assertFails {
472-
assertThat(listOf(thing) as Iterable<Thing>).flatExtracting { it.four }.containsExactly("C", "D")
472+
assertThat(listOf(thing) as Iterable<Thing>).flatExtracting { it.three }.containsExactly('C', 'D')
473473
}
474474
assertEquals(
475-
"""expected to contain exactly:<["C", "D"]> but was:<["A", "B"]>
476-
| at index:0 expected:<"C">
477-
| at index:0 unexpected:<"A">
478-
| at index:1 expected:<"D">
479-
| at index:1 unexpected:<"B"> ([Thing(one=one, two=2, three=3, four=[A, B])])""".trimMargin(), error.message
475+
"""expected to contain exactly:<['C', 'D']> but was:<['A', 'B']>
476+
| at index:0 expected:<'C'>
477+
| at index:0 unexpected:<'A'>
478+
| at index:1 expected:<'D'>
479+
| at index:1 unexpected:<'B'> ([Thing(one=one, two=2, three=[A, B])])""".trimMargin(), error.message
480480
)
481481
}
482482
//region flatExtracting
@@ -528,5 +528,5 @@ class IterableTest {
528528
}
529529
//endregion
530530

531-
data class Thing(val one: String, val two: Int, val three: Char, val four: List<String> = listOf())
531+
data class Thing(val one: String, val two: Int, val three: List<Char>)
532532
}

0 commit comments

Comments
 (0)