Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View 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)

View file

@ -0,0 +1,4 @@
* long_names : false
NoDecode.name max_length : 32

View 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;
}

View 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;
}