File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2 Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 26
26
package com.nhaarman.mockitokotlin2
27
27
28
28
import com.nhaarman.mockitokotlin2.internal.createInstance
29
+ import org.mockito.ArgumentMatcher
29
30
import org.mockito.Mockito
30
31
31
32
/* * Object argument that is equal to the given value. */
@@ -70,6 +71,16 @@ inline fun <reified T : Any> argThat(noinline predicate: T.() -> Boolean): T {
70
71
)
71
72
}
72
73
74
+ /* *
75
+ * Registers a custom ArgumentMatcher. The original Mockito function registers the matcher and returns null,
76
+ * here the required type is returned.
77
+ *
78
+ * @param matcher The ArgumentMatcher on [T] to be registered.
79
+ */
80
+ inline fun <reified T : Any > argThat (matcher : ArgumentMatcher <T >): T {
81
+ return Mockito .argThat(matcher) ? : createInstance()
82
+ }
83
+
73
84
/* *
74
85
* Alias for [argThat].
75
86
*
You can’t perform that action at this time.
0 commit comments