mirror of
https://github.com/google/pebble.git
synced 2025-08-24 11:17:24 -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
14
third_party/nanopb/tests/regression/issue_363/SConscript
vendored
Normal file
14
third_party/nanopb/tests/regression/issue_363/SConscript
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Regression test for #363:
|
||||
# Incorrect PB_STATIC_ASSERT for bytes inside oneof
|
||||
|
||||
Import("env")
|
||||
|
||||
env.NanopbProto("oneofmsg.proto")
|
||||
testprog = env.Program(["test_oneofmsg.c",
|
||||
"oneofmsg.pb.c",
|
||||
"$COMMON/pb_encode.o",
|
||||
"$COMMON/pb_decode.o",
|
||||
"$COMMON/pb_common.o"])
|
||||
|
||||
env.RunTest(testprog)
|
||||
|
10
third_party/nanopb/tests/regression/issue_363/oneofmsg.proto
vendored
Normal file
10
third_party/nanopb/tests/regression/issue_363/oneofmsg.proto
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
syntax = "proto2";
|
||||
|
||||
import "nanopb.proto";
|
||||
|
||||
message BodyMessage {
|
||||
oneof body_type {
|
||||
bytes device_data_crypted = 1 [(nanopb).max_size = 252];
|
||||
bytes device_config_crypted = 2 [(nanopb).max_size = 252];
|
||||
}
|
||||
}
|
42
third_party/nanopb/tests/regression/issue_363/test_oneofmsg.c
vendored
Normal file
42
third_party/nanopb/tests/regression/issue_363/test_oneofmsg.c
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
#include "oneofmsg.pb.h"
|
||||
#include "unittests.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
uint8_t buffer[512];
|
||||
pb_size_t msglen = 0;
|
||||
|
||||
{
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
BodyMessage msg = BodyMessage_init_zero;
|
||||
|
||||
msg.which_body_type = BodyMessage_device_data_crypted_tag;
|
||||
msg.body_type.device_data_crypted.size = 252;
|
||||
memset(msg.body_type.device_data_crypted.bytes, 0xAA, 252);
|
||||
|
||||
TEST(pb_encode(&stream, BodyMessage_fields, &msg));
|
||||
|
||||
msglen = stream.bytes_written;
|
||||
TEST(msglen > 252);
|
||||
}
|
||||
|
||||
{
|
||||
pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
|
||||
BodyMessage msg = BodyMessage_init_zero;
|
||||
|
||||
TEST(pb_decode(&stream, BodyMessage_fields, &msg));
|
||||
|
||||
TEST(msg.which_body_type == BodyMessage_device_data_crypted_tag);
|
||||
TEST(msg.body_type.device_data_crypted.size == 252);
|
||||
TEST(msg.body_type.device_data_crypted.bytes[251] == 0xAA);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue