@@ -416,14 +416,14 @@ class IterableTest {
416
416
}
417
417
418
418
@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 >)
420
420
.extracting(Thing ::one, Thing ::two)
421
421
.containsExactly(" one" to 1 , " two" to 2 )
422
422
}
423
423
424
424
@Test fun pair_extracting_function_fails () {
425
425
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 >)
427
427
.extracting(Thing ::one, Thing ::two)
428
428
.containsExactly(" one" to 2 , " two" to 1 )
429
429
}
@@ -432,51 +432,51 @@ class IterableTest {
432
432
| at index:0 expected:<("one", 2)>
433
433
| at index:0 unexpected:<("one", 1)>
434
434
| 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(),
436
436
error.message
437
437
)
438
438
}
439
439
440
440
@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 >)
442
442
.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' ) ))
444
444
}
445
445
446
446
@Test fun triple_extracting_function_fails () {
447
447
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 >)
449
449
.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' ) ))
451
451
}
452
452
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(),
458
458
error.message
459
459
)
460
460
}
461
461
// region extracting
462
462
463
463
// region flatExtracting
464
464
@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 ' )
467
467
}
468
468
469
469
@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 ' ))
471
471
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 ' )
473
473
}
474
474
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
480
480
)
481
481
}
482
482
// region flatExtracting
@@ -528,5 +528,5 @@ class IterableTest {
528
528
}
529
529
// endregion
530
530
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 > )
532
532
}
0 commit comments