mirror of
https://github.com/google/pebble.git
synced 2025-09-01 08:25:44 -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
10
third_party/nanopb/tests/regression/issue_617/SConscript
vendored
Normal file
10
third_party/nanopb/tests/regression/issue_617/SConscript
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Regression test for #617:
|
||||
# Unordered field numbers inside oneof can cause fields to be ignored
|
||||
|
||||
Import("env")
|
||||
|
||||
env.NanopbProto(["oneof.proto", "oneof.options"])
|
||||
|
||||
test = env.Program(["test_oneof.c", "oneof.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"])
|
||||
env.RunTest(test)
|
||||
|
4
third_party/nanopb/tests/regression/issue_617/oneof.options
vendored
Normal file
4
third_party/nanopb/tests/regression/issue_617/oneof.options
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
* long_names : false
|
||||
|
||||
NoDecode.name max_length : 32
|
||||
|
41
third_party/nanopb/tests/regression/issue_617/oneof.proto
vendored
Normal file
41
third_party/nanopb/tests/regression/issue_617/oneof.proto
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message DecodesOK
|
||||
{
|
||||
uint32 a = 1;
|
||||
uint32 b = 2;
|
||||
}
|
||||
|
||||
message NoDecode
|
||||
{
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message TestMessage
|
||||
{
|
||||
enum MessageType
|
||||
{
|
||||
A = 0;
|
||||
B = 1;
|
||||
C = 2;
|
||||
}
|
||||
|
||||
MessageType messageType = 1;
|
||||
uint32 x = 2;
|
||||
uint32 y = 3;
|
||||
uint32 ip1 = 4;
|
||||
|
||||
oneof payload
|
||||
{
|
||||
DecodesOK pla5 = 5;
|
||||
DecodesOK pla6 = 6;
|
||||
DecodesOK pla7 = 7;
|
||||
DecodesOK pla8 = 8;
|
||||
DecodesOK pla9 = 9;
|
||||
DecodesOK pla10 = 10;
|
||||
NoDecode plb11 = 12;
|
||||
}
|
||||
|
||||
uint32 ip2 = 11;
|
||||
}
|
||||
|
22
third_party/nanopb/tests/regression/issue_617/test_oneof.c
vendored
Normal file
22
third_party/nanopb/tests/regression/issue_617/test_oneof.c
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <pb_decode.h>
|
||||
#include <unittests.h>
|
||||
#include "oneof.pb.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
const uint8_t input_data[] = {
|
||||
0x08, 0x01, 0x10, 0x0F, 0x18, 0xAC, 0x02, 0x20,
|
||||
0xF1, 0x82, 0xA0, 0x85, 0x0C, 0x62, 0x00, 0x58,
|
||||
0xF1, 0x82, 0xA0, 0x85, 0x0C
|
||||
};
|
||||
|
||||
int status = 0;
|
||||
TestMessage msg = TestMessage_init_zero;
|
||||
pb_istream_t stream = pb_istream_from_buffer(input_data, sizeof(input_data));
|
||||
|
||||
TEST(pb_decode(&stream, TestMessage_fields, &msg));
|
||||
TEST(msg.which_payload == TestMessage_plb11_tag);
|
||||
TEST(msg.payload.plb11.name[0] == 0);
|
||||
|
||||
return status;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue