mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 22:17:03 +05:30
fix(api): add test util for type assertion
This commit is contained in:
parent
5c8057d71f
commit
5d2eebf093
1 changed files with 10 additions and 0 deletions
|
@ -6,8 +6,12 @@
|
||||||
*/
|
*/
|
||||||
package dev.msfjarvis.claw.util
|
package dev.msfjarvis.claw.util
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import kotlin.contracts.ExperimentalContracts
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
|
@OptIn(ExperimentalContracts::class)
|
||||||
object TestUtils {
|
object TestUtils {
|
||||||
fun getJson(path: String): String {
|
fun getJson(path: String): String {
|
||||||
// Load the JSON response
|
// Load the JSON response
|
||||||
|
@ -15,4 +19,10 @@ object TestUtils {
|
||||||
val file = File(uri.path)
|
val file = File(uri.path)
|
||||||
return String(file.readBytes())
|
return String(file.readBytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> assertIs(value: Any?): T {
|
||||||
|
contract { returns() implies (value is T) }
|
||||||
|
assertThat(value).isInstanceOf(T::class.java)
|
||||||
|
return value as T
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue