Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulferaud committed Jan 16, 2024
1 parent 008a92b commit 758e3fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Expand Up @@ -55,9 +55,9 @@ inline fun <reified T : Comparable<T>> 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. </T>
* and each element has to be equal.
*/
fun <T> aryEq(value: Array<T>?): Array<T> {
inline fun <reified T> aryEq(value: Array<T>): Array<T> {
return AdditionalMatchers.aryEq(value) ?: createInstance()
}

Expand Down Expand Up @@ -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. */
Expand All @@ -150,13 +150,13 @@ inline fun <reified T : Any> 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
}

/**
* 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)
return AdditionalMatchers.eq(value, delta) ?: 0.0f
}
18 changes: 9 additions & 9 deletions tests/src/test/kotlin/test/AdditionalMatchersTest.kt
Expand Up @@ -3,7 +3,7 @@ package test
import org.junit.Test
import org.mockito.kotlin.*

class ArgumentCaptorTest : TestBase() {
class AdditionalCaptorsTest : TestBase() {

@Test
fun testGeq() {
Expand Down Expand Up @@ -44,11 +44,11 @@ class ArgumentCaptorTest : TestBase() {
}

@Test
fun testCmp() {
fun testCmpEq() {
mock<Methods>().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))
}
}

Expand All @@ -62,7 +62,7 @@ class ArgumentCaptorTest : TestBase() {
}

@Test
fun testAryEqPrimitive() {
fun testAryEq() {
mock<Methods>().apply {
stringArray(arrayOf("Hello", "there"))
verify(this).stringArray(aryEq(arrayOf("Hello", "there")))
Expand All @@ -74,8 +74,8 @@ class ArgumentCaptorTest : TestBase() {
fun testfind() {
mock<Methods>().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()))
}
}

Expand All @@ -92,8 +92,8 @@ class ArgumentCaptorTest : TestBase() {
fun testOr() {
mock<Methods>().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)))
}
}

Expand Down

0 comments on commit 758e3fa

Please sign in to comment.