@@ -19,6 +19,8 @@ package com.google.firebase.dataconnect
19
19
20
20
import com.google.firebase.dataconnect.SerializationTestData.serializationTestDataAllTypes
21
21
import com.google.firebase.dataconnect.SerializationTestData.withEmptyListOfUnitRecursive
22
+ import com.google.firebase.dataconnect.testutil.property.arbitrary.dataConnect
23
+ import com.google.firebase.dataconnect.testutil.property.arbitrary.twoValues
22
24
import com.google.firebase.dataconnect.testutil.shouldContainWithNonAbuttingTextIgnoringCase
23
25
import com.google.firebase.dataconnect.util.ProtoUtil.buildStructProto
24
26
import com.google.firebase.dataconnect.util.ProtoUtil.decodeFromStruct
@@ -477,6 +479,21 @@ class ProtoStructDecoderUnitTest {
477
479
}
478
480
}
479
481
482
+ @Test
483
+ fun `decodeFromStruct() ignores unknown struct keys` () = runTest {
484
+ @Serializable data class TestData1 (val value1 : String , val value2 : String )
485
+ @Serializable data class TestData2 (val value1 : String )
486
+
487
+ val testData1Arb: Arb <TestData1 > =
488
+ Arb .twoValues(Arb .dataConnect.string()).map { (value1, value2) -> TestData1 (value1, value2) }
489
+
490
+ checkAll(propTestConfig, testData1Arb) { testData1 ->
491
+ val struct = encodeToStruct(testData1)
492
+ val decodedTestData = decodeFromStruct<TestData2 >(struct)
493
+ decodedTestData shouldBe TestData2 (testData1.value1)
494
+ }
495
+ }
496
+
480
497
@Test
481
498
fun `decodeFromStruct() should throw SerializationException if attempting to decode an Int` () {
482
499
assertDecodeFromStructThrowsIncorrectKindCase<Int >(
0 commit comments