File Coverage

tstr_param.h
Criterion Covered Total %
statement 16 19 84.2
branch 7 10 70.0
condition n/a
subroutine n/a
pod n/a
total 23 29 79.3


line stmt bran cond sub pod time code
1             #ifndef TSTR_PARAM_H
2             #define TSTR_PARAM_H
3              
4             #include
5             #include
6              
7             typedef enum {
8             TSTR_PARAM_UNKNOWN = 0,
9             TSTR_PARAM_FORMAT,
10             TSTR_PARAM_PRECISION,
11             TSTR_PARAM_NANOSECOND,
12             TSTR_PARAM_OFFSET,
13             TSTR_PARAM_PIVOT_YEAR,
14             } tstr_param_t;
15              
16 1256           static inline tstr_param_t tstr_param_from_string(const char* src, size_t len) {
17 1256           switch (len) {
18 1111           case 6:
19 1111 100         if (!memcmp(src, "format", 6))
20 1074           return TSTR_PARAM_FORMAT;
21 37 50         if (!memcmp(src, "offset", 6))
22 37           return TSTR_PARAM_OFFSET;
23 0           break;
24 109           case 9:
25 109 50         if (!memcmp(src, "precision", 9))
26 109           return TSTR_PARAM_PRECISION;
27 0           break;
28 34           case 10:
29 34 100         if (!memcmp(src, "nanosecond", 10))
30 26           return TSTR_PARAM_NANOSECOND;
31 8 50         if (!memcmp(src, "pivot_year", 10))
32 8           return TSTR_PARAM_PIVOT_YEAR;
33 0           break;
34             }
35 2           return TSTR_PARAM_UNKNOWN;
36             }
37              
38             #endif /* TSTR_PARAM_H */