@@ -23,14 +23,15 @@ import com.google.protobuf.Struct
23
23
import com.google.protobuf.Value
24
24
import com.google.protobuf.Value.KindCase
25
25
import io.kotest.assertions.assertSoftly
26
+ import io.kotest.assertions.throwables.shouldThrow
26
27
import io.kotest.matchers.shouldBe
27
28
import io.kotest.matchers.types.shouldBeSameInstanceAs
28
29
import io.kotest.property.Arb
29
30
import io.kotest.property.arbitrary.arbitrary
30
31
import io.kotest.property.arbitrary.boolean
31
32
import io.kotest.property.arbitrary.constant
32
33
import io.kotest.property.arbitrary.double
33
- import io.kotest.property.arbitrary.filterNot
34
+ import io.kotest.property.arbitrary.filter
34
35
import io.kotest.property.arbitrary.int
35
36
import io.kotest.property.arbitrary.list
36
37
import io.kotest.property.arbitrary.orNull
@@ -39,15 +40,15 @@ import io.kotest.property.checkAll
39
40
import kotlinx.coroutines.test.runTest
40
41
import kotlinx.serialization.Serializable
41
42
import kotlinx.serialization.SerializationException
42
- import org.junit.Assert.assertThrows
43
43
import org.junit.Ignore
44
44
import org.junit.Test
45
45
46
46
class ProtoStructDecoderUnitTest {
47
47
48
48
@Test
49
49
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 ->
51
52
val obj = SerializationTestData .AllTheTypes .newInstance(seed).withEmptyUnitLists()
52
53
val struct = encodeToStruct(obj)
53
54
val decodedObj = decodeFromStruct<SerializationTestData .AllTheTypes >(struct)
@@ -653,7 +654,7 @@ private inline fun <reified T> assertDecodeFromStructThrowsIncorrectKindCase(
653
654
struct : Struct = Struct .getDefaultInstance(),
654
655
path : String? = null
655
656
) {
656
- val exception = assertThrows( SerializationException :: class .java) { decodeFromStruct<T >(struct) }
657
+ val exception = shouldThrow< SerializationException > { decodeFromStruct<T >(struct) }
657
658
// The error message is expected to look something like this:
658
659
// "expected NUMBER_VALUE, but got STRUCT_VALUE"
659
660
assertSoftly {
0 commit comments