zmunm
10/08/2020, 7:12 AMclass Test {
interface Example {
operator fun <T> get(key: String, defaultValue: T): T
}
class ExampleImpl : Example {
override fun <T> get(key: String, defaultValue: T): T = when (defaultValue) {
is Int -> defaultValue
else -> // Debug here is recognized as'Long' on `exampleError`
throw UnsupportedOperationException("NOT_YET_IMPLEMENT")
}
}
// exception occurs only in 1.4
@Test(expected = UnsupportedOperationException::class)
fun exampleError() {
val example: Example = ExampleImpl()
org.junit.Assert.assertEquals(example["key", 1], 1)
}
// Success
@Test
fun exampleSuccess() {
val example: Example = ExampleImpl()
junit.framework.TestCase.assertEquals(example["key", 1], 1)
}
}
I think this is the cause
TestCase.assertEquals
public static void assertEquals(int expected, int actual)
Assert.assertEquals
public static void assertEquals(Object expected, Object actual) // There is no part defined as int type
Is there anyone who can help?zmunm
10/08/2020, 7:26 AM