mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Validate several ids in constructors (#336)
* Validate ids in constructors. * Remove redundant `.value` usage in string interpolation. * Make a distinction between `SessionId` and `UserId` in `TestData`.
This commit is contained in:
committed by
GitHub
parent
638b45930e
commit
fae3417181
+3
-4
@@ -16,18 +16,17 @@
|
||||
|
||||
package io.element.android.tests.testutils
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Assert.assertThrows
|
||||
|
||||
/**
|
||||
* Assert that the lambda throws on debug and returns null on release.
|
||||
* Assert that the lambda throws only on debug mode.
|
||||
*/
|
||||
fun assertNullOrThrow(lambda: () -> Any?) {
|
||||
fun assertThrowsInDebug(lambda: () -> Any?) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
assertThrows(IllegalStateException::class.java) {
|
||||
lambda()
|
||||
}
|
||||
} else {
|
||||
assertThat(lambda()).isNull()
|
||||
lambda()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user