Skip to content

Commit 7c1c1ee

Browse files
committed
ProtoStructDecoderUnitTest.kt: assertThrows -> shouldThrow
1 parent 712db3a commit 7c1c1ee

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/ProtoStructDecoderUnitTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import com.google.protobuf.Struct
2323
import com.google.protobuf.Value
2424
import com.google.protobuf.Value.KindCase
2525
import io.kotest.assertions.assertSoftly
26+
import io.kotest.assertions.throwables.shouldThrow
2627
import io.kotest.matchers.shouldBe
2728
import io.kotest.matchers.types.shouldBeSameInstanceAs
2829
import io.kotest.property.Arb
2930
import io.kotest.property.arbitrary.arbitrary
3031
import io.kotest.property.arbitrary.boolean
3132
import io.kotest.property.arbitrary.constant
3233
import io.kotest.property.arbitrary.double
33-
import io.kotest.property.arbitrary.filterNot
34+
import io.kotest.property.arbitrary.filter
3435
import io.kotest.property.arbitrary.int
3536
import io.kotest.property.arbitrary.list
3637
import io.kotest.property.arbitrary.orNull
@@ -39,15 +40,15 @@ import io.kotest.property.checkAll
3940
import kotlinx.coroutines.test.runTest
4041
import kotlinx.serialization.Serializable
4142
import kotlinx.serialization.SerializationException
42-
import org.junit.Assert.assertThrows
4343
import org.junit.Ignore
4444
import org.junit.Test
4545

4646
class ProtoStructDecoderUnitTest {
4747

4848
@Test
4949
fun `decodeFromStruct() can encode and decode complex objects`() = runTest {
50-
checkAll(iterations = 20, Arb.string().filterNot { it.hashCode() == 0 }) { seed ->
50+
val seeds = Arb.string().filter { it.hashCode() != 0 }
51+
checkAll(iterations = 20, seeds) { seed ->
5152
val obj = SerializationTestData.AllTheTypes.newInstance(seed).withEmptyUnitLists()
5253
val struct = encodeToStruct(obj)
5354
val decodedObj = decodeFromStruct<SerializationTestData.AllTheTypes>(struct)
@@ -653,7 +654,7 @@ private inline fun <reified T> assertDecodeFromStructThrowsIncorrectKindCase(
653654
struct: Struct = Struct.getDefaultInstance(),
654655
path: String? = null
655656
) {
656-
val exception = assertThrows(SerializationException::class.java) { decodeFromStruct<T>(struct) }
657+
val exception = shouldThrow<SerializationException> { decodeFromStruct<T>(struct) }
657658
// The error message is expected to look something like this:
658659
// "expected NUMBER_VALUE, but got STRUCT_VALUE"
659660
assertSoftly {

0 commit comments

Comments
 (0)