From dce25705f87595df06e5114886d9ebc70874cdb6 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 26 Aug 2024 14:33:30 +0300 Subject: [PATCH] proto/test: Add oneof test Signed-off-by: Evgenii Stratonikov --- util/proto/marshal_test.go | 5 +++++ util/proto/test/custom/test_frostfs.pb.go | Bin 19136 -> 25935 bytes util/proto/test/test.pb.go | Bin 14249 -> 18340 bytes util/proto/test/test.proto | 8 ++++++++ 4 files changed, 13 insertions(+) diff --git a/util/proto/marshal_test.go b/util/proto/marshal_test.go index d5758f2..5d887ce 100644 --- a/util/proto/marshal_test.go +++ b/util/proto/marshal_test.go @@ -49,6 +49,8 @@ func TestStableMarshalSingle(t *testing.T) { {name: "fixed32", input: &generated.Primitives{FieldK: nonZero[uint32]()}}, {name: "enum, positive", input: &generated.Primitives{FieldH: generated.Primitives_POSITIVE}}, {name: "enum, negative", input: &generated.Primitives{FieldH: generated.Primitives_NEGATIVE}}, + {name: "oneof, first", input: &generated.Primitives{FieldM: &generated.Primitives_FieldMa{FieldMa: []byte{4, 2}}}}, + {name: "oneof, second", input: &generated.Primitives{FieldM: &generated.Primitives_FieldMe{FieldMe: nonZero[uint32]()}}}, } for _, tc := range marshalCases { t.Run(tc.name, func(t *testing.T) { @@ -97,6 +99,9 @@ func primitivesEqual(t *testing.T, a *generated.Primitives, b *test.Primitives) require.Equal(t, a.FieldJ, b.FieldJ) require.Equal(t, a.FieldK, b.FieldK) require.EqualValues(t, a.FieldH, b.FieldH) + require.Equal(t, a.GetFieldMa(), b.GetFieldMa()) + require.Equal(t, a.GetFieldMe(), b.GetFieldMe()) + require.Equal(t, a.GetFieldAux().GetInnerField(), b.GetFieldAux().GetInnerField()) } func repPrimitivesEqual(t *testing.T, a *generated.RepPrimitives, b *test.RepPrimitives) { diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index c99234e51123aee48609c0769ddd8229995a6fea..b1d2cf278ab0acf60930514fd1fbeb6c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x9M3x6W@oNfr-95l4=A zG~eOb^CzHT;Y#W2Q^UUq3hi*B&N=pVLLaEM-3d+JF@<+@FIMyd@%`=uv9EO$02*;{ Yj2E0TAIgq*!p{7QSKy$&A#X(g0ZoKWZU6uP delta 78 zcmV-U0I~ni$^pQY0k8uFvnLSl0kbg@Vgr+GNL`aqG82>ENV1bX2nw?S7{3CubsVGz k0ezF9Q5%zBFAB0JZw9jtGDiio202*=lgtlMv-d+-A!SP&!2kdN diff --git a/util/proto/test/test.pb.go b/util/proto/test/test.pb.go index 57f7fb0380493817f35399d125e1da0a5a86f76c..de8ec65116b90776067757e70b2943386c7a84dc 100644 GIT binary patch delta 2565 zcmb7GO>7%Q6qXZ;vm2*QWYYXJjweoHubqvv>s=>}(?G)k)Ji6$AQhCR$tD?tLt-0y zUAYR8;mlv*U644G0~a`y9}AU3rIsV&K*9+Q5vqj5r3b{RLL7KA<2swzsmQ_B%$x6h z?|VNxyIMoJ zlcE<3nazxyxkigi;>#jEk1z@}f(fxD_|3(^s*v?@gNq1?*pvpR%eAMJ9?MHOp{^sns=xcTCEwv0Ko1yjztw&|o23OVmo=g9oTJSd zcC^HsElR)*99t_wkgy3z1|3Lv+cP|}#PwXFMQXEbWhq)Fv&1ohEc#u~OD*w5c%kns zTv#fAQ>t(r<;*W2e4G4Tr6&j?gs zsAqpGOWX3JOGT@`;=kl-vnExdl{K^a?ckSgS&y@wzKV>$jSWLq>FQf!mPwu4&#?b# zzSa!5AL!{rq*gY$T|*sOIl&pUDL6Sc((UwhGEWT35|WDJgo9c*b80s~HP65WbrgC@ zSHOwpIKyO~n#KR8VQwf0-iRA2%8Aoc36({d;=*(x+u%6P-Lb;fhLB{!jnUB-S%Q0m z33xE-9Wr@>NP!r^P*0GNCgQL+rofHBlQ}0w=Q`q|oI(?iSZ8wx5`oiPkbrVQlhe#H zNge+}1ji@Rm|}nleJ0QYpAE~f9`%fH_s2V$Ad^A35*mljQ13~MAiAurV2$9b(2R?~ zgU~P|?hLa{D$F-;hG*bz*b8^U-5#dhFfzuFGJ@7C2^>kz$ zTBC6`kRT1Uw`e8=)E+E=3O_3+TqevadOgryw4eDrjQU|dG63A{O);`12{l-M;61=RN1)oF7sbE7$ve%*R6JbinYKpW$tvnNCbm zUZMz`T#-{|wg1wC*HqF)``}H-C=SW=kPS-?95mp;f$s(=S_FpXcF78kv@R=gqp^14 zSu0?LMDd$#g^^Jqic!0KoGBp4x8RBoGbw@g$rY72%XM^%5~X5>^x=?aQO?Hk!b>0zbs`> T3Yl&Bx(iQZACzj|j@PJvmG6a2 diff --git a/util/proto/test/test.proto b/util/proto/test/test.proto index 14f6ac2..f33be49 100644 --- a/util/proto/test/test.proto +++ b/util/proto/test/test.proto @@ -22,6 +22,14 @@ message Primitives { NEGATIVE = -1; } SomeEnum field_h = 300; + + message Aux { uint32 inner_field = 1; } + + oneof field_m { + bytes field_ma = 401; + uint32 field_me = 402; + Aux field_aux = 403; + } } message RepPrimitives {