Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-21 14:14:20 +0400
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-21 14:14:20 +0400
commit9cc19a5e998d93fbe6d7a7c18fba1e37a36076d5 (patch)
tree6fb10fa8670dc3197a2effb2fbe71a8550a6afac /tests/alltypes/SConscript
parenteff9e11150c0bfb6baf5d6bec2351034b72d95ed (diff)
Modify the alltypes test to check re-encoding through protoc.
This way we can verify that the message is encoded exactly the same way as the official protobuf implementation would do it.
Diffstat (limited to 'tests/alltypes/SConscript')
-rw-r--r--tests/alltypes/SConscript23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/alltypes/SConscript b/tests/alltypes/SConscript
index 1dc6f87..9c9072b 100644
--- a/tests/alltypes/SConscript
+++ b/tests/alltypes/SConscript
@@ -7,6 +7,29 @@ env.NanopbProto(["alltypes", "alltypes.options"])
enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o"])
dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o"])
+# Test the round-trip from nanopb encoder to nanopb decoder
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])
+# Re-encode the data using protoc, and check that the results from nanopb
+# match byte-per-byte to the protoc output.
+env.Decode("encode_alltypes.output.decoded",
+ ["encode_alltypes.output", "alltypes.proto"],
+ MESSAGE='AllTypes')
+env.Encode("encode_alltypes.output.recoded",
+ ["encode_alltypes.output.decoded", "alltypes.proto"],
+ MESSAGE='AllTypes')
+env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
+
+# Do the same checks with the optional fields present.
+env.RunTest("optionals.output", enc, ARGS = ['1'])
+env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
+env.Decode("optionals.output.decoded",
+ ["optionals.output", "alltypes.proto"],
+ MESSAGE='AllTypes')
+env.Encode("optionals.output.recoded",
+ ["optionals.output.decoded", "alltypes.proto"],
+ MESSAGE='AllTypes')
+env.Compare(["optionals.output", "optionals.output.recoded"])
+
+