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

          Line data    Source code
       1             : #include <pb_encode.h>
       2             : #include <unittests.h>
       3             : #include <string.h>
       4             : #include "padding.pb.h"
       5             : 
       6           1 : int main()
       7             : {
       8           1 :     int status = 0;
       9             :     
      10             :     TestMessage msg;
      11             :     
      12             :     /* Set padding bytes to garbage */
      13           1 :     memset(&msg, 0xAA, sizeof(msg));
      14             :     
      15             :     /* Set all meaningful fields to 0 */
      16           1 :     msg.submsg.boolfield = false;
      17           1 :     msg.submsg.intfield = 0;
      18             :     
      19             :     /* Test encoding */
      20             :     {
      21           1 :         pb_byte_t buf[128] = {0};
      22           1 :         pb_ostream_t stream = pb_ostream_from_buffer(buf, sizeof(buf));
      23           1 :         TEST(pb_encode(&stream, TestMessage_fields, &msg));
      24             :         
      25             :         /* Because all fields have zero values, proto3 encoder
      26             :          * shouldn't write out anything. */
      27           1 :         TEST(stream.bytes_written == 0);
      28             :     }
      29             :     
      30           1 :     return status;
      31             : }
      32             : 

Generated by: LCOV version 1.14