[#107] proto/test: Add oneof test
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
866db105ed
commit
981dc785f3
4 changed files with 13 additions and 0 deletions
|
@ -49,6 +49,8 @@ func TestStableMarshalSingle(t *testing.T) {
|
||||||
{name: "fixed32", input: &generated.Primitives{FieldK: nonZero[uint32]()}},
|
{name: "fixed32", input: &generated.Primitives{FieldK: nonZero[uint32]()}},
|
||||||
{name: "enum, positive", input: &generated.Primitives{FieldH: generated.Primitives_POSITIVE}},
|
{name: "enum, positive", input: &generated.Primitives{FieldH: generated.Primitives_POSITIVE}},
|
||||||
{name: "enum, negative", input: &generated.Primitives{FieldH: generated.Primitives_NEGATIVE}},
|
{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 {
|
for _, tc := range marshalCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
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.FieldJ, b.FieldJ)
|
||||||
require.Equal(t, a.FieldK, b.FieldK)
|
require.Equal(t, a.FieldK, b.FieldK)
|
||||||
require.EqualValues(t, a.FieldH, b.FieldH)
|
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) {
|
func repPrimitivesEqual(t *testing.T, a *generated.RepPrimitives, b *test.RepPrimitives) {
|
||||||
|
|
BIN
util/proto/test/custom/test_frostfs.pb.go
generated
BIN
util/proto/test/custom/test_frostfs.pb.go
generated
Binary file not shown.
BIN
util/proto/test/test.pb.go
generated
BIN
util/proto/test/test.pb.go
generated
Binary file not shown.
|
@ -22,6 +22,14 @@ message Primitives {
|
||||||
NEGATIVE = -1;
|
NEGATIVE = -1;
|
||||||
}
|
}
|
||||||
SomeEnum field_h = 300;
|
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 {
|
message RepPrimitives {
|
||||||
|
|
Loading…
Reference in a new issue