assertk icon indicating copy to clipboard operation
assertk copied to clipboard

Long isEqualTo Int with equal value fails assertion

Open NavorJames opened this issue 11 months ago • 0 comments

I just swapped Google Truth with AssertK and found that equal assertion fails for Long/? and Int. Using equality operator in Kotlin also returns the error Operator '==' cannot be applied to 'Long?' and 'Int'. However, this succeeds with Google Truth and I think it's reasonable since they have equal values.

@Test
fun nullableLongToIntEqualityCheckIsTrue(){
    val actual: Long? = 2 + 2
    val expected: Int = 4
    assertThat(actual).isEqualTo(expected)
}

NavorJames avatar Jan 31 '25 07:01 NavorJames