core/weather/wx_label.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file wx_label.c | ||
| 3 | * @brief The short word a small slot shows for the sky. | ||
| 4 | * | ||
| 5 | * @ingroup lib_core | ||
| 6 | */ | ||
| 7 | #include "weather/wx_label.h" | ||
| 8 | |||
| 9 | #include <string.h> | ||
| 10 | |||
| 11 | #include "weather/wx_cond.g.h" | ||
| 12 | |||
| 13 | 5 | void wx_label_short(char *out, size_t n, const char *condition) | |
| 14 | { | ||
| 15 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 5 times.
|
5 | if (n == 0) |
| 16 | { | ||
| 17 | ✗ | return; | |
| 18 | } | ||
| 19 | |||
| 20 |
3/4✓ Branch 4 → 5 taken 4 times.
✓ Branch 4 → 6 taken 1 time.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 4 times.
|
5 | if (!condition || !condition[0]) |
| 21 | { | ||
| 22 | 1 | condition = "UNKNOWN"; | |
| 23 | } | ||
| 24 | |||
| 25 | 5 | size_t len = strlen(condition); | |
| 26 |
4/4✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 10 taken 2 times.
✓ Branch 8 → 9 taken 2 times.
✓ Branch 8 → 10 taken 1 time.
|
5 | if (len > WX_COND_NIGHT_LEN && !strcmp(condition + len - WX_COND_NIGHT_LEN, WX_COND_NIGHT_ENDING)) |
| 27 | { | ||
| 28 | 2 | len -= WX_COND_NIGHT_LEN; | |
| 29 | } | ||
| 30 |
2/2✓ Branch 10 → 11 taken 1 time.
✓ Branch 10 → 12 taken 4 times.
|
5 | if (len >= n) |
| 31 | { | ||
| 32 | 1 | len = n - 1; | |
| 33 | } | ||
| 34 | |||
| 35 | 5 | memcpy(out, condition, len); | |
| 36 | 5 | out[len] = '\0'; | |
| 37 | } | ||
| 38 |