@@ -27,6 +27,10 @@ import okio.ByteString.Companion.decodeHex
2727import org.junit.Test
2828import squareup.proto2.java.empty.EmptyLength as EmptyLengthJ
2929import squareup.proto2.java.interop.InteropMessage as InteropMessageJ
30+ import squareup.proto2.java.interop.InteropRepeatedUint as InteropRepeatedUintJ2
31+ import squareup.proto2.java.interop.InteropTest.InteropRepeatedUint as InteropRepeatedUintP2
32+ import squareup.proto2.java.interop.InteropTest.SubInteropRepeatedUint as SubInteropRepeatedUintP2
33+ import squareup.proto2.java.interop.SubInteropRepeatedUint as SubInteropRepeatedUintJ2
3034import squareup.proto2.java.interop.type.EnumProto2 as EnumProto2J
3135import squareup.proto2.java.interop.type.MessageProto2 as MessageProto2J
3236import squareup.proto2.kotlin.MapTypes
@@ -49,10 +53,12 @@ import squareup.proto2.kotlin.interop.InteropMessageOuterClass.extRepProto2Enum
4953import squareup.proto2.kotlin.interop.InteropMessageOuterClass.extRepProto2Message
5054import squareup.proto2.kotlin.interop.InteropMessageOuterClass.extRepProto3Enum
5155import squareup.proto2.kotlin.interop.InteropMessageOuterClass.extRepProto3Message
56+ import squareup.proto2.kotlin.interop.InteropRepeatedUint as InteropRepeatedUintK2
5257import squareup.proto2.kotlin.interop.Quilt
5358import squareup.proto2.kotlin.interop.QuiltColor
5459import squareup.proto2.kotlin.interop.QuiltContainer
5560import squareup.proto2.kotlin.interop.RepeatedEnum
61+ import squareup.proto2.kotlin.interop.SubInteropRepeatedUint as SubInteropRepeatedUintK2
5662import squareup.proto2.kotlin.interop.type.EnumProto2 as EnumProto2K
5763import squareup.proto2.kotlin.interop.type.InteropTypes.EnumProto2
5864import squareup.proto2.kotlin.interop.type.InteropTypes.MessageProto2
@@ -183,6 +189,35 @@ class Proto2WireProtocCompatibilityTests {
183189 assertThat(mapTypeWire.map_string_string[" " ]).isEqualTo(" ed" )
184190 }
185191
192+ @Test fun decodingRepeatedEntries () {
193+ // ── 1 ┐
194+ // ├─ 1: 1
195+ // ╰- 1: 1
196+ val byteArray = byteArrayOf(10 , 3 , 10 , 1 , 1 , 10 , 3 , 10 , 1 , 1 )
197+ assertThat(InteropRepeatedUintP2 .parseFrom(byteArray))
198+ .isEqualTo(
199+ InteropRepeatedUintP2 .newBuilder()
200+ .setSubMessage(
201+ SubInteropRepeatedUintP2 .newBuilder().addAllRepeatedValues(listOf (1 , 1 )).build(),
202+ )
203+ .build(),
204+ )
205+ assertThat(InteropRepeatedUintJ2 .ADAPTER .decode(byteArray)).isEqualTo(
206+ InteropRepeatedUintJ2 .Builder ()
207+ .sub_message(
208+ SubInteropRepeatedUintJ2 .Builder ().repeated_values(listOf (1 , 1 )).build(),
209+ )
210+ .build(),
211+ )
212+ assertThat(InteropRepeatedUintK2 .ADAPTER .decode(byteArray)).isEqualTo(
213+ InteropRepeatedUintK2 .Builder ()
214+ .sub_message(
215+ SubInteropRepeatedUintK2 .Builder ().repeated_values(listOf (1 , 1 )).build(),
216+ )
217+ .build(),
218+ )
219+ }
220+
186221 /* *
187222 * The TS-proto library encodes enums differently from Wire or Protoc. Protoc is fine with this,
188223 * but it causes Wire to crash. The fix is to make Wire accept this format also.
0 commit comments