summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-07-31 21:50:33 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-07-31 21:50:33 -0700
commitfe427341f29a31656e247ef528adbab5ad786c9e (patch)
tree14cdd5fdb83c81f6c378b30de134fb767b136c0f /tests
parent9c788b116e9a3ba6d774f39025a0f89e77598d44 (diff)
Decoder fix: skipped data at end of submessage.
Diffstat (limited to 'tests')
-rw-r--r--tests/pb/test_decoder.cc17
-rw-r--r--tests/test_util.h6
2 files changed, 21 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),
diff --git a/tests/test_util.h b/tests/test_util.h
index d2d30a4..eafee64 100644
--- a/tests/test_util.h
+++ b/tests/test_util.h
@@ -53,10 +53,16 @@ class VerboseParserEnvironment {
bool Start() {
+ if (verbose_) {
+ fprintf(stderr, "Calling start()\n");
+ }
return sink_->Start(len_, &subc_);
}
bool End() {
+ if (verbose_) {
+ fprintf(stderr, "Calling end()\n");
+ }
return sink_->End();
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback