Branch Coverage

types.c
Criterion Covered Total %
branch 482 598 80.6


line true false branch
13 0 9871 if (!t) return;
14 2175 7696 if (t->inner) free_typeinfo(aTHX_ t->inner);
15 1097 8774 if (t->tuple) {
17 2171 1097 for (i = 0; i < t->tuple_len; i++) free_typeinfo(aTHX_ t->tuple[i]);
20 1017 8854 if (t->enum_entries) {
22 2036 1017 for (i = 0; i < t->enum_count; i++) Safefree(t->enum_entries[i].name);
25 1020 8851 if (t->enum_lookup) SvREFCNT_dec((SV*)t->enum_lookup);
26 17 9854 if (t->variant_decl_to_wire) Safefree(t->variant_decl_to_wire);
27 17 9854 if (t->variant_wire_to_decl) Safefree(t->variant_wire_to_decl);
28 41 9830 if (t->tuple_names) {
30 57 41 for (i = 0; i < t->tuple_len; i++)
31 57 0 if (t->tuple_names[i]) Safefree(t->tuple_names[i]);
39 1015 5 long min_val = (code == T_ENUM8) ? -128 : -32768;
40 1015 5 long max_val = (code == T_ENUM8) ? 127 : 32767;
46 2039 1017 while (i < len) {
47 4077 0 while (i < len && (s[i] == ' ' || s[i] == ',')) i++;
1019 3058 while (i < len && (s[i] == ' ' || s[i] == ',')) i++;
1019 2039 while (i < len && (s[i] == ' ' || s[i] == ',')) i++;
48 0 2039 if (i >= len) break;
50 0 2039 if (s[i] != '\'')
59 4147 0 while (i < len && s[i] != '\'') {
2108 2039 while (i < len && s[i] != '\'') {
60 1 2107 if (s[i] == '\\' && i + 1 < len) { i++; name_raw_len++; }
1 0 if (s[i] == '\\' && i + 1 < len) { i++; name_raw_len++; }
63 0 2039 if (i >= len)
72 2108 2039 while (j < i) {
73 1 2107 if (s[j] == '\\' && j + 1 < i) j++;
1 0 if (s[j] == '\\' && j + 1 < i) j++;
77 1 2038 if (name_len == 0) {
83 8152 0 while (i < len && (s[i] == ' ' || s[i] == '=')) i++;
4076 4076 while (i < len && (s[i] == ' ' || s[i] == '=')) i++;
2038 2038 while (i < len && (s[i] == ' ' || s[i] == '=')) i++;
86 2038 0 if (i < len && s[i] == '-') { neg = 1; i++; }
2 2036 if (i < len && s[i] == '-') { neg = 1; i++; }
87 2038 0 if (i >= len || s[i] < '0' || s[i] > '9') {
2038 0 if (i >= len || s[i] < '0' || s[i] > '9') {
0 2038 if (i >= len || s[i] < '0' || s[i] > '9') {
92 3082 1019 while (i < len && s[i] >= '0' && s[i] <= '9') {
2063 1019 while (i < len && s[i] >= '0' && s[i] <= '9') {
2063 0 while (i < len && s[i] >= '0' && s[i] <= '9') {
96 2 2036 if (neg) val = -val;
97 2038 0 if (val < min_val || val > max_val) {
2 2036 if (val < min_val || val > max_val) {
99 1 1 croak("Enum value %ld out of range for %s",
103 1017 1019 if (t->enum_count >= cap) {
104 0 1017 cap = cap ? cap * 2 : 8;
119 26 9866 if (*slot) free_typeinfo(aTHX_ *slot);
133 0 1097 if (s->types) {
135 0 0 for (i = 0; i < s->count; i++)
136 0 0 if (s->types[i]) free_typeinfo(aTHX_ s->types[i]);
163 25056 1063 for (i = 0; i <= len; i++) {
164 23993 1063 char c = (i < len) ? s[i] : ',';
165 1010 24046 if (c == '(') depth++;
166 1010 23036 else if (c == ')') depth--;
167 2128 20908 else if ((c == ',' && depth == 0) || i == len) {
1 2127 else if ((c == ',' && depth == 0) || i == len) {
0 20909 else if ((c == ',' && depth == 0) || i == len) {
170 3190 1 while (tstart < tend && IS_WS(s[tstart])) tstart++;
1064 2126 while (tstart < tend && IS_WS(s[tstart])) tstart++;
0 2126 while (tstart < tend && IS_WS(s[tstart])) tstart++;
0 2126 while (tstart < tend && IS_WS(s[tstart])) tstart++;
0 2126 while (tstart < tend && IS_WS(s[tstart])) tstart++;
171 2126 1 while (tend > tstart && IS_WS(s[tend-1])) tend--;
0 2126 while (tend > tstart && IS_WS(s[tend-1])) tend--;
0 2126 while (tend > tstart && IS_WS(s[tend-1])) tend--;
0 2126 while (tend > tstart && IS_WS(s[tend-1])) tend--;
0 2126 while (tend > tstart && IS_WS(s[tend-1])) tend--;
172 2126 1 if (tend > tstart) {
174 2126 0 if (id_end < tend
175 2126 0 && ((s[id_end] >= 'A' && s[id_end] <= 'Z')
12 2114 && ((s[id_end] >= 'A' && s[id_end] <= 'Z')
176 12 0 || (s[id_end] >= 'a' && s[id_end] <= 'z')
0 12 || (s[id_end] >= 'a' && s[id_end] <= 'z')
177 0 0 || s[id_end] == '_')) {
180 12591 1107 && ((s[id_end] >= 'A' && s[id_end] <= 'Z')
9444 3147 && ((s[id_end] >= 'A' && s[id_end] <= 'Z')
30 9414 && ((s[id_end] >= 'A' && s[id_end] <= 'Z')
181 9414 3147 || (s[id_end] >= 'a' && s[id_end] <= 'z')
9414 0 || (s[id_end] >= 'a' && s[id_end] <= 'z')
182 2128 1019 || (s[id_end] >= '0' && s[id_end] <= '9')
2128 0 || (s[id_end] >= '0' && s[id_end] <= '9')
183 0 1019 || s[id_end] == '_'))
185 1019 1107 if (id_end < tend && IS_WS(s[id_end])) {
1007 12 if (id_end < tend && IS_WS(s[id_end])) {
1007 0 if (id_end < tend && IS_WS(s[id_end])) {
1007 0 if (id_end < tend && IS_WS(s[id_end])) {
0 1007 if (id_end < tend && IS_WS(s[id_end])) {
189 24 0 while (ts < tend && IS_WS(s[ts])) ts++;
12 12 while (ts < tend && IS_WS(s[ts])) ts++;
0 12 while (ts < tend && IS_WS(s[ts])) ts++;
0 12 while (ts < tend && IS_WS(s[ts])) ts++;
0 12 while (ts < tend && IS_WS(s[ts])) ts++;
190 12 0 if (ts < tend) tstart = ts;
215 1097 0 if (n > 0) Newxz(slot->types, n, TypeInfo*);
218 2171 1097 for (i = 0; i < n; i++) {
231 0 24 Newx(bounds, len + 1, TypeBound);
256 12 6 for (i = 0; i < t->tuple_len; i++)
257 0 12 if (!type_can_be_typed_path(t->tuple[i]))
273 0 41 Newxz(bounds, body_len + 1, TypeBound);
279 773 38 for (i = 0; i <= body_len; i++) {
280 732 41 char c = (i < body_len) ? body[i] : ',';
281 16 757 if (c == '(') depth++;
282 16 741 else if (c == ')') depth--;
283 60 681 else if ((c == ',' && depth == 0) || i == body_len) {
8 52 else if ((c == ',' && depth == 0) || i == body_len) {
0 689 else if ((c == ',' && depth == 0) || i == body_len) {
286 61 2 while (ts < te && J_WS(body[ts])) ts++;
11 50 while (ts < te && J_WS(body[ts])) ts++;
0 50 while (ts < te && J_WS(body[ts])) ts++;
0 50 while (ts < te && J_WS(body[ts])) ts++;
0 50 while (ts < te && J_WS(body[ts])) ts++;
287 50 2 while (te > ts && J_WS(body[te-1])) te--;
0 50 while (te > ts && J_WS(body[te-1])) te--;
0 50 while (te > ts && J_WS(body[te-1])) te--;
0 50 while (te > ts && J_WS(body[te-1])) te--;
0 50 while (te > ts && J_WS(body[te-1])) te--;
288 50 2 if (te > ts) {
290 50 0 if (body[id] == '_'
291 50 0 || (body[id] >= 'A' && body[id] <= 'Z')
50 0 || (body[id] >= 'A' && body[id] <= 'Z')
292 50 0 || (body[id] >= 'a' && body[id] <= 'z')) {
50 0 || (body[id] >= 'a' && body[id] <= 'z')) {
295 185 1 && (body[id] == '_' || body[id] == '.'
0 185 && (body[id] == '_' || body[id] == '.'
7 178 && (body[id] == '_' || body[id] == '.'
296 129 49 || (body[id] >= 'A' && body[id] <= 'Z')
0 129 || (body[id] >= 'A' && body[id] <= 'Z')
297 129 49 || (body[id] >= 'a' && body[id] <= 'z')
129 0 || (body[id] >= 'a' && body[id] <= 'z')
298 0 49 || (body[id] >= '0' && body[id] <= '9')))
0 0 || (body[id] >= '0' && body[id] <= '9')))
301 0 50 if (id == ts)
308 1 49 if (body[id - 1] == '.')
313 134 48 for (dk = ts + 1; dk < id; dk++) {
314 6 128 if (body[dk] == '.' && body[dk - 1] == '.')
1 5 if (body[dk] == '.' && body[dk - 1] == '.')
320 94 1 while (ws < te && J_WS(body[ws])) ws++;
47 47 while (ws < te && J_WS(body[ws])) ws++;
0 47 while (ws < te && J_WS(body[ws])) ws++;
0 47 while (ws < te && J_WS(body[ws])) ws++;
0 47 while (ws < te && J_WS(body[ws])) ws++;
321 47 1 if (ws == id || ws == te)
0 47 if (ws == id || ws == te)
334 2 36 if (idx == 0) return;
338 11 36 for (ii = 1; ii < n; ii++) {
341 11 8 while (j >= 0) {
346 1 10 if (cmp == 0)
348 3 8 if (cmp <= 0) break;
355 11 35 for (ii = 1; ii < n; ii++) {
356 5 6 if (bounds[ii].name_len == bounds[ii-1].name_len
359 1 4 bounds[ii].name_len) == 0)
366 45 35 for (ii = 0; ii < n; ii++) {
374 45 29 for (ii = 0; ii < n; ii++) {
375 6 39 if (!type_can_be_typed_path(t->tuple[ii]))
393 449 9443 if (len == 4 && strncmp(type, "Int8", 4) == 0) {
12 437 if (len == 4 && strncmp(type, "Int8", 4) == 0) {
395 1544 8336 } else if (len == 5 && strncmp(type, "Int16", 5) == 0) {
10 1534 } else if (len == 5 && strncmp(type, "Int16", 5) == 0) {
397 1534 8336 } else if (len == 5 && strncmp(type, "Int32", 5) == 0) {
1484 50 } else if (len == 5 && strncmp(type, "Int32", 5) == 0) {
399 50 8336 } else if (len == 5 && strncmp(type, "Int64", 5) == 0) {
13 37 } else if (len == 5 && strncmp(type, "Int64", 5) == 0) {
401 37 8336 } else if (len == 5 && strncmp(type, "UInt8", 5) == 0) {
27 10 } else if (len == 5 && strncmp(type, "UInt8", 5) == 0) {
403 1775 6571 } else if (len == 6 && strncmp(type, "UInt16", 6) == 0) {
4 1771 } else if (len == 6 && strncmp(type, "UInt16", 6) == 0) {
405 1771 6571 } else if (len == 6 && strncmp(type, "UInt32", 6) == 0) {
129 1642 } else if (len == 6 && strncmp(type, "UInt32", 6) == 0) {
407 1642 6571 } else if (len == 6 && strncmp(type, "UInt64", 6) == 0) {
40 1602 } else if (len == 6 && strncmp(type, "UInt64", 6) == 0) {
409 381 7792 } else if (len == 7 && strncmp(type, "Float32", 7) == 0) {
11 370 } else if (len == 7 && strncmp(type, "Float32", 7) == 0) {
411 370 7792 } else if (len == 7 && strncmp(type, "Float64", 7) == 0) {
354 16 } else if (len == 7 && strncmp(type, "Float64", 7) == 0) {
413 362 7446 } else if (len == 8 && strncmp(type, "BFloat16", 8) == 0) {
9 353 } else if (len == 8 && strncmp(type, "BFloat16", 8) == 0) {
415 1602 6197 } else if (len == 6 && strncmp(type, "String", 6) == 0) {
1593 9 } else if (len == 6 && strncmp(type, "String", 6) == 0) {
417 4337 1869 } else if (len > 12 && strncmp(type, "FixedString(", 12) == 0) {
22 4315 } else if (len > 12 && strncmp(type, "FixedString(", 12) == 0) {
420 2 20 if (t->param <= 0) croak("FixedString needs positive length");
421 5728 456 } else if (len > 6 && strncmp(type, "Array(", 6) == 0) {
1069 4659 } else if (len > 6 && strncmp(type, "Array(", 6) == 0) {
424 4659 456 } else if (len > 6 && strncmp(type, "Tuple(", 6) == 0) {
1021 3638 } else if (len > 6 && strncmp(type, "Tuple(", 6) == 0) {
429 0 1021 Newx(bounds, body_len + 1, TypeBound);
439 2036 1015 for (j = 0; j < t->tuple_len; j++) {
440 6 2030 if (bounds[j].name_len > 0) { has_names = 1; break; }
442 6 1015 if (has_names) {
444 12 6 for (j = 0; j < t->tuple_len; j++) {
445 12 0 if (bounds[j].name_len > 0) {
455 3268 826 } else if (len > 9 && strncmp(type, "Nullable(", 9) == 0) {
1068 2200 } else if (len > 9 && strncmp(type, "Nullable(", 9) == 0) {
456 15 1053 if (len > 18 && strncmp(type + 9, "Nullable(", 9) == 0)
2 13 if (len > 18 && strncmp(type + 9, "Nullable(", 9) == 0)
460 2570 456 } else if (len > 6 && strncmp(type, "Enum8(", 6) == 0) {
1015 1555 } else if (len > 6 && strncmp(type, "Enum8(", 6) == 0) {
463 1539 472 } else if (len > 7 && strncmp(type, "Enum16(", 7) == 0) {
5 1534 } else if (len > 7 && strncmp(type, "Enum16(", 7) == 0) {
466 1177 829 } else if (len > 10 && strncmp(type, "Decimal32(", 10) == 0) {
9 1168 } else if (len > 10 && strncmp(type, "Decimal32(", 10) == 0) {
469 9 0 if (t->param < 0 || t->param > 9)
1 8 if (t->param < 0 || t->param > 9)
471 1168 829 } else if (len > 10 && strncmp(type, "Decimal64(", 10) == 0) {
1012 156 } else if (len > 10 && strncmp(type, "Decimal64(", 10) == 0) {
474 1012 0 if (t->param < 0 || t->param > 18)
0 1012 if (t->param < 0 || t->param > 18)
476 155 830 } else if (len > 11 && strncmp(type, "Decimal128(", 11) == 0) {
16 139 } else if (len > 11 && strncmp(type, "Decimal128(", 11) == 0) {
479 16 0 if (t->param < 0 || t->param > 38)
0 16 if (t->param < 0 || t->param > 38)
481 139 830 } else if (len > 11 && strncmp(type, "Decimal256(", 11) == 0) {
11 128 } else if (len > 11 && strncmp(type, "Decimal256(", 11) == 0) {
484 11 0 if (t->param < 0 || t->param > 76)
0 11 if (t->param < 0 || t->param > 76)
486 133 825 } else if (len > 8 && strncmp(type, "Decimal(", 8) == 0) {
2 131 } else if (len > 8 && strncmp(type, "Decimal(", 8) == 0) {
489 0 2 if (!comma) croak("Decimal(P, S) requires precision and scale");
491 1 1 if (precision < 1 || precision > 38)
0 1 if (precision < 1 || precision > 38)
493 1 0 if (scale < 0 || scale > precision)
0 1 if (scale < 0 || scale > precision)
496 1 0 if (precision <= 9) t->code = T_DECIMAL32;
497 0 0 else if (precision <= 18) t->code = T_DECIMAL64;
499 437 519 } else if (len == 4 && strncmp(type, "Date", 4) == 0) {
20 417 } else if (len == 4 && strncmp(type, "Date", 4) == 0) {
501 9 927 } else if (len == 6 && strncmp(type, "Date32", 6) == 0) {
7 2 } else if (len == 6 && strncmp(type, "Date32", 6) == 0) {
503 353 576 } else if (len == 8 && strncmp(type, "DateTime", 8) == 0) {
353 0 } else if (len == 8 && strncmp(type, "DateTime", 8) == 0) {
505 130 446 } else if (len > 9 && strncmp(type, "DateTime(", 9) == 0) {
1 129 } else if (len > 9 && strncmp(type, "DateTime(", 9) == 0) {
507 125 450 } else if (len > 11 && strncmp(type, "DateTime64(", 11) == 0) {
21 104 } else if (len > 11 && strncmp(type, "DateTime64(", 11) == 0) {
510 21 0 if (t->param < 0 || t->param > 9)
1 20 if (t->param < 0 || t->param > 9)
512 417 137 } else if (len == 4 && strncmp(type, "Bool", 4) == 0) {
313 104 } else if (len == 4 && strncmp(type, "Bool", 4) == 0) {
514 16 225 } else if (len == 7 && strncmp(type, "Boolean", 7) == 0) {
0 16 } else if (len == 7 && strncmp(type, "Boolean", 7) == 0) {
516 104 137 } else if (len == 4 && strncmp(type, "UUID", 4) == 0) {
12 92 } else if (len == 4 && strncmp(type, "UUID", 4) == 0) {
518 92 137 } else if (len == 4 && strncmp(type, "IPv4", 4) == 0) {
13 79 } else if (len == 4 && strncmp(type, "IPv4", 4) == 0) {
520 79 137 } else if (len == 4 && strncmp(type, "IPv6", 4) == 0) {
6 73 } else if (len == 4 && strncmp(type, "IPv6", 4) == 0) {
522 35 175 } else if (len > 24 && strncmp(type, "SimpleAggregateFunction(", 24) == 0) {
1 34 } else if (len > 24 && strncmp(type, "SimpleAggregateFunction(", 24) == 0) {
529 0 1 if (!comma) croak("SimpleAggregateFunction requires (func, T)");
531 2 0 while (inner_off < body_len && body[inner_off] == ' ') inner_off++;
1 1 while (inner_off < body_len && body[inner_off] == ' ') inner_off++;
538 108 101 } else if (len > 8 && strncmp(type, "Variant(", 8) == 0) {
18 90 } else if (len > 8 && strncmp(type, "Variant(", 8) == 0) {
553 0 18 Newx(bounds, body_len + 1, TypeBound);
556 1 17 if (t->tuple_len < 1)
558 0 17 if (t->tuple_len > 254)
567 36 17 for (j = 0; j < t->tuple_len; j++) t->variant_wire_to_decl[j] = j;
568 19 17 for (j = 0; j < t->tuple_len - 1; j++) {
570 21 19 for (k = j + 1; k < t->tuple_len; k++) {
577 17 4 if (cmp > 0 || (cmp == 0 && la > lb)) min_idx = k;
0 17 if (cmp > 0 || (cmp == 0 && la > lb)) min_idx = k;
0 0 if (cmp > 0 || (cmp == 0 && la > lb)) min_idx = k;
579 4 15 if (min_idx != j) {
585 36 17 for (j = 0; j < t->tuple_len; j++)
587 118 73 } else if (len > 4 && strncmp(type, "Map(", 4) == 0) {
14 104 } else if (len > 4 && strncmp(type, "Map(", 4) == 0) {
592 0 14 if (t->tuple_len != 2)
594 76 101 } else if (len > 7 && strncmp(type, "Nested(", 7) == 0) {
2 74 } else if (len > 7 && strncmp(type, "Nested(", 7) == 0) {
602 16 159 } else if (len == 7 && strncmp(type, "Dynamic", 7) == 0) {
12 4 } else if (len == 7 && strncmp(type, "Dynamic", 7) == 0) {
609 73 90 } else if ((len == 4 && strncmp(type, "JSON", 4) == 0)
3 70 } else if ((len == 4 && strncmp(type, "JSON", 4) == 0)
610 80 13 || (len > 5 && strncmp(type, "JSON(", 5) == 0
41 39 || (len > 5 && strncmp(type, "JSON(", 5) == 0
611 0 41 && type[len-1] == ')')
612 36 16 || (len > 7 && strncmp(type, "Object(", 7) == 0)) {
0 36 || (len > 7 && strncmp(type, "Object(", 7) == 0)) {
623 41 70 if (len > 5 && type[4] == '(') {
41 0 if (len > 5 && type[4] == '(') {
626 10 42 } else if (len == 5 && strncmp(type, "Point", 5) == 0) {
10 0 } else if (len == 5 && strncmp(type, "Point", 5) == 0) {
630 3 39 } else if (len == 4 && strncmp(type, "Ring", 4) == 0) {
3 0 } else if (len == 4 && strncmp(type, "Ring", 4) == 0) {
634 3 36 } else if (len == 10 && strncmp(type, "LineString", 10) == 0) {
2 1 } else if (len == 10 && strncmp(type, "LineString", 10) == 0) {
638 0 37 } else if (len == 15 && strncmp(type, "MultiLineString", 15) == 0) {
0 0 } else if (len == 15 && strncmp(type, "MultiLineString", 15) == 0) {
642 3 34 } else if (len == 7 && strncmp(type, "Polygon", 7) == 0) {
3 0 } else if (len == 7 && strncmp(type, "Polygon", 7) == 0) {
646 2 32 } else if (len == 12 && strncmp(type, "MultiPolygon", 12) == 0) {
2 0 } else if (len == 12 && strncmp(type, "MultiPolygon", 12) == 0) {
650 30 2 } else if (len > 15 && strncmp(type, "LowCardinality(", 15) == 0) {
30 0 } else if (len > 15 && strncmp(type, "LowCardinality(", 15) == 0) {
653 11 19 if (t->inner->code != T_STRING && t->inner->code != T_FIXEDSTRING
10 1 if (t->inner->code != T_STRING && t->inner->code != T_FIXEDSTRING
654 9 1 && (t->inner->code != T_NULLABLE
655 0 9 || (t->inner->inner->code != T_STRING
656 0 0 && t->inner->inner->code != T_FIXEDSTRING)))