TCase *tcase_create (const char *name) { char *env; int timeout = DEFAULT_TIMEOUT; TCase *tc = emalloc (sizeof(TCase)); /*freed in tcase_free */ if (name == NULL) tc->name = ""; else tc->name = name; env = getenv("CK_DEFAULT_TIMEOUT"); if (env != NULL) { int tmp = atoi(env); if (tmp >= 0) { timeout = tmp; } } env = getenv("CK_TIMEOUT_MULTIPLIER"); if (env != NULL) { int tmp = atoi(env); if (tmp >= 0) { timeout = timeout * tmp; } } tc->timeout = timeout; tc->tflst = check_list_create(); tc->unch_sflst = check_list_create(); tc->ch_sflst = check_list_create(); tc->unch_tflst = check_list_create(); tc->ch_tflst = check_list_create(); return tc; }
TCase *tcase_create(const char *name) { char *env; double timeout_sec = DEFAULT_TIMEOUT; TCase *tc = (TCase *)emalloc(sizeof(TCase)); /*freed in tcase_free */ if(name == NULL) tc->name = ""; else tc->name = name; env = getenv("CK_DEFAULT_TIMEOUT"); if(env != NULL) { char *endptr = NULL; double tmp = strtod(env, &endptr); if(tmp >= 0 && endptr != env && (*endptr) == '\0') { timeout_sec = tmp; } } env = getenv("CK_TIMEOUT_MULTIPLIER"); if(env != NULL) { char *endptr = NULL; double tmp = strtod(env, &endptr); if(tmp >= 0 && endptr != env && (*endptr) == '\0') { timeout_sec = timeout_sec * tmp; } } tc->timeout.tv_sec = (time_t) floor(timeout_sec); tc->timeout.tv_nsec = (long)((timeout_sec - floor(timeout_sec)) * (double)NANOS_PER_SECONDS); tc->tflst = check_list_create(); tc->unch_sflst = check_list_create(); tc->ch_sflst = check_list_create(); tc->unch_tflst = check_list_create(); tc->ch_tflst = check_list_create(); return tc; }
END_TEST START_TEST(test_free) { List *lp = check_list_create(); list_add_end (lp, "abc"); list_add_end (lp, "123"); list_add_end (lp, NULL); list_free (lp); }
Suite *suite_create (const char *name) { Suite *s; s = emalloc (sizeof(Suite)); /* freed in suite_free */ if (name == NULL) s->name = ""; else s->name = name; s->tclst = check_list_create(); return s; }
END_TEST START_TEST(test_add_front) { List * lp = check_list_create(); const char * tval = "abc"; list_add_front (lp, tval); fail_unless (list_val (lp) != NULL, "List current val should not be null after new insertion"); fail_unless (strcmp(tval, (char *) list_val (lp)) == 0, "List current val should equal newly inserted val"); list_free (lp); }
END_TEST START_TEST(test_add_a_bunch) { List *lp; int i, j; for (i = 0; i < 3; i++) { lp = check_list_create(); for (j = 0; j < 1000; j++) { list_add_end (lp, "abc"); list_add_front (lp, "123"); } list_free(lp); } }
void srunner_init_logging (SRunner *sr, enum print_output print_mode) { FILE *f; sr->loglst = check_list_create(); srunner_register_lfun (sr, stdout, 0, stdout_lfun, print_mode); f = srunner_open_lfile (sr); if (f) { srunner_register_lfun (sr, f, 1, lfile_lfun, print_mode); } f = srunner_open_xmlfile (sr); if (f) { srunner_register_lfun (sr, f, 2, xml_lfun, print_mode); } srunner_send_evt (sr, NULL, CLINITLOG_SR); }
END_TEST START_TEST(test_add_end_and_next) { List *lp = check_list_create(); const char *tval1 = "abc"; const char *tval2 = "123"; list_add_end (lp, tval1); list_add_end (lp, tval2); list_front(lp); fail_unless (strcmp (tval1, list_val (lp)) == 0, "List head val should equal first inserted val"); list_advance (lp); fail_unless (!list_at_end (lp), "List should not be at end after two adds and one next"); fail_unless (strcmp (tval2, list_val (lp)) == 0, "List val should equal second inserted val"); list_advance(lp); fail_unless (list_at_end (lp), "List should be at and after two adds and two nexts"); list_free (lp); }