123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #include <check.h>
- #include <stdio.h>
-
- #include "ttail_check.h"
- #include "ttail.h"
- #include "ttail_init.h"
- #include "ttail_search.h"
-
- #define TTAIL_TM_CMP_INIT \
- struct tm a, b;\
- int ret;\
- ttail_tm_init(&a);\
- ttail_tm_init(&b);\
-
- START_TEST (test_tm_cmp_init)
- {
- TTAIL_TM_CMP_INIT
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_eq(ret, 0);
- }
- END_TEST
-
- START_TEST (test_tm_cmp_field_priority)
- {
- TTAIL_TM_CMP_INIT
- a.tm_sec = 42;
- b.tm_sec = 41;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_gt(ret, 0);
- a.tm_min = 41;
- b.tm_min = 42;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_lt(ret, 0);
- a.tm_hour = 42;
- b.tm_hour = 41;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_gt(ret, 0);
- a.tm_mday = 21;
- b.tm_mday = 22;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_lt(ret, 0);
- a.tm_mon = 10;
- b.tm_mon = 9;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_gt(ret, 0);
- a.tm_year = 14;
- b.tm_year = 15;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_lt(ret, 0);
- }
- END_TEST
-
- START_TEST (test_tm_cmp_empty_fields1)
- {
- TTAIL_TM_CMP_INIT
- a.tm_sec = 42;
- b.tm_min = 41;
- a.tm_hour = 1;
- b.tm_hour = 1;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_eq(ret, 0);
- }
- END_TEST
-
- START_TEST (test_tm_cmp_empty_fields2)
- {
- TTAIL_TM_CMP_INIT
- a.tm_sec = 42;
- b.tm_min = 41;
- b.tm_hour = 1;
- b.tm_mday = 6;
- b.tm_mon = 7;
- b.tm_year = 15;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_eq(ret, 0);
- }
- END_TEST
-
- START_TEST (test_tm_cmp_empty_fields3)
- {
- TTAIL_TM_CMP_INIT
- a.tm_sec = 42;
- b.tm_sec = 55;
- b.tm_min = 41;
- b.tm_hour = 1;
- b.tm_mday = 6;
- b.tm_mon = 7;
- b.tm_year = 15;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_lt(ret, 0);
- }
- END_TEST
-
- START_TEST (test_tm_cmp_empty_fields4)
- {
- TTAIL_TM_CMP_INIT
- b.tm_sec = 42;
- a.tm_min = 41;
- a.tm_hour = 1;
- a.tm_mday = 6;
- a.tm_mon = 7;
- a.tm_year = 15;
- ret = ttail_tm_cmp(&a, &b);
- ck_assert_int_eq(ret, 0);
- }
- END_TEST
-
- TTAIL_CHECK_START("ttail search functions checks", "ttail_tm_cmp() checks")
- TTAIL_ADD_TEST(test_tm_cmp_init);
- TTAIL_ADD_TEST(test_tm_cmp_field_priority);
- TTAIL_ADD_TEST(test_tm_cmp_empty_fields1);
- TTAIL_ADD_TEST(test_tm_cmp_empty_fields2);
- TTAIL_ADD_TEST(test_tm_cmp_empty_fields3);
- TTAIL_ADD_TEST(test_tm_cmp_empty_fields4);
- TTAIL_CHECK_END
|