aboutsummaryrefslogtreecommitdiff
path: root/tests/regression/issue_395/test.c
diff options
context:
space:
mode:
authorKrzysztof Kosiński <krzysio@google.com>2021-12-05 17:15:15 +0000
committerKrzysztof Kosiński <krzysio@google.com>2021-12-10 00:56:29 -0800
commit2698e8bf57b179ed5922aeb1217d2e7fd1184075 (patch)
tree45680bae9335ed374090f4aee3812fe80c98accc /tests/regression/issue_395/test.c
parent8eaf90c022e7862456fa5c97f3f03bdfbd6d68c9 (diff)
parent7ee9ef9f627d85cbe1b8c4f49a3ed26eed216c77 (diff)
downloadnanopb-c-2698e8bf57b179ed5922aeb1217d2e7fd1184075.tar.gz
Performed by merging the upgrade commit from master. Bug: 198577383 Test: presubmit Merged-In: If02f28dcb5a6034625681a733e640c550e79c6a2 Change-Id: I8f12a43d3a7c9048785de12c24285ae99e8571b6
Diffstat (limited to 'tests/regression/issue_395/test.c')
-rw-r--r--tests/regression/issue_395/test.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/regression/issue_395/test.c b/tests/regression/issue_395/test.c
new file mode 100644
index 0000000..9578caf
--- /dev/null
+++ b/tests/regression/issue_395/test.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pb_encode.h>
+#include <pb_decode.h>
+#include "test.pb.h"
+#include "unittests.h"
+
+int main(int argc, char **argv)
+{
+ int status = 0;
+ uint8_t buffer[512] = {0};
+ int i;
+ pb_ostream_t ostream;
+
+ Reply reply = Reply_init_zero;
+ Reply_Result request_result = Reply_Result_OK;
+
+ ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
+ reply.result = request_result;
+ if (!pb_encode(&ostream, Reply_fields, &reply)) {
+ fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&ostream));
+ return 1;
+ }
+
+ printf("response payload (%d):", (int)ostream.bytes_written);
+ for (i = 0; i < ostream.bytes_written; i++) {
+ printf("%02X", buffer[i]);
+ }
+ printf("\n");
+
+ TEST(ostream.bytes_written == 2);
+ TEST(buffer[0] == 0x08);
+ TEST(buffer[1] == 0x01);
+
+ return status;
+}
+