mirror of
https://github.com/google/pebble.git
synced 2025-07-14 10:11:59 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
40
third_party/nanopb/tests/regression/issue_376/test_fixarray.c
vendored
Normal file
40
third_party/nanopb/tests/regression/issue_376/test_fixarray.c
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
#include "fixed_array.pb.h"
|
||||
#include "unittests.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
uint8_t buffer[64];
|
||||
pb_size_t msglen = 0;
|
||||
|
||||
{
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
MainMessage msg = MainMessage_init_zero;
|
||||
|
||||
msg.submsg.data[0] = 0;
|
||||
msg.submsg.data[4] = 5;
|
||||
|
||||
TEST(pb_encode(&stream, MainMessage_fields, &msg));
|
||||
|
||||
msglen = stream.bytes_written;
|
||||
TEST(msglen > 5);
|
||||
}
|
||||
|
||||
{
|
||||
pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
|
||||
MainMessage msg = MainMessage_init_zero;
|
||||
|
||||
TEST(pb_decode(&stream, MainMessage_fields, &msg));
|
||||
|
||||
TEST(msg.submsg.data[0] == 0);
|
||||
TEST(msg.submsg.data[4] == 5);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue