int main() { int err; TestSuite *suite = create_test_suite(); add_test_with_context(suite, eclGetContextInteractively, runs); add_test_with_context(suite, eclGetContextInteractively, returnsAContextIfNoErrorOccured); add_test_with_context(suite, eclGetContextInteractively, returnsAValidContext); add_test_with_context(suite, eclGetContextInteractively, returnsADeviceIfNoErrorOccured); add_test_with_context(suite, eclGetContextInteractively, returnsAValidDevice); add_test_with_context(suite, eclGetContextInteractively, returnsACommandQueueIfNoErrorOccured); add_test_with_context(suite, eclGetContextInteractively, returnsAValidCommandQueue); add_test_with_context(suite, eclGetContextInteractively, commandQueueConsistentWithContext); add_test_with_context(suite, eclGetContextInteractively, commandQueueConsistentWithDevice); add_test_with_context(suite, eclGetContextInteractively, doesntCrashDueToBogusPlatformChoice); add_test_with_context(suite, eclGetContextInteractively, recoversFromBogusPlatformChoice); add_test_with_context(suite, eclGetContextInteractively, doesntCrashDueToBogusDeviceChoice); add_test_with_context(suite, eclGetContextInteractively, recoversFromBogusDeviceChoice); err = run_test_suite(suite, create_text_reporter()); destroy_test_suite(suite); return err; }
void destroy_test_suite(TestSuite *suiteToDestroy) { int i; for (i = 0; i < suiteToDestroy->size; i++) { UnitTest test = suiteToDestroy->tests[i]; TestSuite* suite = test.Runnable.suite; if (test_suite == test.type && suite != NULL) { suiteToDestroy->tests[i].Runnable.suite = NULL; destroy_test_suite(suite); } } if (suiteToDestroy->tests != NULL) free(suiteToDestroy->tests); free(suiteToDestroy); }
int main(int argc, char **argv) { PetscInitialize(&argc, &argv, NULL, help); TestSuite *suite = create_test_suite(); add_test(suite, first_derivative_of_constant_is_zero); add_test(suite, first_derivative_fourth_order_of_constant_is_zero); add_test(suite, first_derivative_of_linear_function_is_computed_exactly); add_test(suite, first_derivative_fourth_order_of_linear_function_is_computed_exactly); add_test(suite, second_derivative_of_constant_is_zero); add_test(suite, second_derivative_fourth_order_of_constant_is_zero); add_test(suite, second_derivative_of_linear_function_is_zero); add_test(suite, second_derivative_fourth_order_of_linear_function_is_zero); int result = run_test_suite(suite, create_text_reporter()); destroy_test_suite(suite); PetscFinalize(); return result; }
/*----------------------------------------------------------------------*/ static int run_tests(TestReporter *reporter, const char *suite_name, const char *symbolic_name, void *test_library_handle, TestItem test_items[], bool verbose) { int status; ContextSuite *context_suites = NULL; TestSuite *suite = create_named_test_suite(suite_name); const int number_of_matches = add_matching_tests_to_suite(test_library_handle, symbolic_name, test_items, suite, &context_suites); if (error_when_matching(number_of_matches)) return EXIT_FAILURE; if (symbolic_name != NULL && number_of_matches == 1) { bool found = matching_test_exists(symbolic_name, test_items); if (verbose) printf(" to only run one test: '%s' ...\n", symbolic_name); if (!found) { fprintf(stderr, "ERROR: No such test: '%s' in '%s'\n", symbolic_name, suite_name); return EXIT_FAILURE; } status = run_single_test(suite, test_name_of(symbolic_name), reporter); } else { if (verbose) { if (number_of_matches != count(test_items)) printf(" to run %d matching tests ...\n", number_of_matches); else printf(" to run all %d discovered tests ...\n", count(test_items)); } if (number_of_matches > 0) status = run_test_suite(suite, reporter); else { fprintf(stderr, "ERROR: No such test: '%s' in '%s'\n", symbolic_name, suite_name); status = EXIT_FAILURE; } } destroy_test_suite(suite); destroy_context_suites(context_suites); return(status); }
int main(int argc, char **argv) { PetscInitialize(&argc, &argv, NULL, help); TestSuite *suite = create_test_suite(); add_test_with_context(suite, FFT, can_be_constructed_from_DMDA); add_test_with_context(suite, FFT, registers_the_right_DM); add_test_with_context(suite, FFT, creates_output_vector_of_correct_size); add_test_with_context(suite, FFT, transforms_constant_into_delta_function); add_test_with_context(suite, FFT, can_transform_second_component); add_test_with_context(suite, FFT, i_transform_is_inverse_of_transform); add_test_with_context(suite, FFT, PSD_of_delta_function_is_flat); add_test_with_context(suite, FFT, yields_PSD_of_the_correct_size); int result; if (argc > 2) { result = run_single_test(suite, argv[1], create_text_reporter()); } else { result = run_test_suite(suite, create_text_reporter()); } destroy_test_suite(suite); PetscFinalize(); return result; }
int main(int argc, char **argv) { PetscInitialize(&argc, &argv, NULL, help); TestSuite *suite = create_test_suite(); add_test_with_context(suite, FourthOrderJacobian, can_be_built); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_constant_fields); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_sine_waves); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_gaussian); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_constant_right_moving); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_sine_wave_right_moving); add_test_with_context(suite, FourthOrderJacobian, is_consistent_for_gaussian_right_moving); /* Disable this test for now, need the right Chi3 physics add_test(suite, prec_consistent_sine_wave_non_zero_gamma); */ int result; if (argc > 2) { result = run_single_test(suite, argv[1], create_text_reporter()); } else { result = run_test_suite(suite, create_text_reporter()); } destroy_test_suite(suite); PetscFinalize(); return result; }
static void clean_up_test_run(TestSuite *suite, TestReporter *reporter) { (*reporter->destroy)(reporter); destroy_test_suite(suite); }