diff options
author | Josh Haberman <jhaberman@gmail.com> | 2015-07-31 21:50:33 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2015-07-31 21:50:33 -0700 |
commit | fe427341f29a31656e247ef528adbab5ad786c9e (patch) | |
tree | 14cdd5fdb83c81f6c378b30de134fb767b136c0f /tests/pb/test_decoder.cc | |
parent | 9c788b116e9a3ba6d774f39025a0f89e77598d44 (diff) |
Decoder fix: skipped data at end of submessage.
Diffstat (limited to 'tests/pb/test_decoder.cc')
-rw-r--r-- | tests/pb/test_decoder.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc index 310f8c1..78dd7dc 100644 --- a/tests/pb/test_decoder.cc +++ b/tests/pb/test_decoder.cc @@ -138,7 +138,7 @@ void PrintBinary(const string& str) { if (isprint(str[i])) { fprintf(stderr, "%c", str[i]); } else { - fprintf(stderr, "\\x%02x", str[i]); + fprintf(stderr, "\\x%02x", (int)(uint8_t)str[i]); } } } @@ -575,7 +575,6 @@ void do_run_decoder(VerboseParserEnvironment* env, upb::pb::Decoder* decoder, } else { fprintf(stderr, "Expected to FAIL\n"); } - fprintf(stderr, "Calling start()\n"); } bool ok = env->Start() && @@ -941,6 +940,20 @@ void test_valid() { submsg(12345, string(" ")), "<\n>\n"); + // Unknown field inside a known submessage. + assert_successful_parse( + cat (submsg(UPB_DESCRIPTOR_TYPE_MESSAGE, + submsg(12345, string(" "))), + tag(UPB_DESCRIPTOR_TYPE_INT32, UPB_WIRE_TYPE_VARINT), + varint(5)), + LINE("<") + LINE("%u:{") + LINE(" <") + LINE(" >") + LINE("}") + LINE("%u:5") + LINE(">"), UPB_DESCRIPTOR_TYPE_MESSAGE, UPB_DESCRIPTOR_TYPE_INT32); + // This triggered a previous bug in the decoder. assert_successful_parse( cat( tag(UPB_DESCRIPTOR_TYPE_SFIXED32, UPB_WIRE_TYPE_VARINT), |