| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gate/tests.h" | ||
| 2 | #include "test_times.h" | ||
| 3 | #include "gate/times.h" | ||
| 4 | |||
| 5 | 1 | GATE_TEST_FUNCTION(test_times) | |
| 6 | { | ||
| 7 | gate_datetime_t dt, dt2; | ||
| 8 | gate_time_t tm, tm2; | ||
| 9 | gate_day_id_t did, did2; | ||
| 10 | gate_result_t res; | ||
| 11 | char buffer[1024]; | ||
| 12 | 1 | gate_size_t buffer_len = sizeof(buffer); | |
| 13 | |||
| 14 | 1 | GATE_TEST_UNIT_BEGIN(test_times); | |
| 15 | |||
| 16 | 1 | gate_mem_clear(&dt, sizeof(dt)); | |
| 17 | 1 | gate_mem_clear(&dt2, sizeof(dt2)); | |
| 18 | 1 | gate_mem_clear(&tm, sizeof(tm)); | |
| 19 | 1 | gate_mem_clear(&tm2, sizeof(tm2)); | |
| 20 | |||
| 21 | 1 | dt.date.year = 2018; | |
| 22 | 1 | dt.date.month = 10; | |
| 23 | 1 | dt.date.day = 1; | |
| 24 | 1 | dt.time.hour = 12; | |
| 25 | 1 | dt.time.minute = 30; | |
| 26 | 1 | dt.time.second = 45; | |
| 27 | 1 | dt.time.microsecond = 500000; | |
| 28 | |||
| 29 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_time(&dt, &tm)); |
| 30 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_time_to_datetime(&tm, &dt2)); |
| 31 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_mem_compare(&dt, &dt2, sizeof(dt)) == 0); |
| 32 | |||
| 33 | 1 | did = gate_date_to_day_id(&dt.date); | |
| 34 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK(did != 0); |
| 35 | |||
| 36 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_from_day_id(did, &dt2.date)); |
| 37 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_mem_compare(&dt.date, &dt2.date, sizeof(gate_date_t)) == 0); |
| 38 | 1 | gate_date_day_of_week(did); | |
| 39 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_date_day_of_year(&dt.date) > 0); |
| 40 | |||
| 41 | 1 | gate_date_week_of_year(&dt.date, true); | |
| 42 | 1 | gate_date_week_of_year(&dt.date, false); | |
| 43 | |||
| 44 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_time(&dt, &tm)); |
| 45 | 1 | did2 = gate_time_to_day_id(tm.timestamp); | |
| 46 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(did, did2); |
| 47 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_time_from_day_id(did, &tm2.timestamp)); |
| 48 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK(tm.timestamp > tm2.timestamp); |
| 49 | |||
| 50 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, NULL, buffer, &buffer_len)); |
| 51 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, "{YYYY}-{MNA}-{D} {k}:{m}:{s}.{S} {ampm} / {bias}", buffer, &buffer_len)); |
| 52 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, "{YY}-{MN}-{DD} {kk}:{mm}:{ss}.{SS} {ampm} / {bias}", buffer, &buffer_len)); |
| 53 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, "{YYYY}-{M}-{D} {h}:{m}:{s}.{SSSS}", buffer, &buffer_len)); |
| 54 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, "{YYYY}-{MM}-{DD} {hh}:{mm}:{ss}.{SSSSS}", buffer, &buffer_len)); |
| 55 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_date_to_string(&dt, 60, "{YYYY}-{MM}-{DD} {hh}:{mm}:{ss}.{SSSSSS}", buffer, &buffer_len)); |
| 56 | |||
| 57 | 1 | GATE_TEST_UNIT_END; | |
| 58 | } | ||
| 59 |