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))); }
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)); }
void test_card_suit_new_from_string(void) { cut_set_message("文字列からスーツを作成する。"); cut_assert_true(card_suit_new_from_string("SPADE")==SPADE); cut_assert_true(card_suit_new_from_string("HEART")==HEART); cut_assert_true(card_suit_new_from_string("DIAMOND")==DIAMOND); cut_assert_true(card_suit_new_from_string("CLUB")==CLUB); }
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); }
void test_need_maintain (void) { milter_client_set_maintenance_interval(client, 10); milter_client_set_n_processing_sessions(client, 3); milter_client_set_n_processed_sessions(client, 10); cut_assert_false(milter_client_need_maintain(client, 0)); cut_assert_true(milter_client_need_maintain(client, 1)); milter_client_set_n_processed_sessions(client, 11); cut_assert_false(milter_client_need_maintain(client, 1)); cut_assert_true(milter_client_need_maintain(client, 2)); }
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)); }
void test_memcached_decrement(void) { uint32_t flags; uint64_t intval; memcached_return rc; rc = memcached_increment_with_initial(memc, "decr", 4, 30, 99, 0, &intval); cut_assert_equal_int(MEMCACHED_SUCCESS, rc); cut_assert_true(intval == 99); rc = memcached_decrement_with_initial(memc, "decr", 4, 17, 0, 0, &intval); cut_assert_equal_int(MEMCACHED_SUCCESS, rc); cut_assert_true(intval == 82); }
void test_header (void) { const gchar name[] = "X-HEADER-NAME"; const gchar value[] = "MilterServerContext test"; const gchar *packet; gsize packet_size; test_data(); channel_free(); reply_continue(); cut_assert_true(milter_server_context_header(context, name, value)); pump_all_events(); milter_test_assert_state(HEADER); milter_test_assert_status(NOT_CHANGE); milter_command_encoder_encode_header(encoder, &packet, &packet_size, name, value); milter_test_assert_packet(channel, packet, packet_size); cut_assert_equal_uint(0, n_message_processed); }
void test_body (void) { const gchar chunk[] = "This is a body text."; const gchar *packet; gsize packet_size; gsize packed_size; test_end_of_header(); channel_free(); reply_continue(); cut_assert_true(milter_server_context_body(context, chunk, strlen(chunk))); pump_all_events(); milter_test_assert_state(BODY); milter_test_assert_status(NOT_CHANGE); milter_command_encoder_encode_body(encoder, &packet, &packet_size, chunk, strlen(chunk), &packed_size); milter_test_assert_packet(channel, packet, packet_size); cut_assert_equal_uint(strlen(chunk), packed_size); cut_assert_equal_uint(0, n_message_processed); }
void test_scale (gconstpointer data) { GtkWidget *scale; gint widget_value; gint xinput_value; const gchar *widget_name; const gchar *xinput_name; const gchar *box_name; widget_name = gcut_data_get_string(data, "widget-name"); xinput_name = gcut_data_get_string(data, "xinput-name"); box_name = gcut_data_get_string(data, "box-name"); enable_widget(box_name); scale = get_widget(widget_name); cut_assert_true(GTK_IS_RANGE(scale)); xinput_value = get_int_property_of_xinput(xinput_name); widget_value = gtk_test_slider_get_value(scale); cut_assert_equal_int(xinput_value, widget_value); gtk_test_slider_set_perc(scale, 50.0); wait_action(); xinput_value = get_int_property_of_xinput(xinput_name); widget_value = gtk_test_slider_get_value(scale); cut_assert_equal_int(xinput_value, widget_value); }
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)); }
void test_attachment_save (void) { GList *attachments, *node; document = load_document ("attachment.pdf"); cut_assert_true (poppler_document_has_attachments (document)); attachments = poppler_document_get_attachments (document); gcut_take_list (attachments, attachment_unref); for (node = attachments; node; node = g_list_next (node)) { PopplerAttachment *attachment = node->data; const gchar *filename; gchar *contents; const gchar *expected_contents; GError *error = NULL; filename = cut_take_string (g_build_filename (tmp_dir, attachment->name, NULL)); poppler_attachment_save (attachment, filename, &error); gcut_assert_error (error); g_file_get_contents (filename, &contents, NULL, &error); gcut_assert_error (error); expected_contents = cut_get_fixture_data_string (attachment->name, NULL); cut_set_message ("%s", attachment->name); cut_assert_equal_string_with_free (expected_contents, contents); } }
void test_toggle_button (gconstpointer data) { GtkWidget *button, *dependent_widget; gboolean widget_value; gboolean xinput_value; const gchar *widget_name; const gchar *xinput_name; const gchar *dependent_widget_name; widget_name = gcut_data_get_string(data, "widget-name"); xinput_name = gcut_data_get_string(data, "xinput-name"); dependent_widget_name = gcut_data_get_string(data, "dependent-widget-name"); button = get_widget(widget_name); cut_assert_true(GTK_IS_TOGGLE_BUTTON(button)); xinput_value = get_boolean_property_of_xinput(xinput_name); widget_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); cut_assert_equal_int(xinput_value, widget_value); /* check widget sensitivity */ dependent_widget = get_widget(dependent_widget_name); cut_assert_equal_int(widget_value, GTK_WIDGET_SENSITIVE(dependent_widget)); gtk_test_widget_click(button, 1, 0); wait_action(); xinput_value = get_boolean_property_of_xinput(xinput_name); cut_assert_equal_int(xinput_value, !widget_value); cut_assert_equal_int(!widget_value, GTK_WIDGET_SENSITIVE(dependent_widget)); }
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)); }
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)); }
void test_stop_on_connect (void) { struct sockaddr_in address; const gchar host_name[] = "mx.local.net"; const gchar ip_address[] = "192.168.123.123"; guint16 port; port = g_htons(50443); address.sin_family = AF_INET; address.sin_port = port; inet_pton(AF_INET, ip_address, &(address.sin_addr)); cut_assert_true(milter_server_context_connect(context, host_name, (struct sockaddr *)&address, sizeof(address))); cut_assert_equal_uint(1, n_stop_on_connect); cut_assert_equal_string(host_name, connect_host_name); cut_assert_equal_int(sizeof(struct sockaddr_in), connect_address_size); cut_assert_equal_uint(1, n_stopped); cut_assert_equal_uint(0, n_accept); }
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)); }
void test_bool_to_bool(void) { grn_obj_reinit(&context, &dest, GRN_DB_BOOL, 0); cast_bool(TRUE); cut_assert_true(GRN_BOOL_VALUE(&dest)); }
void test_wheel_axes (gconstpointer data) { GtkWidget *button; gint widget_value; const gchar *widget_name; WheelAxisAssertFunction assert_function; widget_name = gcut_data_get_string(data, "widget-name"); assert_function = gcut_data_get_pointer(data, "assert-function"); enable_widget("wheel_emulation_box"); button = get_widget(widget_name); cut_assert_true(GTK_IS_CHECK_BUTTON(button)); cut_assert_equal_int(4, get_scroll_axes_property_of_xinput()); widget_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); assert_function(widget_value); gtk_test_widget_click(button, 1, 0); wait_action(); cut_assert_equal_int(4, get_scroll_axes_property_of_xinput()); widget_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); assert_function(widget_value); }
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_quit (void) { const gchar *packet; gsize packet_size; test_end_of_message_without_chunk(); channel_free(); reply_continue(); cut_assert_true(milter_server_context_quit(context)); pump_all_events(); milter_test_assert_state(QUIT); milter_test_assert_status(NOT_CHANGE); milter_command_encoder_encode_quit(encoder, &packet, &packet_size); milter_test_assert_packet(channel, packet, packet_size); cut_assert_equal_uint(1, n_message_processed); milter_test_assert_result("*****@*****.**", RECIPIENTS("*****@*****.**", NULL), HEADERS("X-HEADER-NAME", "MilterServerContext test", NULL), 20, STATE(END_OF_MESSAGE_REPLIED), STATUS(NOT_CHANGE), HEADERS(NULL), HEADERS(NULL), FALSE); }
void test_memcached_increment(void) { uint32_t flags; uint64_t intval; memcached_return rc; rc = memcached_increment_with_initial(memc, "incr", 4, 1, 30, 0, &intval); cut_assert_equal_int(MEMCACHED_SUCCESS, rc); cut_assert_true(intval == 30); rc = memcached_increment_with_initial(memc, "incr", 4, 3, 0, 0, &intval); cut_assert_equal_int(MEMCACHED_SUCCESS, rc); cut_assert_true(intval == 33); fflush(stderr); }
void test_parse_args_aio(void) { argv[argc()] = "-A"; argv[argc()] = dummy_file; cut_assert_equal_int(0, parse_args(argc(), argv, &option)); cut_assert_true(option.aio); }
void test_in(void) { cut_assert_true(grn_geo_in_rectangle(context, shinjuku_wgs84, sazare_wgs84, hiiragi_wgs84)); }
void test_remove_pid_file_on_exit (void) { gboolean pid_file_exist = FALSE; cut_trace(setup_client()); milter_client_set_pid_file(client, pid_file_path()); milter_event_loop_add_idle_full(loop, G_PRIORITY_HIGH, cb_idle_check_pid_file_existence, &pid_file_exist, NULL); cut_assert_true(milter_client_run(client, &actual_error)); gcut_assert_error(actual_error); cut_assert_true(pid_file_exist); cut_assert_false(g_file_test(pid_file_path(), G_FILE_TEST_EXISTS)); }
static void wait_reaped_helper (gint expected_signal) { GError *error = NULL; gint returned_exit_status; returned_exit_status = gcut_process_wait(process, 1000, &error); gcut_assert_error(error); cut_assert_equal_int(exit_status, returned_exit_status); if (expected_signal) { cut_assert_true(WIFSIGNALED(exit_status)); cut_assert_equal_int(expected_signal, WTERMSIG(exit_status)); } else { cut_assert_true(WIFEXITED(exit_status)); cut_assert_equal_int(EXIT_SUCCESS, WEXITSTATUS(exit_status)); } }
static void stub_success_iterated_test (gconstpointer data) { static int i = 0; i++; cut_assert_true(TRUE, cut_message("always pass")); cut_assert_equal_int(i, GPOINTER_TO_INT(data)); }
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))); }
void test_need_maintain_over_interval (void) { milter_client_set_maintenance_interval(client, 2); milter_client_set_n_processing_sessions(client, 3); milter_client_set_n_processed_sessions(client, 4); cut_assert_true(milter_client_need_maintain(client, 3)); }
void test_cursor(void) { grn_table_cursor *c; database = grn_db_create(context, NULL, NULL); c = grn_table_cursor_open(context, database, NULL, 0, NULL, 0, 0, -1, 0); cut_assert_true(grn_table_cursor_next(context, c)); grn_table_cursor_close(context, c); }