void test_pending (void) { CutTestContainer *container; test_iterator = cut_test_iterator_new("pending test iterator", stub_pending_iterated_test, stub_iterated_data); container = CUT_TEST_CONTAINER(test_iterator); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_false(run()); cut_assert_equal_uint(3, cut_test_container_get_n_tests(container, NULL)); cut_assert_n_signals(1, 1, 3, 3, 3, 0, 0, 0, 0, 1, 0, 0); cut_assert_test_result_summary(run_context, 3, 5, 2, 0, 0, 1, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_SUCCESS, "pending test iterator (First)", NULL, NULL, NULL, NULL, NULL, NULL); cut_assert_test_result(run_context, 1, CUT_TEST_RESULT_PENDING, "pending test iterator (Second)", "PENDING!", NULL, NULL, NULL, FAIL_LOCATION, "stub_pending_iterated_test", NULL); cut_assert_test_result(run_context, 2, CUT_TEST_RESULT_SUCCESS, "pending test iterator (Third)", NULL, NULL, NULL, NULL, NULL, NULL); }
void test_equal_list_enum (void) { const gchar inspected_expected[] = "(#<CutTestResultStatus: " "pending(CUT_TEST_RESULT_PENDING:3)>, " "#<CutTestResultStatus: " "success(CUT_TEST_RESULT_SUCCESS:0)>)"; const gchar inspected_actual[] = "(#<CutTestResultStatus: " "failure(CUT_TEST_RESULT_FAILURE:4)>)"; test = cut_test_new("equal_list_enum test", stub_equal_list_enum); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list_enum test", NULL, "<list1 == list2>", inspected_expected, inspected_actual, FAIL_LOCATION, FUNCTION("stub_equal_list_enum"), NULL); }
void test_load_test_iterator (void) { const GList *tests; CutTestContainer *container; CutTestIterator *test_iterator; CutIteratedTestFunction iterated_test_function = NULL; CutDataSetupFunction data_setup_function = NULL; loader = loader_new("iterator", "success-iterated-test." G_MODULE_SUFFIX); cut_assert_not_null(loader); test_case = cut_loader_load_test_case(loader); cut_assert_not_null(test_case); container = CUT_TEST_CONTAINER(test_case); cut_assert_equal_int(1, cut_test_container_get_n_tests(container, NULL)); tests = cut_test_container_get_children(container); cut_assert_not_null(tests); test_iterator = tests->data; cut_assert_not_null(test_iterator); g_object_get(test_iterator, "iterated-test-function", &iterated_test_function, "data-setup-function", &data_setup_function, NULL); cut_assert_not_null(iterated_test_function); cut_assert_not_null(data_setup_function); cut_assert_true(run()); cut_assert_test_result_summary(run_context, 2, 2, 2, 0, 0, 0, 0, 0); }
void test_equal_list_object (void) { const gchar *inspected_expected, *inspected_actual; test = cut_test_new("equal_list_object test", stub_equal_list_object); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); inspected_expected = cut_take_printf( "(#<CutRepository:%p directory=<\"directory1\">>, " "(null), " "#<CutTest:%p name=<\"test1\">, element-name=<\"test\">, " "test-function=<NULL>, base-directory=<NULL>>)", list1->data, g_list_nth_data(list1, 2)); inspected_actual = cut_take_printf( "(#<CutRepository:%p directory=<\"directory2\">>, " "(null), " "#<CutTest:%p name=<\"test2\">, element-name=<\"test\">, " "test-function=<NULL>, base-directory=<NULL>>)", list2->data, g_list_nth_data(list2, 2)); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list_object test", NULL, "<list1 == list2>", inspected_expected, inspected_actual, FAIL_LOCATION, FUNCTION("stub_equal_list_object"), NULL); }
void test_equal_object_custom (void) { const gchar *inspected_expected, *inspected_actual; test = cut_test_new("gcut_assert_equal_object_custom test", stub_equal_object_custom); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); inspected_expected = cut_take_printf("#<CutTest:%p " "name=<\"test-name\">, " "element-name=<\"test\">, " "test-function=<NULL>, " "base-directory=<NULL>>", object1); inspected_actual = cut_take_printf("#<CutTest:%p " "name=<\"no-name\">, " "element-name=<\"test\">, " "test-function=<NULL>, " "base-directory=<NULL>>", object3); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_equal_object_custom test", NULL, "<equal_name(object1, object3)>", inspected_expected, inspected_actual, FAIL_LOCATION, FUNCTION("stub_equal_object_custom"), NULL); }
void test_equal_flags (void) { static const GFlagsValue values[] = { {1 << 0, "CUTTEST_ASSERT_STUB_FIRST", "first"}, {1 << 1, "CUTTEST_ASSERT_STUB_SECOND", "second"}, {1 << 2, "CUTTEST_ASSERT_STUB_THIRD", "third"}, {0, NULL, NULL} }; flags_type = g_flags_register_static("CuttestAssertStubFlags", values); test = cut_test_new("gcut_assert_equal_flags test", stub_equal_flags); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_equal_flags test", NULL, "<(1 << 1) | (1 << 2) == (1 << 3)> (flags_type)", "#<CuttestAssertStubFlags: " "second|third " "(CUTTEST_ASSERT_STUB_SECOND:0x2)|" "(CUTTEST_ASSERT_STUB_THIRD:0x4)>", "#<CuttestAssertStubFlags: (unknown flags: 0x8)>", FAIL_LOCATION, FUNCTION("stub_equal_flags"), NULL); }
void test_equal_object_null (void) { const gchar *inspected_expected; test = cut_test_new("gcut_assert_equal_object_null test", stub_equal_object_null); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 0, 0, 1, 0, 0, 0, 0); inspected_expected = cut_take_printf("#<CutLoader:%p " "so-filename=<\"so-name\">, " "base-directory=<NULL>>", object1); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_equal_object_null test", NULL, "<object1 == NULL>", inspected_expected, "(null)", FAIL_LOCATION, FUNCTION("stub_equal_object_null"), NULL); }
void test_equal_list_string_both_null (void) { test = cut_test_new("equal_list_string test (both NULL)", stub_equal_list_string_both_null); cut_assert_not_null(test); cut_assert_true(run()); cut_assert_test_result_summary(run_context, 1, 3, 1, 0, 0, 0, 0, 0); }
void test_not_equal_uint64 (void) { test = cut_test_new("cut_assert_not_equal_uint64()", stub_not_equal_uint64); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "cut_assert_not_equal_uint64()", NULL, "<G_MAXUINT64 != G_MAXUINT64>", "18446744073709551615", "18446744073709551615", FAIL_LOCATION, FUNCTION("stub_not_equal_uint64"), NULL); }
void test_not_equal_int64 (void) { test = cut_test_new("cut_assert_not_equal_int64()", stub_not_equal_int64); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "cut_assert_not_equal_int64()", NULL, "<G_MAXINT64 != G_MAXINT64>", "9223372036854775807", "9223372036854775807", FAIL_LOCATION, FUNCTION("stub_not_equal_int64"), NULL); }
void test_not_equal_pid (void) { test = cut_test_new("cut_assert_not_equal_pid()", stub_not_equal_pid); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "cut_assert_not_equal_pid()", NULL, "<0 != 0>", "0", "0", FAIL_LOCATION, FUNCTION("stub_not_equal_pid"), NULL); }
void test_success (void) { CutTestContainer *container; test_iterator = cut_test_iterator_new("success test iterator", stub_success_iterated_test, stub_iterated_data); container = CUT_TEST_CONTAINER(test_iterator); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_true(run()); cut_assert_equal_uint(3, cut_test_container_get_n_tests(container, NULL)); cut_assert_n_signals(1, 1, 3, 3, 3, 0, 1, 0, 0, 0, 0, 0); cut_assert_test_result_summary(run_context, 3, 6, 3, 0, 0, 0, 0, 0); }
void test_error_in_data_setup (void) { CutTestContainer *container; test_iterator = cut_test_iterator_new("error in data setup test iterator", stub_error_in_data_setup_iterated_test, stub_error_in_data_setup_iterated_data); container = CUT_TEST_CONTAINER(test_iterator); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_false(run()); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_n_signals(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); cut_assert_test_result_summary(run_context, 0, 0, 0, 0, 0, 0, 0, 0); }
void test_equal_type (void) { test = cut_test_new("equal_type test", stub_equal_type); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_type test", NULL, "<G_TYPE_INT == G_TYPE_STRING>", "gint", "gchararray", FAIL_LOCATION, FUNCTION("stub_equal_type"), NULL); }
void test_equal_error (void) { test = cut_test_new("gcut_assert_equal_error test", stub_equal_error); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_equal_error test", NULL, "<error1 == error2>", "g-file-error-quark:4: not found", "g-file-error-quark:4: no entry", FAIL_LOCATION, FUNCTION("stub_equal_error"), NULL); }
void test_error (void) { test = cut_test_new("gcut_assert_error test", stub_error); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_error test", NULL, "expected: <error> is NULL\n" " actual: <g-file-error-quark:4: not found>", NULL, NULL, FAIL_LOCATION, FUNCTION("stub_error"), NULL); }
void test_equal_value (void) { test = cut_test_new("equal_value test", stub_equal_value); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_value test", NULL, "<value1 == value2>", "10 (gint)", "\"String\" (gchararray)", FAIL_LOCATION, FUNCTION("stub_equal_value"), NULL); }
void test_equal_list_uint (void) { test = cut_test_new("equal_list_uint test", stub_equal_list_uint); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list_uint test", NULL, "<list1 == list2>", "(100, 200)", "(1000, 2000)", FAIL_LOCATION, FUNCTION("stub_equal_list_uint"), NULL); }
void test_equal_list_string (void) { test = cut_test_new("equal_list_string test", stub_equal_list_string); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list_string test", NULL, "<list1 == list2>", "(\"abc\", \"def\")", "(\"zyx\", \"wvu\")", FAIL_LOCATION, FUNCTION("stub_equal_list_string"), NULL); }
void test_equal_hash_table_string_string (void) { test = cut_test_new("equal_hash_table_string_string test", stub_equal_hash_table_string_string); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_hash_table_string_string test", NULL, "<hash1 == hash2>", "{\"abc\" => \"11\", \"def\" => \"22\"}", "{\"wvu\" => \"88\", \"zyx\" => \"99\"}", FAIL_LOCATION, FUNCTION("stub_equal_hash_table_string_string"), NULL); }
void test_equal_hash_table (void) { test = cut_test_new("equal_hash_table test", stub_equal_hash_table); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_hash_table test", NULL, "<g_str_equal(hash1[key], hash2[key]) == TRUE>", "{1 => \"11\", 10 => \"22\"}", "{2 => \"99\", 20 => \"88\"}", FAIL_LOCATION, FUNCTION("stub_equal_hash_table"), NULL); }
void test_equal_list (void) { test = cut_test_new("equal_list test", stub_equal_list); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result( run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list test", NULL, "<stub_equal_list_equal_func(list1[i], list2[i]) == TRUE>", "(CCC: <100>, CCC: <-200>)", "(CCC: <-1000>, CCC: <2000>)", FAIL_LOCATION, FUNCTION("stub_equal_list"), NULL); }
void test_equal_enum (void) { test = cut_test_new("gcut_assert_equal_enum test", stub_equal_enum); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 1, 0, 1, 0, 0, 0, 0); cut_assert_test_result( run_context, 0, CUT_TEST_RESULT_FAILURE, "gcut_assert_equal_enum test", NULL, "<CUT_TEST_RESULT_FAILURE == CUT_TEST_RESULT_PENDING>" " (CUT_TYPE_TEST_RESULT_STATUS)", "#<CutTestResultStatus: failure(CUT_TEST_RESULT_FAILURE:4)>", "#<CutTestResultStatus: pending(CUT_TEST_RESULT_PENDING:3)>", FAIL_LOCATION, FUNCTION("stub_equal_enum"), NULL); }
void test_omission (void) { CutTestContainer *container; test_iterator = cut_test_iterator_new("omission test iterator", stub_omission_iterated_test, stub_iterated_data); container = CUT_TEST_CONTAINER(test_iterator); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_true(run()); cut_assert_equal_uint(3, cut_test_container_get_n_tests(container, NULL)); cut_assert_n_signals(1, 1, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1); cut_assert_test_result_summary(run_context, 3, 5, 3, 0, 0, 0, 0, 1); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_SUCCESS, "omission test iterator (First)", NULL, NULL, NULL, NULL, NULL, NULL); cut_assert_test_result(run_context, 1, CUT_TEST_RESULT_OMISSION, "omission test iterator (Second)", "OMISSION!", NULL, NULL, NULL, FAIL_LOCATION, "stub_omission_iterated_test", NULL); cut_assert_test_result(run_context, 2, CUT_TEST_RESULT_SUCCESS, "omission test iterator (Second)", NULL, NULL, NULL, NULL, NULL, NULL); cut_assert_test_result(run_context, 3, CUT_TEST_RESULT_SUCCESS, "omission test iterator (Third)", NULL, NULL, NULL, NULL, NULL, NULL); }
void test_equal_list_flags (void) { const gchar inspected_expected[] = "(#<CuttestAssertListStubFlags: " "first|second " "(CUTTEST_ASSERT_LIST_STUB_FIRST:0x1)|" "(CUTTEST_ASSERT_LIST_STUB_SECOND:0x2)>, " "#<CuttestAssertListStubFlags: " "third (CUTTEST_ASSERT_LIST_STUB_THIRD:0x4)>)"; const gchar inspected_actual[] = "(#<CuttestAssertListStubFlags>)"; static const GFlagsValue values[] = { {1 << 0, "CUTTEST_ASSERT_LIST_STUB_FIRST", "first"}, {1 << 1, "CUTTEST_ASSERT_LIST_STUB_SECOND", "second"}, {1 << 2, "CUTTEST_ASSERT_LIST_STUB_THIRD", "third"}, {0, NULL, NULL} }; flags_type = g_flags_register_static("CuttestAssertListStubFlags", values); test = cut_test_new("equal_list_flags test", stub_equal_list_flags); cut_assert_not_null(test); cut_assert_false(run()); cut_assert_test_result_summary(run_context, 1, 2, 0, 1, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "equal_list_flags test", NULL, "<list1 == list2>", inspected_expected, inspected_actual, FAIL_LOCATION, FUNCTION("stub_equal_list_flags"), NULL); }
void test_failure (void) { CutTestContainer *container; test_iterator = cut_test_iterator_new("failure test iterator", stub_failure_iterated_test, stub_iterated_data); container = CUT_TEST_CONTAINER(test_iterator); cut_assert_equal_uint(0, cut_test_container_get_n_tests(container, NULL)); cut_assert_false(run()); cut_assert_equal_uint(3, cut_test_container_get_n_tests(container, NULL)); cut_assert_n_signals(1, 1, 3, 3, 3, 0, 0, 1, 0, 0, 0, 0); cut_assert_test_result_summary(run_context, 3, 5, 1, 2, 0, 0, 0, 0); cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_FAILURE, "failure test iterator (First)", NULL, "<2 == GPOINTER_TO_INT(data)>", "2", "1", FAIL_LOCATION, "stub_failure_iterated_test", NULL); cut_assert_test_result(run_context, 1, CUT_TEST_RESULT_SUCCESS, "failure test iterator (Second)", NULL, NULL, NULL, NULL, NULL, NULL); cut_assert_test_result(run_context, 2, CUT_TEST_RESULT_FAILURE, "failure test iterator (Third)", NULL, "<2 == GPOINTER_TO_INT(data)>", "2", "3", FAIL_LOCATION, "stub_failure_iterated_test", NULL); }