diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-10-29 18:20:15 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-10-29 18:20:15 +0200 |
commit | 28b0136ea4dcd045f0422d16a25b7d82b0d2aaee (patch) | |
tree | 7ec5fd5962a733b53e2bc93ea90618df58e5806f /tests | |
parent | 9e0ee92f0a42ce2c5c9d4bf4f1d7d822caf1c561 (diff) |
Improve .proto options parsing.
Options can now be defined on command line, file, message or in field
scope.
Update issue 12
Status: Started
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 10 | ||||
-rw-r--r-- | tests/options.expected | 3 | ||||
-rw-r--r-- | tests/options.proto | 28 |
3 files changed, 40 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile index 7656175..434819c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -55,7 +55,7 @@ coverage: run_unittests gcov pb_encode.gcda gcov pb_decode.gcda -run_unittests: decode_unittests encode_unittests test_cxxcompile test_encode1 test_encode2 test_encode3 test_decode1 test_decode2 test_decode3 test_encode_callbacks test_decode_callbacks test_missing_fields +run_unittests: decode_unittests encode_unittests test_cxxcompile test_encode1 test_encode2 test_encode3 test_decode1 test_decode2 test_decode3 test_encode_callbacks test_decode_callbacks test_missing_fields test_options rm -f *.gcda ./decode_unittests > /dev/null @@ -82,5 +82,13 @@ run_unittests: decode_unittests encode_unittests test_cxxcompile test_encode1 te ./test_missing_fields +test_options: options.pb.h options.expected + for p in $$(grep . options.expected); do \ + if ! grep -qF "$$p" $<; then \ + echo Expected: $$p; \ + exit 1; \ + fi \ + done + run_fuzztest: test_decode2 bash -c 'I=1; while true; do cat /dev/urandom | ./test_decode2 > /dev/null; I=$$(($$I+1)); echo -en "\r$$I"; done' diff --git a/tests/options.expected b/tests/options.expected new file mode 100644 index 0000000..e184cf9 --- /dev/null +++ b/tests/options.expected @@ -0,0 +1,3 @@ +char filesize[20]; +char msgsize[30]; +char fieldsize[40]; diff --git a/tests/options.proto b/tests/options.proto new file mode 100644 index 0000000..73edf2b --- /dev/null +++ b/tests/options.proto @@ -0,0 +1,28 @@ +/* Test nanopb option parsing. + * options.expected lists the patterns that are searched for in the output. + */ + +import "nanopb.proto"; + +// File level options +option (nanopb_fileopt).max_size = 20; + +message Message1 +{ + required string filesize = 1; +} + +// Message level options +message Message2 +{ + option (nanopb_msgopt).max_size = 30; + required string msgsize = 1; +} + +// Field level options +message Message3 +{ + required string fieldsize = 1 [(nanopb).max_size = 40]; +} + + |