MOS Source Code
Loading...
Searching...
No Matches
pio_with_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_with_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 TestMessageWithOptions original = TestMessageWithOptions_init_zero;
18 strcpy(original.str,"Hello");
19
20 ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
21
22 TEST(pb_encode(&ostream, &TestMessageWithOptions_msg, &original));
23
24 written = ostream.bytes_written;
25
26 istream = pb_istream_from_buffer(buffer, written);
27
28 TestMessageWithOptions decoded = TestMessageWithOptions_init_zero;
29
30 TEST(pb_decode(&istream, &TestMessageWithOptions_msg, &decoded));
31
32 TEST(strcmp(decoded.str,"Hello") == 0);
33
34 return status;
35}
MOSAPI char * strcpy(char *__restrict dest, const char *__restrict src)
Definition mos_string.c:184
MOSAPI s32 strcmp(const char *str1, const char *str2)
Definition mos_string.c:24
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