summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pb/test_decoder.cc13
-rw-r--r--tests/test_table.cc23
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc
index e016632..2d94d82 100644
--- a/tests/pb/test_decoder.cc
+++ b/tests/pb/test_decoder.cc
@@ -612,6 +612,9 @@ void run_decoder(const string& proto, const string* expected_output) {
if (ok) {
fprintf(stderr, "Didn't expect ok result, but got output: '%s'\n",
output.c_str());
+ } else if (filter_hash) {
+ fprintf(stderr, "Failed as we expected, with message: %s\n",
+ status.error_message());
}
ASSERT(!ok);
}
@@ -838,6 +841,10 @@ void test_invalid() {
// Field number is 0.
assert_does_not_parse(
cat( tag(0, UPB_WIRE_TYPE_DELIMITED), varint(0) ));
+ // The previous test alone did not catch this particular pattern which could
+ // corrupt the internal state.
+ assert_does_not_parse(
+ cat( tag(0, UPB_WIRE_TYPE_64BIT), uint64(0) ));
// Field number is too large.
assert_does_not_parse(
@@ -928,6 +935,12 @@ void test_valid() {
submsg(12345, string(" ")),
"<\n>\n");
+ // This triggered a previous bug in the decoder.
+ assert_successful_parse(
+ cat( tag(UPB_DESCRIPTOR_TYPE_SFIXED32, UPB_WIRE_TYPE_VARINT),
+ varint(0) ),
+ "<\n>\n");
+
assert_successful_parse(
cat(
submsg(UPB_DESCRIPTOR_TYPE_MESSAGE,
diff --git a/tests/test_table.cc b/tests/test_table.cc
index 2d08abb..d51138b 100644
--- a/tests/test_table.cc
+++ b/tests/test_table.cc
@@ -284,6 +284,26 @@ int32_t *get_contiguous_keys(int32_t num) {
return buf;
}
+void test_delete() {
+ upb_inttable t;
+ upb_inttable_init(&t, UPB_CTYPE_BOOL);
+ upb_inttable_insert(&t, 0, upb_value_bool(true));
+ upb_inttable_insert(&t, 2, upb_value_bool(true));
+ upb_inttable_insert(&t, 4, upb_value_bool(true));
+ upb_inttable_compact(&t);
+ upb_inttable_remove(&t, 0, NULL);
+ upb_inttable_remove(&t, 2, NULL);
+ upb_inttable_remove(&t, 4, NULL);
+
+ upb_inttable_iter iter;
+ for (upb_inttable_begin(&iter, &t); !upb_inttable_done(&iter);
+ upb_inttable_next(&iter)) {
+ ASSERT(false);
+ }
+
+ upb_inttable_uninit(&t);
+}
+
extern "C" {
int run_tests(int argc, char *argv[]) {
@@ -336,6 +356,9 @@ int run_tests(int argc, char *argv[]) {
}
test_inttable(keys4, 64, "Table size: 64, keys: 1-32 and 10133-10164 ====\n");
delete[] keys4;
+
+ test_delete();
+
return 0;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback