MOS Source Code
Loading...
Searching...
No Matches
test_fixarray.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <pb_encode.h>
5
#include <pb_decode.h>
6
#include "fixed_array.pb.h"
7
#include "
unittests.h
"
8
9
int
main
(
int
argc
,
char
**
argv
)
10
{
11
int
status = 0;
12
uint8_t
buffer
[64];
13
pb_size_t
msglen = 0;
14
15
{
16
pb_ostream_t stream =
pb_ostream_from_buffer
(
buffer
,
sizeof
(
buffer
));
17
MainMessage msg = MainMessage_init_zero;
18
19
msg.submsg.data[0] = 0;
20
msg.submsg.data[4] = 5;
21
22
TEST
(
pb_encode
(&stream, MainMessage_fields, &msg));
23
24
msglen = stream.bytes_written;
25
TEST
(msglen > 5);
26
}
27
28
{
29
pb_istream_t stream =
pb_istream_from_buffer
(
buffer
, msglen);
30
MainMessage msg = MainMessage_init_zero;
31
32
TEST
(
pb_decode
(&stream, MainMessage_fields, &msg));
33
34
TEST
(msg.submsg.data[0] == 0);
35
TEST
(msg.submsg.data[4] == 5);
36
}
37
38
return
status;
39
}
40
argv
const char ** argv
Definition
kmain.c:44
argc
size_t argc
Definition
kmain.c:43
pb_size_t
uint_least16_t pb_size_t
Definition
pb.h:310
pb_decode
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
Definition
pb_decode.c:1182
pb_istream_from_buffer
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t msglen)
Definition
pb_decode.c:143
pb_ostream_from_buffer
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
Definition
pb_encode.c:63
pb_encode
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
Definition
pb_encode.c:512
uint8_t
unsigned char uint8_t
Definition
pb_syshdr.h:20
main
int main()
Definition
simple.cpp:6
TEST
#define TEST(x)
Definition
test.h:3
buffer
static char buffer[2048]
Definition
test_printf.c:7
unittests.h
libs
nanopb
nanopb
tests
regression
issue_376
test_fixarray.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0