Permalink
Browse files

Add test for get_fuzzy_time on full hours

  • Loading branch information...
1 parent c6d9f24 commit 860b70738f3a386f9002bdae40b3b7c2624db923 @caio committed Mar 27, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 tests/check_fuzzyclock.c
View
@@ -20,11 +20,34 @@ START_TEST(test_get_hour_string) {
}
END_TEST
+START_TEST(test_get_fuzzy_time) {
+ char buff[MAX_MSG_SIZE];
+ char test[MAX_MSG_SIZE];
+ time_t now = time(NULL);
+ struct tm* clock = localtime(&now);
+ int i = 0;
+
+ // Verifying o' clock
+ clock->tm_min = 0;
+
+ for (i = 1; i < 12; i++) {
+ clock->tm_hour = i;
+ snprintf(test, MAX_MSG_SIZE, "%s o' clock", get_hour_string(i));
+
+ get_fuzzy_time(clock, buff);
+
+ fail_if(strcmp(test, buff) != 0, "WANTED \"%s\", GOT \"%s\"", test, buff);
+ }
+
+}
+END_TEST
+
Suite* fuzzy_suite(void) {
Suite* suite = suite_create("fuzzyclock");
TCase* tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_get_hour_string);
+ tcase_add_test(tc_core, test_get_fuzzy_time);
suite_add_tcase(suite, tc_core);
return suite;

0 comments on commit 860b707

Please sign in to comment.