コード例 #1
0
void *
echo_service(void *arg)
{
  struct llc_connection *connection = (struct llc_connection *)arg;

  int old_cancelstate;
  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);

  cut_set_current_test_context(connection->link->cut_test_context);

  mqd_t llc_up = mq_open(connection->mq_up_name, O_RDONLY);
  cut_assert_false(llc_up == (mqd_t) - 1, cut_message("Can't open llc_up mqueue for reading"));

  mqd_t llc_down = mq_open(connection->mq_down_name, O_WRONLY);
  cut_assert_false(llc_down == (mqd_t) - 1, cut_message("Can't open llc_down mqueue for writing"));

  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);

  for (;;) {
    char buffer[1024];
    int res = mq_receive(llc_up, buffer, sizeof(buffer), NULL);
    pthread_testcancel();
    cut_assert_equal_int(7, res, cut_message("Invalid message length"));
    cut_assert_equal_memory(buffer, res, "\x40\xc0Hello", 7, cut_message("Invalid message data"));
    sem_post(sem_cutter);
    pthread_testcancel();
  }
}
コード例 #2
0
void
test_set_data (void)
{
    CutTestData *current_test_data;
    const gchar name[] = "sample test data";
    const gchar value[] = "sample test value";

    cut_assert_false(cut_test_context_have_data(context));

    test_data = cut_test_data_new(name, g_strdup(value), string_data_free);
    cut_test_context_set_data(context, test_data);
    g_object_unref(test_data);
    test_data = NULL;
    cut_assert_false(destroy_called);
    cut_assert_equal_string(NULL, destroyed_string);

    cut_assert_true(cut_test_context_have_data(context));
    current_test_data = cut_test_context_get_current_data(context);
    cut_assert_not_null(current_test_data);
    cut_assert_equal_string(value, cut_test_data_get_value(current_test_data));

    cut_assert_false(destroy_called);
    cut_assert_equal_string(NULL, destroyed_string);
    g_object_unref(context);
    context = NULL;
    cut_assert_true(destroy_called);
    cut_assert_equal_string(value, destroyed_string);
}
コード例 #3
0
ファイル: test-gcut-process.c プロジェクト: hayamiz/cutter
void
test_flags (void)
{
    GError *error = NULL;

    process = gcut_process_new("echo", "XXX", NULL);
    setup_process(process);

    gcut_process_set_flags(process, 0);
    cut_assert_false(gcut_process_get_flags(process) & G_SPAWN_SEARCH_PATH);
    cut_assert_false(gcut_process_run(process, &actual_error));
    expected_error =
        g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT,
                    "Failed to execute child process \"%s\" (%s)",
                    "echo", g_strerror(ENOENT));
    gcut_assert_equal_error(expected_error, actual_error);

    gcut_process_set_flags(process, G_SPAWN_SEARCH_PATH);
    gcut_process_run(process, &error);
    gcut_assert_error(error);

    wait_exited();
    cut_assert_equal_string("XXX\n", output_string->str);
    cut_assert_equal_string("", error_string->str);
}
コード例 #4
0
void
test_remove_unix_socket_on_close_accessor (void)
{
    cut_assert_true(milter_client_get_default_remove_unix_socket_on_close(client));
    cut_assert_true(milter_client_is_remove_unix_socket_on_close(client));
    milter_client_set_default_remove_unix_socket_on_close(client, FALSE);
    cut_assert_false(milter_client_get_default_remove_unix_socket_on_close(client));
    cut_assert_false(milter_client_is_remove_unix_socket_on_close(client));
}
コード例 #5
0
ファイル: test_domain.c プロジェクト: kenhys/gauche-izc
CUT_EXPORT void test_cs_isInstantiated(void)
{
    cut_assert_true(cs_isInstantiated(CSINT(0)));
    cut_assert_true(cs_isInstantiated(CSINT(INT_MIN)));
    cut_assert_true(cs_isInstantiated(CSINT(INT_MAX)));

    cut_assert_false(cs_isInstantiated(cs_createCSint(0, 10)));
    cut_assert_false(cs_isInstantiated(cs_createCSint(INT_MIN, INT_MAX)));
}
コード例 #6
0
void
test_equal_content_threshold (void)
{
    pixbuf1 = load_pixbuf("dark-circle.png");
    pixbuf2 = load_pixbuf("max-3-pixel-value-different-dark-circle.png");

    cut_assert_false(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf2, 0));
    cut_assert_true(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf1, 3));
    cut_assert_false(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf2, 2));
}
コード例 #7
0
void
test_set_failed (void)
{
    cut_assert_false(cut_test_context_is_failed(context));

    cut_test_context_set_failed(context, TRUE);
    cut_assert_true(cut_test_context_is_failed(context));

    cut_test_context_set_failed(context, FALSE);
    cut_assert_false(cut_test_context_is_failed(context));
}
コード例 #8
0
ファイル: test-micbench-io.c プロジェクト: curvet/micbench
void
test_parse_args_rwmix_mode(void)
{
    argv[1] = "-M";
    argv[2] = "0.5";
    argv[3] = dummy_file;
    cut_assert_equal_int(0, parse_args(4, argv, &option));
    cut_assert_false(option.read);
    cut_assert_false(option.write);
    cut_assert_equal_double(0.5, 0.001, option.rwmix);
}
コード例 #9
0
void
test_need_maintain_never (void)
{
    milter_client_set_maintenance_interval(client, 0);
    milter_client_set_n_processing_sessions(client, 3);

    cut_assert_false(milter_client_need_maintain(client, 0));
    cut_assert_false(milter_client_need_maintain(client, 1));

    milter_client_set_n_processed_sessions(client, 100);
    cut_assert_false(milter_client_need_maintain(client, 1));
}
コード例 #10
0
void
test_equal_content (void)
{
    pixbuf1 = load_pixbuf("dark-circle.png");
    pixbuf2 = load_pixbuf("nested-circle.png");

    cut_assert_true(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf1, 0));
    cut_assert_true(gdkcut_pixbuf_equal_content(pixbuf2, pixbuf2, 0));
    cut_assert_false(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf2, 0));

    g_object_unref(pixbuf2);
    pixbuf2 = load_pixbuf("small-circle.png");
    cut_assert_false(gdkcut_pixbuf_equal_content(pixbuf1, pixbuf2, 0));
}
コード例 #11
0
ファイル: test-micbench-io.c プロジェクト: curvet/micbench
void
test_parse_args_rw_modes(void)
{
    argv[1] = dummy_file;
    cut_assert_equal_int(0, parse_args(2, argv, &option));
    cut_assert_true(option.read);
    cut_assert_false(option.write);

    argv[1] = "-W";
    argv[2] = dummy_file;
    cut_assert_equal_int(0, parse_args(3, argv, &option));
    cut_assert_false(option.read);
    cut_assert_true(option.write);
}
コード例 #12
0
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);
}
コード例 #13
0
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);
}
コード例 #14
0
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);
}
コード例 #15
0
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);
}
コード例 #16
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);
}
コード例 #17
0
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);
}
コード例 #18
0
void
test_daemon (void)
{
    cut_assert_false(milter_manager_configuration_is_daemon(config));
    milter_manager_configuration_set_daemon(config, TRUE);
    cut_assert_true(milter_manager_configuration_is_daemon(config));
}
コード例 #19
0
void
test_privilege_mode (void)
{
    cut_assert_false(milter_manager_configuration_is_privilege_mode(config));
    milter_manager_configuration_set_privilege_mode(config, TRUE);
    cut_assert_true(milter_manager_configuration_is_privilege_mode(config));
}
コード例 #20
0
void
test_remove_controller_unix_socket_on_create (void)
{
    cut_assert_true(milter_manager_configuration_is_remove_controller_unix_socket_on_create(config));
    milter_manager_configuration_set_remove_controller_unix_socket_on_create(config, FALSE);
    cut_assert_false(milter_manager_configuration_is_remove_controller_unix_socket_on_create(config));
}
コード例 #21
0
void
test_remove_pid_file_on_exit_accessor (void)
{
    cut_assert_true(milter_client_is_remove_pid_file_on_exit(client));
    milter_client_set_remove_pid_file_on_exit(client, FALSE);
    cut_assert_false(milter_client_is_remove_pid_file_on_exit(client));
}
コード例 #22
0
ファイル: test-tuishogi.cpp プロジェクト: myokoym/tuishogi
  void
  test_playerOperate_only_place(void)
  {
    // Arrange
    std::stringbuf  string_out;
    std::streambuf* std_out = std::cout.rdbuf(&string_out);
    NumEffectState state((SimpleState(HIRATE)));
    const char* expected = "\
P1-KY-KE-GI-KI-OU-KI-GI-KE-KY\n\
P2 * -HI *  *  *  *  * -KA * \n\
P3-FU-FU-FU-FU-FU-FU-FU-FU-FU\n\
P4 *  *  *  *  *  *  *  *  * \n\
P5 *  *  *  *  *  *  *  *  * \n\
P6 *  * +FU *  *  *  *  *  * \n\
P7+FU+FU * +FU+FU+FU+FU+FU+FU\n\
P8 * +KA *  *  *  *  * +HI * \n\
P9+KY+KE+GI+KI+OU+KI+GI+KE+KY\n\
-\n\
\n\
+7776FU\n";

    // Act
    bool failed = playerOperate(state, "7776");

    std::cout << std::flush;
    std::cout.rdbuf(std_out);

    // TODO assert it as a std::string
    std::string str = string_out.str();
    const char* actual = str.c_str();

    // Assert
    cut_assert_false(failed);
    cut_assert_equal_string(expected, actual);
  }
コード例 #23
0
ファイル: test-tuishogi.cpp プロジェクト: myokoym/tuishogi
 void
 test_isMated(void)
 {
   NumEffectState state((SimpleState(HIRATE)));
   bool mated = isMated(state);
   cut_assert_false(mated);
 }
コード例 #24
0
void
test_not_remove_unix_socket_on_create (void)
{
    const gchar *path;
    GError *error = NULL;

    path = cut_take_printf("%s/milter.sock", tmp_dir);
    spec = cut_take_printf("unix:%s", path);

    g_file_set_contents(path, "", 0, &error);
    gcut_assert_error(error);

    milter_client_set_remove_unix_socket_on_create(client, FALSE);

    cut_trace(setup_client());
    cut_assert_false(milter_client_run(client, &error));
    gcut_assert_error(actual_error);

    actual_error = error;
    expected_error = g_error_new(MILTER_CONNECTION_ERROR,
                                 MILTER_CONNECTION_ERROR_BIND_FAILURE,
                                 "failed to bind(): %s: %s",
                                 spec, g_strerror(EADDRINUSE));
    gcut_assert_equal_error(expected_error, actual_error);
}
コード例 #25
0
void
test_not_in(void)
{
  cut_assert_false(grn_geo_in_rectangle(context,
                                        tokyo_wgs84,
                                        sazare_wgs84,
                                        hiiragi_wgs84));
}
コード例 #26
0
void
test_need_maintain_no_processing_sessions_below_processed_sessions (void)
{
    milter_client_set_maintenance_interval(client, 5);
    milter_client_set_n_processed_sessions(client, 3);
    cut_assert_false(milter_client_need_maintain(client, 0));
    cut_assert_true(milter_client_need_maintain(client, 1));
}
コード例 #27
0
ファイル: test_domain.c プロジェクト: kenhys/gauche-izc
CUT_EXPORT void test_cs_isFree(void)
{
    CSint *vint = NULL;
    CSint *vint2 = NULL;

    cut_assert_true(cs_isFree(cs_createCSint(0, 10)));

    vint = cs_createCSint(INT_MIN, INT_MAX);
    cut_assert_equal_int(INT_MIN, cs_getMin(vint));
    cut_assert_equal_int(INT_MAX, cs_getMax(vint));
    /* may be iz-c bug? expect true, but false */
    cut_assert_true(cs_isFree(vint), "may be iz-c bug?");

    cut_assert_false(cs_isFree(CSINT(0)));
    cut_assert_false(cs_isFree(CSINT(INT_MIN)));
    cut_assert_false(cs_isFree(CSINT(INT_MAX)));

}
コード例 #28
0
ファイル: test-tuishogi.cpp プロジェクト: myokoym/tuishogi
 void
 test_computerOperate(void)
 {
   // TODO cleanup
   std::stringbuf  string_out;
   std::streambuf* std_out = std::cout.rdbuf(&string_out);
   NumEffectState state((SimpleState(HIRATE)));
   bool ended = computerOperate(state);
   std::cout << std::flush;
   std::cout.rdbuf(std_out);
   cut_assert_false(ended);
 }
コード例 #29
0
void
test_remove_unix_socket_on_close (void)
{
    const gchar *path;

    path = cut_take_printf("%s/milter.sock", tmp_dir);
    spec = cut_take_printf("unix:%s", path);

    cut_trace(setup_client());
    cut_assert_true(milter_client_run(client, &actual_error));
    gcut_assert_error(actual_error);

    cut_assert_false(g_file_test(path, G_FILE_TEST_EXISTS));
}
コード例 #30
0
ファイル: test-object.c プロジェクト: tSU-RooT/groonga
void
test_is_scorer_proc(gconstpointer data)
{
  const gchar *name;
  grn_obj *object;

  name = gcut_data_get_string(data, "name");
  object = grn_ctx_get(context, name, strlen(name));
  if (gcut_data_get_string(data, "expected")) {
    cut_assert_true(grn_obj_is_scorer_proc(context, object));
  } else {
    cut_assert_false(grn_obj_is_scorer_proc(context, object));
  }
}