15
15
*/
16
16
package com.google.firebase.dataconnect
17
17
18
+ import com.google.firebase.dataconnect.SerializationTestData.serializationTestDataAllTypes
19
+ import com.google.firebase.dataconnect.SerializationTestData.withEmptyListOfUnitRecursive
18
20
import com.google.firebase.dataconnect.testutil.shouldContainWithNonAbuttingTextIgnoringCase
19
21
import com.google.firebase.dataconnect.util.ProtoUtil.buildStructProto
20
22
import com.google.firebase.dataconnect.util.ProtoUtil.decodeFromStruct
@@ -31,9 +33,9 @@ import io.kotest.property.arbitrary.arbitrary
31
33
import io.kotest.property.arbitrary.boolean
32
34
import io.kotest.property.arbitrary.constant
33
35
import io.kotest.property.arbitrary.double
34
- import io.kotest.property.arbitrary.filter
35
36
import io.kotest.property.arbitrary.int
36
37
import io.kotest.property.arbitrary.list
38
+ import io.kotest.property.arbitrary.map
37
39
import io.kotest.property.arbitrary.orNull
38
40
import io.kotest.property.arbitrary.string
39
41
import io.kotest.property.checkAll
@@ -47,17 +49,21 @@ class ProtoStructDecoderUnitTest {
47
49
48
50
@Test
49
51
fun `decodeFromStruct() can encode and decode complex objects` () = runTest {
50
- val seeds = Arb .string().filter { it.hashCode() != 0 }
51
- checkAll(iterations = 20 , seeds) { seed ->
52
- val obj = SerializationTestData .AllTheTypes .newInstance(seed).withEmptyUnitLists()
52
+ // TODO(b/370992204) Remove the call to withEmptyListOfUnitRecursive() once the bug that a list
53
+ // of Unit is incorrectly decoded as an empty list is fixed.
54
+ val arb = Arb .serializationTestDataAllTypes().map { it.withEmptyListOfUnitRecursive() }
55
+ checkAll(iterations = 20 , arb) { obj ->
53
56
val struct = encodeToStruct(obj)
54
57
val decodedObj = decodeFromStruct<SerializationTestData .AllTheTypes >(struct)
55
58
decodedObj shouldBe obj
56
59
}
57
60
}
58
61
62
+ @Ignore(
63
+ " b/370992204: Re-enable this test once the bug that a list of Unit is incorrectly " +
64
+ " decoded as an empty list is fixed"
65
+ )
59
66
@Test
60
- @Ignore(" A List<Unit> gets decoded as an empty list; if anyone cares, fix it." )
61
67
fun `decodeFromStruct() can encode and decode a list of non-nullable Unit` () = runTest {
62
68
@Serializable data class TestData (val list : List <Unit >)
63
69
checkAll(Arb .list(Arb .constant(Unit ))) { list ->
0 commit comments