#include #include #include #include #include #include #include #include struct buffer_in_the_middle { //# encoder char a[8]; //#1 char b[8]; //#2 char c[8]; //#3 char d[8]; //#5 int e; // #6 uint64_t f; //#7 uint64_t g; //#8 uint8_t *h; //#10 num_at=h_size int h_size; uint8_t buffer[256]; //# buffer=here char i[32]; //#11 char j[8]; //#12 int k; //#15 int l; //#16 }; #include "test_printer_buffer_in_the_middle.pb.h" void test_printer_buffer_in_the_middle(void **state) { struct buffer_in_the_middle m; char buf[256]; uint8_t bytes[3] = {0, 1, 2}; (void)state; memset(&m, 0, sizeof(m)); strcpy(m.a, "a"); strcpy(m.b, "b"); strcpy(m.c, "c"); strcpy(m.d, "d"); m.e = 1; m.f = 2; m.g = 3; m.h = bytes; m.h_size = sizeof(bytes); strcpy(m.i, "i"); strcpy(m.j, "j"); m.k = 4; m.l = 5; assert_non_null(pb_seprint_buffer_in_the_middle(&m, buf, buf+sizeof(buf), 0, 1)); assert_string_equal( buf, "{\n" " a = \"a\", // #1\n" " b = \"b\", // #2\n" " c = \"c\", // #3\n" " d = \"d\", // #5\n" " e = 1, // #6\n" " f = 2, // #7\n" " g = 3, // #8\n" " h = 0x000102 (3 bytes), // #10\n" " i = \"i\", // #11\n" " j = \"j\", // #12\n" " k = 4, // #15\n" " l = 5, // #16\n" "}" ); }