MOS Source Code
Loading...
Searching...
No Matches
pio_without_options.c
Go to the documentation of this file.
1#include "pb_encode.h"
2#include "pb_decode.h"
3
4#include "test.h"
5
6#include "pio_without_options.pb.h"
7
8int main(int argc, char *argv[]) {
9
10 int status = 0;
11
12 uint8_t buffer[256];
13 pb_ostream_t ostream;
14 pb_istream_t istream;
15 size_t written;
16
17 TestMessageWithoutOptions original = TestMessageWithoutOptions_init_zero;
18 original.number = 45;
19
20 ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
21
22 TEST(pb_encode(&ostream, &TestMessageWithoutOptions_msg, &original));
23
24 written = ostream.bytes_written;
25
26 istream = pb_istream_from_buffer(buffer, written);
27
28 TestMessageWithoutOptions decoded = TestMessageWithoutOptions_init_zero;
29
30 TEST(pb_decode(&istream, &TestMessageWithoutOptions_msg, &decoded));
31
32 TEST(decoded.number == 45);
33
34 return status;
35}
const char ** argv
Definition kmain.c:44
size_t argc
Definition kmain.c:43
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
Definition pb_decode.c:1182
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t msglen)
Definition pb_decode.c:143
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
Definition pb_encode.c:63
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
Definition pb_encode.c:512
unsigned char uint8_t
Definition pb_syshdr.h:20
int main()
Definition simple.cpp:6
#define TEST(x)
Definition test.h:3
static char buffer[2048]
Definition test_printf.c:7