Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson
2025-01-27 11:38:16 -08:00
committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions
@@ -0,0 +1,14 @@
# Regression test for #376:
# Problem with fixed array inside proto3 submessage
Import("env")
env.NanopbProto(["fixed_array.proto", "fixed_array.options"])
testprog = env.Program(["test_fixarray.c",
"fixed_array.pb.c",
"$COMMON/pb_encode.o",
"$COMMON/pb_decode.o",
"$COMMON/pb_common.o"])
env.RunTest(testprog)
@@ -0,0 +1,2 @@
SubMessage.data fixed_count:true,max_count:8
MainMessage.submsg proto3_singular_msgs:true
@@ -0,0 +1,11 @@
syntax = "proto3";
message MainMessage {
SubMessage submsg = 1;
}
message SubMessage {
repeated int32 data = 1;
}
@@ -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;
}