Adding upstream version 1.2+20240521.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6b2864e4b9
commit
8512f66c5a
229 changed files with 19561 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"nested": {}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package proto3_field_presence_oneof;
|
||||
|
||||
message Test {
|
||||
oneof kind {
|
||||
Nested nested = 1;
|
||||
WithOptional with_optional = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message InnerNested {
|
||||
optional bool a = 1;
|
||||
}
|
||||
|
||||
message Nested {
|
||||
InnerNested inner = 1;
|
||||
}
|
||||
|
||||
message WithOptional {
|
||||
optional bool b = 2;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
from tests.output_aristaproto.proto3_field_presence_oneof import (
|
||||
InnerNested,
|
||||
Nested,
|
||||
Test,
|
||||
WithOptional,
|
||||
)
|
||||
|
||||
|
||||
def test_serialization():
|
||||
"""Ensure that serialization of fields unset but with explicit field
|
||||
presence do not bloat the serialized payload with length-delimited fields
|
||||
with length 0"""
|
||||
|
||||
def test_empty_nested(message: Test) -> None:
|
||||
# '0a' => tag 1, length delimited
|
||||
# '00' => length: 0
|
||||
assert bytes(message) == bytearray.fromhex("0a 00")
|
||||
|
||||
test_empty_nested(Test(nested=Nested()))
|
||||
test_empty_nested(Test(nested=Nested(inner=None)))
|
||||
test_empty_nested(Test(nested=Nested(inner=InnerNested(a=None))))
|
||||
|
||||
def test_empty_with_optional(message: Test) -> None:
|
||||
# '12' => tag 2, length delimited
|
||||
# '00' => length: 0
|
||||
assert bytes(message) == bytearray.fromhex("12 00")
|
||||
|
||||
test_empty_with_optional(Test(with_optional=WithOptional()))
|
||||
test_empty_with_optional(Test(with_optional=WithOptional(b=None)))
|
Loading…
Add table
Add a link
Reference in a new issue