From bed8c7f00dac9820f0a9240bc5a92ad02a6132a5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 27 Aug 2024 15:02:16 +0300 Subject: [PATCH] proto/test: Add repeated message test Signed-off-by: Evgenii Stratonikov --- util/proto/marshal_test.go | 15 +++++++++++++++ util/proto/test/custom/test_frostfs.pb.go | Bin 25899 -> 30182 bytes util/proto/test/test.pb.go | Bin 18340 -> 20911 bytes util/proto/test/test.proto | 3 +++ 4 files changed, 18 insertions(+) diff --git a/util/proto/marshal_test.go b/util/proto/marshal_test.go index 5d887ce..a848bb5 100644 --- a/util/proto/marshal_test.go +++ b/util/proto/marshal_test.go @@ -113,6 +113,10 @@ func repPrimitivesEqual(t *testing.T, a *generated.RepPrimitives, b *test.RepPri require.Equal(t, a.FieldE, b.FieldE) require.Equal(t, a.FieldF, b.FieldF) require.Equal(t, a.FieldFu, b.FieldFu) + require.Equal(t, len(a.GetFieldAux()), len(b.GetFieldAux())) + for i := range a.FieldAux { + require.Equal(t, a.GetFieldAux()[i].GetInnerField(), b.GetFieldAux()[i].GetInnerField()) + } } func randIntSlice[T protoInt](n int, includeZero bool) []T { @@ -129,6 +133,14 @@ func randIntSlice[T protoInt](n int, includeZero bool) []T { return r } +func uint32SliceToAux(s []uint32) []*generated.RepPrimitives_Aux { + r := make([]*generated.RepPrimitives_Aux, len(s)) + for i := range s { + r[i] = &generated.RepPrimitives_Aux{s[i]} + } + return r +} + func TestStableMarshalRep(t *testing.T) { t.Run("empty", func(t *testing.T) { marshalCases := []struct { @@ -176,6 +188,9 @@ func TestStableMarshalRep(t *testing.T) { {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](1, true)}}, {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](2, true)}}, {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](2, false)}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](1, true))}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](2, true))}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](2, false))}}, } for _, tc := range marshalCases { t.Run(tc.name, func(t *testing.T) { diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index a39bba7b55f648d89d34338879c7e4639ef6d480..f3b958fd5a784a55017c89cdd83c9c8fc5be3b93 100644 GIT binary patch delta 896 zcmZuvOK%cU7!9R71{j2r&=zfb!Jt5q+FDaWf|itrNL#BFYXS&Un9(sX;LLz+Ol#b@ z)6JK zFm3ai5QdU0^1@{d2O$urjhNvD`Pc-Uw7Fn5PLqu0HbW#roYrCn1p5e3c1tg*05Q7* z=4=*Q(o-@~NuI4%lFiP*@nmx+5^JvDlmK>OLF8+^%(qynNXXJvsV+o397)I6Q-Y&? zqlz|>(88ybQ;R9sa2~dWgJ>nB_P|VzFTi_e8Lzred2#A>4}47ZPmp3aOccd)yOqct zMFL+{W7O^%-UB0su-}i9)|6|R$2xtPkysRllK0llwh~1V(`c|l#ne`LIXTarOpQ6y513uT2GBT848>VjC8>&s0ze<-b4gIG2IcgBp$ z{Ml45EM^A?aN$jT{;qDqbDsz5P;E$FAXUh`HT^U%jPuh?1_*S$vr5l#fXSQ sdvCuJtn!lFbx`Ar!6@*cSl&V dZWfNOVwv3G<-d7u%0{-$Iyv4PlV_KD0{{V5O*H@j diff --git a/util/proto/test/test.pb.go b/util/proto/test/test.pb.go index de8ec65116b90776067757e70b2943386c7a84dc..e7d5699b73a81daaef96ecfadb426b4b0e543d4f 100644 GIT binary patch delta 725 zcmZvZU2D@|9K}gn)+R0;ovzxKv{~2Hc4oFs(ic0LPG`jpFE)jNlx}S`lYr|=n~u&a z@lpg|&Xu6x8;aiO%$+yxN(6;{0Abr#Q1Ev6Bm<$&o51;<^FL4Eyt+@le@T6~?W6fh zwNhviz`-{ zOl;#_;i=6jCz$nmn+Fx*(Jab%UYx?N;>FKm5Q9nv(@KD+m&w(dlAE1mzp!pzp?ra5 zbFyw4A4jr@j)Fmjf#K$h)+<>iZ*dA_1Hx{otxBTM)%`fMmh@m`U=rTRzQb($WFHM;6)YEMCFQ2KJURLT2fh% n8lRV#o65zBq8}tH%Lp<_Y%{Z`Aj@VwzdlAr