add timespec_clear_spec() and timespec_get_spec()
This commit is contained in:
@ -88,8 +88,12 @@ static void test_timespec_flips_and_seconds(const struct mgos_timespec *ts, cons
|
||||
static void test_timespec_state(void) {
|
||||
struct mgos_timespec *ts = timespec_create();
|
||||
struct tm target;
|
||||
char buf[500];
|
||||
|
||||
ASSERT(ts, "Created timespec");
|
||||
timespec_get_spec(ts, buf, sizeof(buf)-1);
|
||||
ASSERT(0 == strcmp(buf, ""), "timespec_get_spec() didn't match input spec(s)");
|
||||
|
||||
ASSERT(timespec_add_spec(ts, "08-10"), "Added timespec");
|
||||
ASSERT(timespec_add_spec(ts, "12:00-13:00"), "Added timespec");
|
||||
ASSERT(timespec_add_spec(ts, "14:11:05-14:59:52"), "Added timespec");
|
||||
@ -150,6 +154,11 @@ static void test_timespec_state(void) {
|
||||
target.tm_sec = 3; target.tm_min = 2; target.tm_hour = 1;
|
||||
ASSERT(!timespec_match(ts, &target), "No match at 01:02:03");
|
||||
|
||||
// Test timespec retrieval
|
||||
timespec_get_spec(ts, buf, sizeof(buf)-1);
|
||||
ASSERT(0 == strcmp(buf, "23:01:02-01:02:03,14:11:05-14:59:52,12:00:00-13:00:00,08:00:00-10:00:00"), "timespec_get_spec() didn't match input spec(s)");
|
||||
LOG(LL_INFO, ("Spec: '%s'", buf));
|
||||
|
||||
ASSERT(timespec_destroy(&ts), "Destroyed timespec");
|
||||
|
||||
// Some time counting tests
|
||||
@ -174,6 +183,10 @@ static void test_timespec_state(void) {
|
||||
ASSERT(timespec_add_spec(ts, "03:02:03-04:03:04"), "Added timespec");
|
||||
test_timespec_flips_and_seconds(ts, 9, 7200 + 0 + 7200 + 1 + 3661);
|
||||
|
||||
// Test timespec retrieval
|
||||
timespec_get_spec(ts, buf, sizeof(buf)-1);
|
||||
ASSERT(0 == strcmp(buf, "03:02:03-04:03:04,02:00:00-02:00:01,23:00:00-01:00:00,00:00:00-00:00:00,08:00:00-10:00:00"), "timespec_get_spec() didn't match input spec(s)");
|
||||
|
||||
ASSERT(timespec_destroy(&ts), "Destroyed timespec");
|
||||
|
||||
// Some other time counting tests
|
||||
@ -184,6 +197,10 @@ static void test_timespec_state(void) {
|
||||
ASSERT(timespec_add_spec(ts, "12-00"), "Added timespec");
|
||||
test_timespec_flips_and_seconds(ts, 1, 24 * 60 * 60);
|
||||
|
||||
// Test timespec retrieval
|
||||
timespec_get_spec(ts, buf, sizeof(buf)-1);
|
||||
ASSERT(0 == strcmp(buf, "12:00:00-00:00:00,00:00:00-12:00:00"), "timespec_get_spec() didn't match input spec(s)");
|
||||
|
||||
ASSERT(timespec_destroy(&ts), "Destroyed timespec");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user