diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-12-15 00:03:35 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-12-15 00:03:35 +0000 |
commit | 7ecaead1261f60de80f205a83546966941b7f543 (patch) | |
tree | 45680bae9335ed374090f4aee3812fe80c98accc /tests/regression/issue_395/test.c | |
parent | 75930fdbca54e79d07a890855a04f161a7cbdce9 (diff) | |
parent | 2698e8bf57b179ed5922aeb1217d2e7fd1184075 (diff) | |
download | nanopb-c-android12L-d2-s1-release.tar.gz |
Snap for 8000352 from 2698e8bf57b179ed5922aeb1217d2e7fd1184075 to sc-d2-releaseandroid-12.1.0_r26android-12.1.0_r25android-12.1.0_r24android-12.1.0_r23android-12.1.0_r18android-12.1.0_r17android-12.1.0_r16android-12.1.0_r15android-12.1.0_r14android-12.1.0_r13android-12.1.0_r12android12L-d2-s8-releaseandroid12L-d2-s7-releaseandroid12L-d2-s6-releaseandroid12L-d2-s5-releaseandroid12L-d2-s4-releaseandroid12L-d2-s3-releaseandroid12L-d2-s2-releaseandroid12L-d2-s1-releaseandroid12L-d2-release
Change-Id: Ic35f7dce5040938cd47b31fec40fd3f9f4eb1830
Diffstat (limited to 'tests/regression/issue_395/test.c')
-rw-r--r-- | tests/regression/issue_395/test.c | 38 |
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; +} + |