1 #include <unittests.h> 2 #include <pb_encode.h> 3 #include "short_array.pb.h" 4 main()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 25