MOS Source Code
Loading...
Searching...
No Matches
short_array.c
Go to the documentation of this file.
1#include <unittests.h>
2#include <pb_encode.h>
3#include "short_array.pb.h"
4
5int main()
6{
7 int status = 0;
8
9 COMMENT("Test message length calculation for short arrays");
10 {
11 uint8_t buffer[TestMessage_size] = {0};
12 pb_ostream_t ostream = pb_ostream_from_buffer(buffer, TestMessage_size);
13 TestMessage msg = TestMessage_init_zero;
14
15 msg.rep_uint32_count = 1;
16 msg.rep_uint32[0] = ((uint32_t)1 << 31);
17
18 TEST(pb_encode(&ostream, TestMessage_fields, &msg));
19 TEST(ostream.bytes_written == TestMessage_size);
20 }
21
22 return status;
23}
24
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 int uint32_t
Definition pb_syshdr.h:24
unsigned char uint8_t
Definition pb_syshdr.h:20
int main()
Definition short_array.c:5
#define TEST(x)
Definition test.h:3
static char buffer[2048]
Definition test_printf.c:7
#define COMMENT(x)
Definition unittests.h:17