LCOV - code coverage report
Current view: top level - t - test_msgs.c (source / functions) Hit Total Coverage
Test: PB-C-TEXT Code Coverage Lines: 22 24 91.7 %
Date: 2014-09-08 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include <sys/types.h>
       2             : #include <sys/stat.h>
       3             : #include <unistd.h>
       4             : #include <stdio.h>
       5             : #include <string.h>
       6             : #include <stdlib.h>
       7             : #include <protobuf-c/protobuf-c.h>
       8             : #include "protobuf-c-text/protobuf-c-text.h"
       9             : #include "addressbook.pb-c.h"
      10             : #include "broken-alloc.h"
      11             : 
      12             : #include <check.h>
      13             : 
      14           1 : START_TEST(test_deep_nesting)
      15             : {
      16             :   ProtobufCTextError tf_res;
      17             :   Tutorial__Recurse *msg;
      18             :   
      19           1 :   msg = (Tutorial__Recurse *)protobuf_c_text_from_string(
      20             :       &tutorial__recurse__descriptor,
      21             :       "id: 1 m {\n"
      22             :       " id: 2 m {\n"
      23             :       "  id: 3 m {\n"
      24             :       "   id: 4 m {\n"
      25             :       "    id: 5 m {\n"
      26             :       "     id: 6 m {\n"
      27             :       "      id: 7 m {\n"
      28             :       "       id: 8 m {\n"
      29             :       "        id: 9 m {\n"
      30             :       "         id: 10 m {\n"
      31             :       "          id: 11 m {\n"
      32             :       "           id: 12 m {\n"
      33             :       "            id: 13 m {\n"
      34             :       "             id: 14 m {\n"
      35             :       "              id: 15 m {\n"
      36             :       "               id: 16\n"
      37             :       "              }\n"
      38             :       "             }\n"
      39             :       "            }\n"
      40             :       "           }\n"
      41             :       "          }\n"
      42             :       "         }\n"
      43             :       "        }\n"
      44             :       "       }\n"
      45             :       "      }\n"
      46             :       "     }\n"
      47             :       "    }\n"
      48             :       "   }\n"
      49             :       "  }\n"
      50             :       " }\n"
      51             :       "}\n",
      52             :       &tf_res, NULL);
      53             : 
      54           1 :   if (tf_res.error_txt != NULL) {
      55           0 :     ck_assert_msg(strlen(tf_res.error_txt) == 0,
      56             :         "There was an unexpected error: [%d]\"%s\"",
      57             :         strlen(tf_res.error_txt), tf_res.error_txt);
      58             :   }
      59           1 :   ck_assert_int_eq(tf_res.complete, 1);
      60           1 :   ck_assert_msg(msg != NULL, "Unexpected malloc failure.");
      61           1 :   tutorial__recurse__free_unpacked(msg, NULL);
      62             : }
      63           1 : END_TEST
      64             : 
      65             : Suite *
      66           2 : suite_odd_messages(void)
      67             : {
      68           2 :   Suite *s = suite_create("Protobuf C Text Format - Parsing");
      69           2 :   TCase *tc = tcase_create("Odd messages");
      70             : 
      71             :   /* Tests for odd messages. */
      72           2 :   tcase_add_test(tc, test_deep_nesting);
      73           2 :   suite_add_tcase(s, tc);
      74             : 
      75           2 :   return s;
      76             : }
      77             : 
      78             : int
      79           2 : main(int argc, char *argv[])
      80             : {
      81           2 :   int number_failed, exit_code = EXIT_SUCCESS;
      82           2 :   Suite *s_odd = suite_odd_messages();
      83           2 :   SRunner *sr_odd = srunner_create(s_odd);
      84             : 
      85             :   /* Run odd message tests. */
      86           2 :   srunner_run_all(sr_odd, CK_NORMAL);
      87           1 :   number_failed = srunner_ntests_failed(sr_odd);
      88           1 :   srunner_free(sr_odd);
      89             : 
      90           1 :   if (number_failed > 0)
      91           0 :     exit_code = EXIT_FAILURE;
      92           1 :   return exit_code;
      93             : }

Generated by: LCOV version 1.10