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

          Line data    Source code
       1             : #include <stdio.h>
       2             : #include <stdlib.h>
       3             : #include <string.h>
       4             : #include <pb_encode.h>
       5             : #include <pb_decode.h>
       6             : #include "test.pb.h"
       7             : #include "unittests.h"
       8             : 
       9           1 : int main(int argc, char **argv)
      10             : {
      11           1 :     int status = 0;
      12           1 :     uint8_t buffer[512] = {0};
      13             :     int i;
      14             :     pb_ostream_t ostream;
      15             :     
      16           1 :     Reply reply = Reply_init_zero;
      17           1 :     Reply_Result request_result = Reply_Result_OK;
      18             : 
      19           1 :     ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
      20           1 :     reply.result = request_result;
      21           1 :     if (!pb_encode(&ostream, Reply_fields, &reply)) {
      22           0 :         fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&ostream));
      23           0 :         return 1;
      24             :     }
      25             : 
      26           1 :     printf("response payload (%d):", (int)ostream.bytes_written);
      27           3 :     for (i = 0; i < ostream.bytes_written; i++) {
      28           2 :         printf("%02X", buffer[i]);
      29             :     }
      30           1 :     printf("\n");
      31             : 
      32           1 :     TEST(ostream.bytes_written == 2);
      33           1 :     TEST(buffer[0] == 0x08);
      34           1 :     TEST(buffer[1] == 0x01);
      35             :     
      36           1 :     return status;
      37             : }
      38             : 

Generated by: LCOV version 1.14