robstoll
10/24/2020, 4:23 PMjdornieden
10/25/2020, 11:43 AM_expect_("calling myNullableFun with ...") *{*
* *_mapOf_(
Int.MIN_VALUE _to expectLambda_<String> *{* _contains_("min") *}*,
-1 _to expectLambda_ *{* toBeNull() *}*,
0 _to expectLambda_ *{* toBeNull() *}*,
1 _to expectLambda_ *{* _toBe_("1") *}*,
2 _to expectLambda_ *{* _endsWith_("2") *}*,
Int.MAX_VALUE _to expectLambda_ *{* _toBe_("max") *}*
* *)._forEach_ *{* (arg, assertionCreatorOrNull) *->*
* *_feature_ *{* f(::myNullableFun, arg) *}*
}
}
robstoll
10/25/2020, 12:43 PMtoBe(null)
How are you going to use the assertionCreatorOrNull in your example, you missed to show it?
Actually, expectLambda
should already accept T
without any upper bound which is the same as T: Any?
If that's not the case, then we should fix itjdornieden
10/25/2020, 1:07 PMexpect("calling myNullableFun with ...") {
mapOf(
Int.MIN_VALUE to expectLambda<String> { contains("min") },
-1 to expectLambda { toBeNull() },
0 to expectLambda { toBeNull() },
1 to expectLambda { toBe("1") },
2 to expectLambda { endsWith("2") },
Int.MAX_VALUE to expectLambda { toBe("max") }
).forEach { (arg, assertionCreator) ->
feature( { f(::myNullableFun, arg) }, assertionCreator)
}
}
Basically I wondered if it is necessary to have a special treatment for null or if it was possible to combine the two Data Driven Testing examples (Readme) into one simpler example.robstoll
10/25/2020, 1:16 PMT
means T: Any?
, you should be able to write:
expectLambda<Int?> { toBe(null) }
No?jdornieden
10/25/2020, 1:48 PMexpect("calling myNullableFun with ...") {
mapOf(
Int.MIN_VALUE to expectLambda<String?> { notToBeNull().contains("min") },
-1 to expectLambda { toBe(null) },
0 to expectLambda { toBe(null) },
1 to expectLambda { toBe("1") },
2 to expectLambda { notToBeNull().endsWith("2") },
Int.MAX_VALUE to expectLambda { toBe("max") }
).forEach { (arg, assertionCreator) ->
feature( { f(::myNullableFun, arg) }, assertionCreator)
}
}