Skip to content

Commit 758e3fa

Browse files
committed
Fix compilation errors
1 parent 008a92b commit 758e3fa

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/AdditionalMatchers.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ inline fun <reified T : Comparable<T>> cmpEq(value: T): T {
5555

5656
/**
5757
* Any array argument that is equal to the given array, i.e. it has to have the same type, length,
58-
* and each element has to be equal. </T>
58+
* and each element has to be equal.
5959
*/
60-
fun <T> aryEq(value: Array<T>?): Array<T> {
60+
inline fun <reified T> aryEq(value: Array<T>): Array<T> {
6161
return AdditionalMatchers.aryEq(value) ?: createInstance()
6262
}
6363

@@ -127,7 +127,7 @@ fun aryEq(value: BooleanArray): BooleanArray {
127127

128128
/** String argument that contains a substring that matches the given regular expression. */
129129
fun find(regex: Regex): String {
130-
return AdditionalMatchers.find(regex.pattern) ?: createInstance()
130+
return AdditionalMatchers.find(regex.pattern) ?: ""
131131
}
132132

133133
/** argument that matches both given argument matchers. */
@@ -150,13 +150,13 @@ inline fun <reified T : Any> not(matcher: T): T {
150150
* less than the given delta details.
151151
*/
152152
fun eq(value: Double, delta: Double): Double {
153-
return AdditionalMatchers.eq(value, delta)
153+
return AdditionalMatchers.eq(value, delta) ?: 0.0
154154
}
155155

156156
/**
157157
* double argument that has an absolute difference to the given value that
158158
* is less than the given delta details.
159159
*/
160160
fun eq(value: Float, delta: Float): Float {
161-
return AdditionalMatchers.eq(value, delta)
161+
return AdditionalMatchers.eq(value, delta) ?: 0.0f
162162
}

tests/src/test/kotlin/test/AdditionalMatchersTest.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package test
33
import org.junit.Test
44
import org.mockito.kotlin.*
55

6-
class ArgumentCaptorTest : TestBase() {
6+
class AdditionalCaptorsTest : TestBase() {
77

88
@Test
99
fun testGeq() {
@@ -44,11 +44,11 @@ class ArgumentCaptorTest : TestBase() {
4444
}
4545

4646
@Test
47-
fun testCmp() {
47+
fun testCmpEq() {
4848
mock<Methods>().apply {
4949
int(1)
50-
verify(this).int(cmp(1))
51-
verify(this, never()).int(cmp(2))
50+
verify(this).int(cmpEq(1))
51+
verify(this, never()).int(cmpEq(2))
5252
}
5353
}
5454

@@ -62,7 +62,7 @@ class ArgumentCaptorTest : TestBase() {
6262
}
6363

6464
@Test
65-
fun testAryEqPrimitive() {
65+
fun testAryEq() {
6666
mock<Methods>().apply {
6767
stringArray(arrayOf("Hello", "there"))
6868
verify(this).stringArray(aryEq(arrayOf("Hello", "there")))
@@ -74,8 +74,8 @@ class ArgumentCaptorTest : TestBase() {
7474
fun testfind() {
7575
mock<Methods>().apply {
7676
string("Hello")
77-
verify(this).string(find("l+o$".toRegex())
78-
verify(this, never()).string(find("l$".toRegex())
77+
verify(this).string(find("l+o$".toRegex()))
78+
verify(this, never()).string(find("l$".toRegex()))
7979
}
8080
}
8181

@@ -92,8 +92,8 @@ class ArgumentCaptorTest : TestBase() {
9292
fun testOr() {
9393
mock<Methods>().apply {
9494
int(5)
95-
verify(this).int(and(lt(4), gt(4)))
96-
verify(this, never()).int(and(lt(5), (5)))
95+
verify(this).int(and(gt(4), lt(6)))
96+
verify(this, never()).int(and(gt(4), lt(4)))
9797
}
9898
}
9999

0 commit comments

Comments
 (0)