Skip to content

Commit

Permalink
(WIP) add validation test
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Feb 21, 2021
1 parent 65953a7 commit 84392b6
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ object KotlinWhenExpressionTarget {
else -> 5 // assertFullyCovered()
} // assertFullyCovered()

/**
* Unlike [whenString]
* in this example first case is the only case with biggest hashCode value.
*/
private fun whenStringBiggestHashCodeFirst(p: String): Int = when (p) { // assertFullyCovered(0, 4)
"b" -> 1 // assertFullyCovered()
"a" -> 2 // assertFullyCovered()
"\u0000a" -> 3 // assertFullyCovered()
else -> 4 // assertFullyCovered()
} // assertFullyCovered()

@JvmStatic
fun main(args: Array<String>) {
whenSealed(Sealed.Sealed1)
Expand All @@ -77,6 +88,11 @@ object KotlinWhenExpressionTarget {
whenString("b")
whenString("\u0000a")
whenString("\u0000b")

whenStringBiggestHashCodeFirst("")
whenStringBiggestHashCodeFirst("a")
whenStringBiggestHashCodeFirst("b")
whenStringBiggestHashCodeFirst("\u0000a")
}

}

0 comments on commit 84392b6

Please sign in to comment.