Skip to content

Commit

Permalink
Test for assertInstanceOf nullable upcast
Browse files Browse the repository at this point in the history
  • Loading branch information
awelless committed Aug 27, 2023
1 parent 437d29e commit 43c08ea
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ class KotlinAssertionsTests {
assertFalse(string.isEmpty()) // smart cast to a String object
}

@Test
fun `assertInstanceOf with compiler nullable smart cast`() {
val string: Any? = "string"

assertInstanceOf<String>(string)
assertFalse(string.isEmpty()) // smart cast to a non-null String object
}

@Test
fun `assertInstanceOf with a null value`() {
val error = assertThrows<AssertionFailedError> {
Expand Down

0 comments on commit 43c08ea

Please sign in to comment.