/** * Filter loaded test suites, either remove suites listed (exclude=TRUE), or all * that are not listed (exclude=FALSE). */ static void apply_filter(array_t *loaded, char *filter, bool exclude) { enumerator_t *enumerator, *names; hashtable_t *listed; test_suite_t *suite; char *name; listed = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8); names = enumerator_create_token(filter, ",", " "); while (names->enumerate(names, &name)) { listed->put(listed, name, name); } enumerator = array_create_enumerator(loaded); while (enumerator->enumerate(enumerator, &suite)) { if ((exclude && listed->get(listed, suite->name)) || (!exclude && !listed->get(listed, suite->name))) { array_remove_at(loaded, enumerator); destroy_suite(suite); } } enumerator->destroy(enumerator); listed->destroy(listed); names->destroy(names); }
void test_run_zero_tests_has_zero_failures() { suite_t* suite = create_suite(); silence_suite(suite); run_suite(suite); expect(get_failure_count(suite) == 0); destroy_suite(suite); }
/** * Unload and destroy test suites and associated data */ static void unload_suites(array_t *suites) { test_suite_t *suite; while (array_remove(suites, 0, &suite)) { destroy_suite(suite); } array_destroy(suites); }
void test_expect_unexpected_fails() { suite_t* suite = create_suite(); silence_suite(suite); add_test_to_suite(suite, expect_unexpected); run_suite(suite); expect(get_failure_count(suite) == 1); destroy_suite(suite); }
void test_two_failed_tests() { suite_t* suite = create_suite(); silence_suite(suite); add_test_to_suite(suite, fails); add_test_to_suite(suite, also_fails); run_suite(suite); expect(get_failure_count(suite) == 2); destroy_suite(suite); }