| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#include <stdlib.h> |
| 34 |
#include <check.h> |
| 35 |
#include <global.h> |
| 36 |
#include <libproto.h> |
| 37 |
#include "tod.h" |
| 38 |
|
| 39 |
static void setup(void) { |
| 40 |
reset_sleep(); |
| 41 |
} |
| 42 |
|
| 43 |
static void teardown(void) { |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
START_TEST(test_get_month_name) { |
| 48 |
fail_unless(get_month_name(-1) == NULL, "getting month name for negative value should bring a NULL"); |
| 49 |
fail_unless(get_month_name(MONTHS_PER_YEAR) == NULL, "getting month name for too high value should bring a NULL"); |
| 50 |
fail_unless(get_month_name(0) != NULL, "getting month name for correct value should bring a non NULL season name"); |
| 51 |
} |
| 52 |
END_TEST |
| 53 |
|
| 54 |
START_TEST(test_get_weekday) { |
| 55 |
fail_unless(get_weekday(-1) == NULL, "getting week day name for negative value should bring a NULL"); |
| 56 |
fail_unless(get_weekday(DAYS_PER_WEEK) == NULL, "getting weekday name for too high value should bring a NULL"); |
| 57 |
fail_unless(get_weekday(0) != NULL, "getting weekday name for correct value should bring a non NULL season name"); |
| 58 |
} |
| 59 |
END_TEST |
| 60 |
|
| 61 |
START_TEST(test_get_season_name) { |
| 62 |
fail_unless(get_season_name(-1) == NULL, "getting season name for negative value should bring a NULL"); |
| 63 |
fail_unless(get_season_name(SEASONS_PER_YEAR+2) == NULL, "getting season name for too high value should bring a NULL"); |
| 64 |
fail_unless(get_season_name(SEASONS_PER_YEAR) != NULL, "getting season name for limit value should bring a '\\n'"); |
| 65 |
fail_unless(strcmp(get_season_name(SEASONS_PER_YEAR), "\n") == 0, "getting season name for limit value should bring a '\n'"); |
| 66 |
fail_unless(get_season_name(0) != NULL, "getting season name for correct value should bring a non NULL season name"); |
| 67 |
} |
| 68 |
END_TEST |
| 69 |
|
| 70 |
static Suite *time_suite(void) { |
| 71 |
Suite *s = suite_create("time"); |
| 72 |
TCase *tc_core = tcase_create("Core"); |
| 73 |
|
| 74 |
|
| 75 |
tcase_add_checked_fixture(tc_core, setup, teardown); |
| 76 |
|
| 77 |
suite_add_tcase(s, tc_core); |
| 78 |
tcase_add_test(tc_core, test_get_month_name); |
| 79 |
tcase_add_test(tc_core, test_get_season_name); |
| 80 |
tcase_add_test(tc_core, test_get_weekday); |
| 81 |
|
| 82 |
return s; |
| 83 |
} |
| 84 |
|
| 85 |
int main(void) { |
| 86 |
int nf; |
| 87 |
Suite *s = time_suite(); |
| 88 |
SRunner *sr = srunner_create(s); |
| 89 |
|
| 90 |
srunner_set_xml(sr, LOGDIR "/unit/common/time.xml"); |
| 91 |
srunner_set_log(sr, LOGDIR "/unit/common/time.out"); |
| 92 |
srunner_run_all(sr, CK_ENV); |
| 93 |
nf = srunner_ntests_failed(sr); |
| 94 |
srunner_free(sr); |
| 95 |
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
| 96 |
} |