mirror of
https://github.com/google/pebble.git
synced 2025-07-25 08:44:56 -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_395/SConscript
vendored
Normal file
14
third_party/nanopb/tests/regression/issue_395/SConscript
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Regression test for #395:
|
||||
# Unexpected empty submessage in proto3 mode
|
||||
|
||||
Import("env")
|
||||
|
||||
env.NanopbProto(["test.proto", "test.options"])
|
||||
testprog = env.Program(["test.c",
|
||||
"test.pb.c",
|
||||
"$COMMON/pb_encode.o",
|
||||
"$COMMON/pb_decode.o",
|
||||
"$COMMON/pb_common.o"])
|
||||
|
||||
env.RunTest(testprog)
|
||||
|
38
third_party/nanopb/tests/regression/issue_395/test.c
vendored
Normal file
38
third_party/nanopb/tests/regression/issue_395/test.c
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
#include "test.pb.h"
|
||||
#include "unittests.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
uint8_t buffer[512] = {0};
|
||||
int i;
|
||||
pb_ostream_t ostream;
|
||||
|
||||
Reply reply = Reply_init_zero;
|
||||
Reply_Result request_result = Reply_Result_OK;
|
||||
|
||||
ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
reply.result = request_result;
|
||||
if (!pb_encode(&ostream, Reply_fields, &reply)) {
|
||||
fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&ostream));
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("response payload (%d):", (int)ostream.bytes_written);
|
||||
for (i = 0; i < ostream.bytes_written; i++) {
|
||||
printf("%02X", buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
TEST(ostream.bytes_written == 2);
|
||||
TEST(buffer[0] == 0x08);
|
||||
TEST(buffer[1] == 0x01);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
3
third_party/nanopb/tests/regression/issue_395/test.options
vendored
Normal file
3
third_party/nanopb/tests/regression/issue_395/test.options
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
* proto3_singular_msgs:true
|
||||
SubSubAMessage.somestring max_size:64
|
||||
SubSubBMessage.somestring max_size:64
|
37
third_party/nanopb/tests/regression/issue_395/test.proto
vendored
Normal file
37
third_party/nanopb/tests/regression/issue_395/test.proto
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message Error
|
||||
{
|
||||
int32 code = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
message SubSubAMessage
|
||||
{
|
||||
string somestring = 1;
|
||||
}
|
||||
|
||||
message SubSubBMessage
|
||||
{
|
||||
string somestring = 1;
|
||||
}
|
||||
|
||||
message SubMessage
|
||||
{
|
||||
SubSubAMessage subsubmessageA = 1;
|
||||
repeated SubSubBMessage subsubmessageB = 2;
|
||||
}
|
||||
|
||||
message Reply
|
||||
{
|
||||
enum Result
|
||||
{
|
||||
ERROR = 0;
|
||||
OK = 1;
|
||||
SOME_A = 2;
|
||||
}
|
||||
|
||||
Result result = 1;
|
||||
Error error = 2;
|
||||
SubMessage submessage = 3;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue