diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt index 807ba08..1889b43 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt @@ -55,9 +55,9 @@ inline fun > cmpEq(value: T): T { /** * Any array argument that is equal to the given array, i.e. it has to have the same type, length, - * and each element has to be equal. + * and each element has to be equal. */ -fun aryEq(value: Array?): Array { +inline fun aryEq(value: Array): Array { return AdditionalMatchers.aryEq(value) ?: createInstance() } @@ -127,7 +127,7 @@ fun aryEq(value: BooleanArray): BooleanArray { /** String argument that contains a substring that matches the given regular expression. */ fun find(regex: Regex): String { - return AdditionalMatchers.find(regex.pattern) ?: createInstance() + return AdditionalMatchers.find(regex.pattern) ?: "" } /** argument that matches both given argument matchers. */ @@ -150,7 +150,7 @@ inline fun not(matcher: T): T { * less than the given delta details. */ fun eq(value: Double, delta: Double): Double { - return AdditionalMatchers.eq(value, delta) + return AdditionalMatchers.eq(value, delta) ?: 0.0 } /** @@ -158,5 +158,5 @@ fun eq(value: Double, delta: Double): Double { * is less than the given delta details. */ fun eq(value: Float, delta: Float): Float { - return AdditionalMatchers.eq(value, delta) + return AdditionalMatchers.eq(value, delta) ?: 0.0f } diff --git a/tests/src/test/kotlin/test/AdditionalMatchersTest.kt b/tests/src/test/kotlin/test/AdditionalMatchersTest.kt index 2cf1197..4036f7c 100644 --- a/tests/src/test/kotlin/test/AdditionalMatchersTest.kt +++ b/tests/src/test/kotlin/test/AdditionalMatchersTest.kt @@ -3,7 +3,7 @@ package test import org.junit.Test import org.mockito.kotlin.* -class ArgumentCaptorTest : TestBase() { +class AdditionalCaptorsTest : TestBase() { @Test fun testGeq() { @@ -44,11 +44,11 @@ class ArgumentCaptorTest : TestBase() { } @Test - fun testCmp() { + fun testCmpEq() { mock().apply { int(1) - verify(this).int(cmp(1)) - verify(this, never()).int(cmp(2)) + verify(this).int(cmpEq(1)) + verify(this, never()).int(cmpEq(2)) } } @@ -62,7 +62,7 @@ class ArgumentCaptorTest : TestBase() { } @Test - fun testAryEqPrimitive() { + fun testAryEq() { mock().apply { stringArray(arrayOf("Hello", "there")) verify(this).stringArray(aryEq(arrayOf("Hello", "there"))) @@ -74,8 +74,8 @@ class ArgumentCaptorTest : TestBase() { fun testfind() { mock().apply { string("Hello") - verify(this).string(find("l+o$".toRegex()) - verify(this, never()).string(find("l$".toRegex()) + verify(this).string(find("l+o$".toRegex())) + verify(this, never()).string(find("l$".toRegex())) } } @@ -92,8 +92,8 @@ class ArgumentCaptorTest : TestBase() { fun testOr() { mock().apply { int(5) - verify(this).int(and(lt(4), gt(4))) - verify(this, never()).int(and(lt(5), (5))) + verify(this).int(and(gt(4), lt(6))) + verify(this, never()).int(and(gt(4), lt(4))) } }