mirror of
https://github.com/google/pebble.git
synced 2025-06-24 01:56:16 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
49
third_party/nanopb/tests/regression/issue_558/mixed.c
vendored
Normal file
49
third_party/nanopb/tests/regression/issue_558/mixed.c
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
|
||||
#include "mixed.pb.h"
|
||||
#include "unittests.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int status = 0;
|
||||
pb_byte_t buf[64];
|
||||
size_t msglen;
|
||||
|
||||
{
|
||||
pb_ostream_t ostream = pb_ostream_from_buffer(buf, sizeof(buf));
|
||||
MixedMessage msg = MixedMessage_init_default;
|
||||
|
||||
msg.has_proto2_value = true;
|
||||
msg.proto2_value = 0;
|
||||
msg.proto3_value = 0;
|
||||
|
||||
if (!pb_encode(&ostream, MixedMessage_fields, &msg))
|
||||
{
|
||||
fprintf(stderr, "pb_encode() failed: %s\n", PB_GET_ERROR(&ostream));
|
||||
return 1;
|
||||
}
|
||||
|
||||
msglen = ostream.bytes_written;
|
||||
TEST(msglen > 0);
|
||||
}
|
||||
|
||||
{
|
||||
pb_istream_t istream = pb_istream_from_buffer(buf, msglen);
|
||||
MixedMessage msg = MixedMessage_init_default;
|
||||
|
||||
TEST(msg.proto2_value == 100);
|
||||
TEST(msg.proto3_value == 200);
|
||||
|
||||
if (!pb_decode(&istream, MixedMessage_fields, &msg))
|
||||
{
|
||||
fprintf(stderr, "pb_decode() failed: %s\n", PB_GET_ERROR(&istream));
|
||||
return 1;
|
||||
}
|
||||
|
||||
TEST(msg.proto2_value == 0);
|
||||
TEST(msg.proto3_value == 0);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue