Commit 88b3420 1 parent c1ab1e8 commit 88b3420 Copy full SHA for 88b3420
File tree 3 files changed +15
-0
lines changed
commonMain/kotlin/dev/mokkery/test
commonTest/kotlin/dev/mokkery/test
3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ interface TestInterface : BaseInterface {
4
4
5
5
var property: String
6
6
7
+ fun callWithString (value : String? ): Int
8
+
7
9
fun callWithPrimitives (i : Int , j : Int = 1): Double
8
10
9
11
fun callWithComplex (list : List <String >): List <Int >
Original file line number Diff line number Diff line change @@ -24,9 +24,11 @@ import dev.mokkery.matcher.lte
24
24
import dev.mokkery.matcher.neq
25
25
import dev.mokkery.matcher.neqRef
26
26
import dev.mokkery.matcher.ofType
27
+ import dev.mokkery.matcher.matchingBy
27
28
import dev.mokkery.matcher.varargs.anyVarargs
28
29
import dev.mokkery.matcher.varargs.varargsAll
29
30
import dev.mokkery.matcher.varargs.varargsAny
31
+ import dev.mokkery.matcher.nullable.notNull
30
32
import dev.mokkery.mock
31
33
import kotlin.test.Test
32
34
import kotlin.test.assertContentEquals
@@ -347,5 +349,15 @@ class ArgMatchersTest {
347
349
mock.callWithPrimitives(3 )
348
350
assertEquals(listOf (1 , 3 ), called)
349
351
}
352
+
353
+ @Test
354
+ fun testNotNullMatcherAllowsUsingNotNullableMatchers () {
355
+ every { mock.callWithString(any()) } returns 1
356
+ every { mock.callWithString(notNull()) } returns 2
357
+ every { mock.callWithString(notNull(matchingBy(CharSequence ::isNotEmpty))) } returns 3
358
+ assertEquals(1 , mock.callWithString(null ))
359
+ assertEquals(2 , mock.callWithString(" " ))
360
+ assertEquals(3 , mock.callWithString(" Aaaaaaa" ))
361
+ }
350
362
}
351
363
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ class SpyTest {
92
92
private object TestInterfaceImpl : TestInterface {
93
93
94
94
override var property: String = " 1"
95
+ override fun callWithString (value : String? ): Int = 0
95
96
96
97
override fun callWithPrimitives (i : Int , j : Int ): Double = i.toDouble()
97
98
You can’t perform that action at this time.
0 commit comments