backend/testUtils: add assertTrue and assertFalse

This commit is contained in:
Svyatoslav Scherbina
2017-03-10 12:16:17 +07:00
committed by SvyatoslavScherbina
parent bbcbd03941
commit 9e15873d6c
+13 -1
View File
@@ -2,4 +2,16 @@ package kotlin.test
class TestFailedException(val msg:String):RuntimeException(msg)
fun <T> assertEquals(a:T, b:T, msg:String = "") { if (a != b) throw TestFailedException(msg) }
fun <T> assertEquals(a:T, b:T, msg:String = "") { if (a != b) throw TestFailedException(msg) }
/** Asserts that the expression is `true` with an optional [message]. */
fun assertTrue(actual: Boolean, message: String? = null) {
if (actual != true) {
throw TestFailedException(message ?: "Expected value to be true.")
}
}
/** Asserts that the expression is `false` with an optional [message]. */
fun assertFalse(actual: Boolean, message: String? = null) {
assertTrue(!actual, message ?: "Expected value to be false.")
}