aboutsummaryrefslogtreecommitdiff
path: root/tests/regression/issue_547/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regression/issue_547/test.c')
-rw-r--r--tests/regression/issue_547/test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/regression/issue_547/test.c b/tests/regression/issue_547/test.c
new file mode 100644
index 0000000..9530302
--- /dev/null
+++ b/tests/regression/issue_547/test.c
@@ -0,0 +1,28 @@
+#include <string.h>
+#include <pb_encode.h>
+#include <unittests.h>
+#include "test.pb.h"
+
+int main()
+{
+ pb_byte_t buf[512];
+ MyMessage msg = MyMessage_init_zero;
+ pb_ostream_t stream = pb_ostream_from_buffer(buf, sizeof(buf));
+
+ msg.mybytes.size = 0xFFFFFFFF;
+
+ if (pb_encode(&stream, MyMessage_fields, &msg))
+ {
+ fprintf(stderr, "Failure: expected pb_encode() to fail.\n");
+ return 1;
+ }
+ else if (strcmp(PB_GET_ERROR(&stream), "bytes size exceeded") != 0)
+ {
+ fprintf(stderr, "Unexpected encoding error: %s\n", PB_GET_ERROR(&stream));
+ return 2;
+ }
+ else
+ {
+ return 0;
+ }
+}