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 1889b43..d9f2116 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt @@ -26,7 +26,6 @@ package org.mockito.kotlin import org.mockito.AdditionalMatchers import org.mockito.kotlin.internal.createInstance -import kotlin.reflect.KClass /** comparable argument greater than or equal the given value. */ inline fun > geq(value: T): T { @@ -144,19 +143,3 @@ inline fun or(left: T, right: T): T { inline fun not(matcher: T): T { return AdditionalMatchers.not(matcher) ?: createInstance() } - -/** - * float argument that has an absolute difference to the given value that is - * less than the given delta details. - */ -fun eq(value: Double, delta: Double): Double { - return AdditionalMatchers.eq(value, delta) ?: 0.0 -} - -/** - * double argument that has an absolute difference to the given value that - * is less than the given delta details. - */ -fun eq(value: Float, delta: Float): Float { - 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 4036f7c..bb6f5ed 100644 --- a/tests/src/test/kotlin/test/AdditionalMatchersTest.kt +++ b/tests/src/test/kotlin/test/AdditionalMatchersTest.kt @@ -53,7 +53,34 @@ class AdditionalCaptorsTest : TestBase() { } @Test - fun testAryEqPrimitive() { + fun testAryEqBoolean() { + mock().apply { + booleanArray(booleanArrayOf(true, false, true)) + verify(this).booleanArray(aryEq(booleanArrayOf(true, false, true))) + verify(this, never()).booleanArray(aryEq(booleanArrayOf(true, false))) + } + } + + @Test + fun testAryEqByte() { + mock().apply { + byteArray(byteArrayOf(1, 2, 3)) + verify(this).byteArray(aryEq(byteArrayOf(1, 2, 3))) + verify(this, never()).byteArray(aryEq(byteArrayOf(1, 2))) + } + } + + @Test + fun testAryEqShort() { + mock().apply { + shortArray(shortArrayOf(1, 2, 3)) + verify(this).shortArray(aryEq(shortArrayOf(1, 2, 3))) + verify(this, never()).shortArray(aryEq(shortArrayOf(1, 2))) + } + } + + @Test + fun testAryEqInt() { mock().apply { intArray(intArrayOf(1, 2, 3)) verify(this).intArray(aryEq(intArrayOf(1, 2, 3))) @@ -61,6 +88,42 @@ class AdditionalCaptorsTest : TestBase() { } } + @Test + fun testAryEqLong() { + mock().apply { + longArray(longArrayOf(1, 2, 3)) + verify(this).longArray(aryEq(longArrayOf(1, 2, 3))) + verify(this, never()).longArray(aryEq(longArrayOf(1, 2))) + } + } + + @Test + fun testAryEqChar() { + mock().apply { + charArray(charArrayOf('1', '2', '3')) + verify(this).charArray(aryEq(charArrayOf('1', '2', '3'))) + verify(this, never()).charArray(aryEq(charArrayOf('1', '2'))) + } + } + + @Test + fun testAryEqFloat() { + mock().apply { + floatArray(floatArrayOf(1f, 2f, 3.4f)) + verify(this).floatArray(aryEq(floatArrayOf(1f, 2f, 3.4f))) + verify(this, never()).floatArray(aryEq(floatArrayOf(1f, 2f))) + } + } + + @Test + fun testAryEqDouble() { + mock().apply { + doubleArray(doubleArrayOf(1.0, 2.0, 3.4)) + verify(this).doubleArray(aryEq(doubleArrayOf(1.0, 2.0, 3.4))) + verify(this, never()).doubleArray(aryEq(doubleArrayOf(1.0, 2.0))) + } + } + @Test fun testAryEq() { mock().apply { @@ -71,7 +134,7 @@ class AdditionalCaptorsTest : TestBase() { } @Test - fun testfind() { + fun testFind() { mock().apply { string("Hello") verify(this).string(find("l+o$".toRegex())) diff --git a/tests/src/test/kotlin/test/Classes.kt b/tests/src/test/kotlin/test/Classes.kt index c084b62..4d2f26e 100644 --- a/tests/src/test/kotlin/test/Classes.kt +++ b/tests/src/test/kotlin/test/Classes.kt @@ -44,7 +44,6 @@ class Closed interface Methods { - fun intArray(i: IntArray) fun closed(c: Closed) fun closedArray(a: Array) fun closedNullableArray(a: Array) @@ -54,13 +53,21 @@ interface Methods { fun closedSet(s: Set) fun string(s: String) fun boolean(b: Boolean) + fun booleanArray(d: BooleanArray) fun byte(b: Byte) + fun byteArray(b: ByteArray) fun char(c: Char) + fun charArray(c: CharArray) fun short(s: Short) + fun shortArray(s: ShortArray) fun int(i: Int) + fun intArray(i: IntArray) fun long(l: Long) + fun longArray(l: LongArray) fun float(f: Float) + fun floatArray(f: FloatArray) fun double(d: Double) + fun doubleArray(d: DoubleArray) fun closedVararg(vararg c: Closed) fun throwableClass(t: ThrowableClass) fun nullableString(s: String?)