File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2
tests/src/test/kotlin/test Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ fun <T : Any> notNull(): T? {
133
133
* Object argument that is reflection-equal to the given value with support for excluding
134
134
* selected fields from a class.
135
135
*/
136
- fun <T > refEq (value : T , vararg excludeFields : String ): T ? {
137
- return Mockito .refEq(value, * excludeFields)
136
+ inline fun <reified T : Any > refEq (value : T , vararg excludeFields : String ): T {
137
+ return Mockito .refEq< T > (value, * excludeFields) ? : createInstance( )
138
138
}
139
139
Original file line number Diff line number Diff line change @@ -228,6 +228,19 @@ class MatchersTest : TestBase() {
228
228
expect(t.varargBooleanResult(" a" , " b" , " c" )).toBe(false )
229
229
}
230
230
231
+ /* * https://github.com/nhaarman/mockito-kotlin/issues/328 */
232
+ @Test
233
+ fun testRefEqForNonNullableParameter () {
234
+ mock<Methods >().apply {
235
+ /* When */
236
+ val array = intArrayOf(2 , 3 )
237
+ intArray(array)
238
+
239
+ /* Then */
240
+ verify(this ).intArray(refEq(array))
241
+ }
242
+ }
243
+
231
244
/* *
232
245
* a VarargMatcher implementation for varargs of type [T] that will answer with type [R] if any of the var args
233
246
* matched. Needs to keep state between matching invocations.
You can’t perform that action at this time.
0 commit comments