コード例 #1
0
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;
}
コード例 #2
0
ファイル: suite.c プロジェクト: Atalanta/run-length-encoding
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);
}
コード例 #3
0
ファイル: test_FD.c プロジェクト: ocramz/SuperContinuum
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;
}
コード例 #4
0
ファイル: runner.c プロジェクト: hean01-cendio/cgreen
/*----------------------------------------------------------------------*/
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);
}
コード例 #5
0
ファイル: test_FFT.c プロジェクト: ocramz/SuperContinuum
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;
}
コード例 #6
0
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;
}
コード例 #7
0
ファイル: unit.c プロジェクト: jorgenpt/cgreen
static void clean_up_test_run(TestSuite *suite, TestReporter *reporter) {
    (*reporter->destroy)(reporter);
	destroy_test_suite(suite);
}