summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChalard Jean <jchalard@google.com>2019-07-10 20:04:18 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-07-10 20:04:18 -0700
commite8c3868f2131890f35cc0dc89f37946c14b05eb9 (patch)
tree520f112b0fa7ca3f4271bf5d78c27a004634f70a
parenta9e127574185d8c033c64fdf0b250d0660ce4b3f (diff)
parenteb297bcd09ec73b5cb2f426d62f3a3c15cf312cb (diff)
Add a message-taking assertThrows am: 77c5dabb65
am: eb297bcd09 Change-Id: I4c673a20a18ccd506001fda3e32ca23cef7b68ff
-rw-r--r--tests/lib/src/com/android/testutils/MiscAsserts.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/lib/src/com/android/testutils/MiscAsserts.kt b/tests/lib/src/com/android/testutils/MiscAsserts.kt
index 63aedd6..5019dcd 100644
--- a/tests/lib/src/com/android/testutils/MiscAsserts.kt
+++ b/tests/lib/src/com/android/testutils/MiscAsserts.kt
@@ -17,6 +17,7 @@
package com.android.testutils
import android.util.Log
+import com.android.testutils.ExceptionUtils.ThrowingRunnable
import java.lang.reflect.Modifier
import kotlin.system.measureTimeMillis
import kotlin.test.assertEquals
@@ -36,10 +37,14 @@ fun <T> assertLength(expected: Int, got: Array<T>) = got.size.let { len ->
// Bridge method to help write this in Java. If you're writing Kotlin, consider using native
// kotlin.test.assertFailsWith instead, as that method is reified and inlined.
-fun <T : Exception> assertThrows(expected: Class<T>, block: ExceptionUtils.ThrowingRunnable): T {
+fun <T : Exception> assertThrows(expected: Class<T>, block: ThrowingRunnable): T {
return assertFailsWith(expected.kotlin) { block.run() }
}
+fun <T : Exception> assertThrows(msg: String, expected: Class<T>, block: ThrowingRunnable): T {
+ return assertFailsWith(expected.kotlin, msg) { block.run() }
+}
+
fun <T> assertEqualBothWays(o1: T, o2: T) {
assertTrue(o1 == o2)
assertTrue(o2 == o1)