LCOV - code coverage report
Current view: top level - regression/issue_256 - submsg_array.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 20 100.0 %
Date: 2023-02-14 20:10:26 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include <unittests.h>
       2             : #include <pb_encode.h>
       3             : #include <pb_decode.h>
       4             : #include "submsg_array.pb.h"
       5             : 
       6           1 : int main()
       7             : {
       8           1 :     int status = 0;
       9             :     
      10           1 :     COMMENT("Test encoding for submessage with array");
      11             :     {
      12           1 :         uint8_t buffer[TestMessage_size] = {0};
      13           1 :         pb_ostream_t ostream = pb_ostream_from_buffer(buffer, TestMessage_size);
      14           1 :         TestMessage msg = TestMessage_init_zero;
      15             :         
      16           1 :         msg.submsg.rep_uint32_count = 3;
      17           1 :         msg.submsg.rep_uint32[0] = 0;
      18           1 :         msg.submsg.rep_uint32[1] = 1;
      19           1 :         msg.submsg.rep_uint32[2] = 2;
      20             :         
      21           1 :         TEST(pb_encode(&ostream, TestMessage_fields, &msg));
      22           1 :         TEST(ostream.bytes_written > 0);
      23             :         
      24             :         {
      25           1 :             pb_istream_t istream = pb_istream_from_buffer(buffer, ostream.bytes_written);
      26           1 :             TestMessage msg2 = TestMessage_init_zero;
      27             : 
      28           1 :             TEST(pb_decode(&istream, TestMessage_fields, &msg2));
      29           1 :             TEST(msg2.submsg.rep_uint32_count == 3);
      30           1 :             TEST(msg2.submsg.rep_uint32[0] == 0);
      31           1 :             TEST(msg2.submsg.rep_uint32[1] == 1);
      32           1 :             TEST(msg2.submsg.rep_uint32[2] == 2);
      33             :         }
      34             :     }
      35             :     
      36           1 :     return status;
      37             : }
      38             : 

Generated by: LCOV version 1.14