Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Created April 25, 2018 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamMc331/ce6b13caffab4995ff93d74d430f38ac to your computer and use it in GitHub Desktop.
Save AdamMc331/ce6b13caffab4995ff93d74d430f38ac to your computer and use it in GitHub Desktop.
class TestAssertion<T>(private val actual: T) {
fun matches(expected: T) {
assertEquals(expected, actual)
}
}
inline fun <reified T> assert(actual: T): TestAssertion<T> {
return TestAssertion(actual)
}
@Test
fun testEquals() {
val myList: List<Any> = listOf(3, "Adam", true)
assert(myList[0]).matches(3)
assert(myList[1]).matches("Adam")
assert(myList[2]).matches(true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment