Branch Coverage

src/pdfmake_tag.c
Criterion Covered Total %
branch 53 128 41.4


line true false branch
27 0 11 if (type < 0 || type >= PDFMAKE_TAG_COUNT) return "Div";
33 0 5 if (!name) return -1;
34 80 0 for (i = 0; i < PDFMAKE_TAG_COUNT; i++) {
35 5 75 if (strcmp(name, _struct_type_names[i]) == 0) return i;
45 0 167 if (!doc) return NULL;
48 2 165 if (doc->struct_tree) return (pdfmake_struct_tree_t *)doc->struct_tree;
51 0 165 if (!tree) return NULL;
55 0 165 if (!tree->root) { free(tree); return NULL; }
63 0 0 return doc ? (pdfmake_struct_tree_t *)doc->struct_tree : NULL;
79 0 5 if (!elem) return NULL;
85 5 0 if (parent) {
86 2 3 if (parent->child_count >= parent->child_cap) {
87 0 2 new_cap = parent->child_cap == 0 ? 8 : parent->child_cap * 2;
90 0 2 if (!new_arr) { free(elem); return NULL; }
106 0 0 if (elem && custom_type) {
0 0 if (elem && custom_type) {
113 1 0 if (!elem || !alt) return PDFMAKE_EINVAL;
0 1 if (!elem || !alt) return PDFMAKE_EINVAL;
119 0 0 if (!elem || !text) return PDFMAKE_EINVAL;
0 0 if (!elem || !text) return PDFMAKE_EINVAL;
125 1 0 if (!elem || !lang) return PDFMAKE_EINVAL;
0 1 if (!elem || !lang) return PDFMAKE_EINVAL;
131 0 0 return elem ? elem->child_count : 0;
135 0 0 if (!elem || idx >= elem->child_count) return NULL;
0 0 if (!elem || idx >= elem->child_count) return NULL;
147 0 0 if (!elem) return PDFMAKE_EINVAL;
148 0 0 if (elem->mcr_count >= elem->mcr_cap) {
149 0 0 new_cap = elem->mcr_cap == 0 ? 4 : elem->mcr_cap * 2;
151 0 0 if (!new_arr) return PDFMAKE_ENOMEM;
172 0 0 if (!c) return PDFMAKE_EINVAL;
189 0 0 if (!c) return PDFMAKE_EINVAL;
203 0 0 if (!tree || !custom) return PDFMAKE_EINVAL;
0 0 if (!tree || !custom) return PDFMAKE_EINVAL;
204 0 0 if (tree->role_map_count >= tree->role_map_cap) {
205 0 0 new_cap = tree->role_map_cap == 0 ? 4 : tree->role_map_cap * 2;
207 0 0 if (!new_arr) return PDFMAKE_ENOMEM;
236 7 0 if (!elem || !doc) return 0;
0 7 if (!elem || !doc) return 0;
246 0 7 : pdfmake_struct_type_name(elem->type);
250 5 2 if (parent_num > 0) {
256 1 6 if (elem->alt_text[0]) {
260 0 7 if (elem->actual_text[0]) {
264 1 6 if (elem->lang[0]) {
271 0 7 if (elem->obj_num == 0) return 0;
274 7 0 if (elem->mcr_count > 0 || elem->child_count > 0) {
2 5 if (elem->mcr_count > 0 || elem->child_count > 0) {
278 0 2 for (i_mcr = 0; i_mcr < elem->mcr_count; i_mcr++) {
292 5 2 for (i_child = 0; i_child < elem->child_count; i_child++) {
294 5 0 if (child_num > 0) {
301 2 0 if (elem_obj && elem_obj->kind == PDFMAKE_DICT) {
2 0 if (elem_obj && elem_obj->kind == PDFMAKE_DICT) {
324 0 163 if (!doc) return PDFMAKE_EINVAL;
327 163 0 if (!tree || !tree->root) return PDFMAKE_OK; /* No tree */
0 163 if (!tree || !tree->root) return PDFMAKE_OK; /* No tree */
328 161 2 if (tree->root->child_count == 0 && tree->root->mcr_count == 0)
161 0 if (tree->root->child_count == 0 && tree->root->mcr_count == 0)
335 0 2 if (root_elem_num == 0) return PDFMAKE_ENOMEM;
346 0 2 if (tree->role_map_count > 0) {
348 0 0 for (i = 0; i < tree->role_map_count; i++) {
359 0 2 if (tree->obj_num == 0) return PDFMAKE_ENOMEM;
363 2 0 if (root_obj && root_obj->kind == PDFMAKE_DICT) {
2 0 if (root_obj && root_obj->kind == PDFMAKE_DICT) {
370 2 0 if (catalog && catalog->kind == PDFMAKE_DICT) {
2 0 if (catalog && catalog->kind == PDFMAKE_DICT) {