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

          Line data    Source code
       1             : #include "defaults.pb.h"
       2             : #include <unittests.h>
       3             : #include <pb_decode.h>
       4             : 
       5           2 : int check_defaults(const DefaultsMsg *msg)
       6             : {
       7           2 :     int status = 0;
       8             :     
       9           2 :     TEST(msg->b1[0] == 0xDE && msg->b1[1] == 0xAD && msg->b1[2] == 0x00 &&
      10             :          msg->b1[3] == 0xBE && msg->b1[4] == 0xEF);
      11           2 :     TEST(msg->b2.bytes[0] == 0xDE && msg->b2.bytes[1] == 0xAD &&
      12             :          msg->b2.bytes[2] == 0x00 && msg->b2.bytes[3] == 0xBE &&
      13             :          msg->b2.bytes[4] == 0xEF && msg->b2.size == 5);
      14           2 :     TEST(msg->b3.bytes[0] == 0xDE && msg->b3.bytes[1] == 0xAD &&
      15             :          msg->b3.bytes[2] == 0x00 && msg->b3.bytes[3] == 0xBE &&
      16             :          msg->b3.bytes[4] == 0xEF && msg->b2.size == 5);
      17           2 :     TEST(msg->s1[0] == (char)0xC3 && msg->s1[1] == (char)0xA4 &&
      18             :          msg->s1[2] == (char)0xC3 && msg->s1[3] == (char)0xB6 &&
      19             :          msg->s1[4] == '\0');
      20             :     
      21           2 :     return status;
      22             : }
      23             : 
      24           1 : int main()
      25             : {
      26           1 :     int status = 0;
      27             :     
      28             :     {
      29           1 :         DefaultsMsg msg = DefaultsMsg_init_default;
      30           1 :         COMMENT("Checking defaults from static initializer");
      31           1 :         status += check_defaults(&msg);
      32             :     }
      33             : 
      34             :     {
      35           1 :         DefaultsMsg msg = DefaultsMsg_init_zero;
      36           1 :         pb_istream_t empty = {0,0,0};
      37           1 :         pb_decode(&empty, DefaultsMsg_fields, &msg);
      38           1 :         COMMENT("Checking defaults set at runtime");
      39           1 :         status += check_defaults(&msg);
      40             :     }
      41             : 
      42           1 :     return status;
      43             : }
      44             : 

Generated by: LCOV version 1.14