static gboolean attachment_equal (gconstpointer data1, gconstpointer data2) { const PopplerAttachment *attachment1 = data1; const PopplerAttachment *attachment2 = data2; if (attachment1 == attachment2) return TRUE; if (attachment1 == NULL || attachment2 == NULL) return FALSE; if ((attachment1->checksum != attachment2->checksum) && (attachment1->checksum == NULL || attachment2->checksum == NULL)) return FALSE; return cut_equal_string (attachment1->name, attachment2->name) && cut_equal_string (attachment1->description, attachment2->description) && attachment1->size == attachment2->size && attachment1->mtime == attachment2->mtime && attachment1->ctime == attachment2->ctime && (attachment1->checksum == attachment2->checksum || cut_equal_string (attachment1->checksum->str, attachment2->checksum->str)); }
void grn_test_assert_error_helper (grn_rc expected_rc, const gchar *expected_message, grn_ctx *context, const gchar *expression) { if (!context) { cut_test_with_user_message( cut_assert_null_helper(context, expression), cut_message("context should not NULL")); } else if (context->rc == expected_rc && cut_equal_string(expected_message, context->errbuf)) { cut_test_pass(); } else { cut_test_fail(cut_take_printf("<%s>\n" "expected: <%s>(%s)\n" " actual: <%s>(%s)\n" "%s:%d: %s():", expression, expected_message, grn_rc_to_string(expected_rc), context->errbuf, grn_rc_to_string(context->rc), context->errfile, context->errline, context->errfunc)); } }
void grn_test_assert_send_command_error_helper (grn_ctx *context, grn_rc expected_rc, const gchar *expected_message, const gchar *command, const gchar *expected_rc_expression, const gchar *expected_message_expression, const gchar *command_expression) { const gchar **lines; lines = cut_take_string_array(g_strsplit(command, "\n", 0)); for (; *lines; lines++) { grn_ctx_send(context, *lines, strlen(*lines), 0); if (context->rc) { break; } } if (context->rc == expected_rc && cut_equal_string(expected_message, context->errbuf)) { gchar *command_result; unsigned int command_result_length; int flags = 0; cut_test_pass(); grn_ctx_recv(context, &command_result, &command_result_length, &flags); } else { cut_set_expected(cut_take_printf("<%s>(%s)", expected_message, grn_rc_to_string(expected_rc))); cut_set_actual(cut_take_printf("<%s>(%s)", context->errbuf, grn_rc_to_string(context->rc))); cut_test_fail(cut_take_printf("<send(\"%s\")>\n" "%s:%d: %s():", command_expression, context->errfile, context->errline, context->errfunc)); } }
static void cut_poppler_assert_equal_property_helper (const gchar *title, const gchar *format, const gchar *author, const gchar *subject, const gchar *keywords, GTime creation_date, GTime mod_date, const gchar *creator, const gchar *producer, const gchar *linearized, PopplerPageMode mode, PopplerPageLayout layout, PopplerViewerPreferences viewer_preferences, PopplerPermissions permissions, PopplerDocument *document) { gchar *actual_title; gchar *actual_format; gchar *actual_author; gchar *actual_subject; gchar *actual_keywords; GTime actual_creation_date; GTime actual_mod_date; gchar *actual_creator; gchar *actual_producer; gchar *actual_linearized; PopplerPageMode actual_mode; PopplerPageLayout actual_layout; PopplerViewerPreferences actual_viewer_preferences; PopplerPermissions actual_permissions; g_object_get (document, "title", &actual_title, "format", &actual_format, "author", &actual_author, "subject", &actual_subject, "keywords", &actual_keywords, "creation-date", &actual_creation_date, "mod-date", &actual_mod_date, "creator", &actual_creator, "producer", &actual_producer, "linearized", &actual_linearized, "page-mode", &actual_mode, "page-layout", &actual_layout, "viewer-preferences", &actual_viewer_preferences, "permissions", &actual_permissions, NULL); if (cut_equal_string (title, actual_title) && cut_equal_string (format, actual_format) && cut_equal_string (author, actual_author) && cut_equal_string (subject, actual_subject) && cut_equal_string (keywords, actual_keywords) && creation_date == actual_creation_date && mod_date == actual_mod_date && cut_equal_string (creator, actual_creator) && cut_equal_string (producer, actual_producer) && cut_equal_string (linearized, actual_linearized) && mode == actual_mode && layout == actual_layout && viewer_preferences == actual_viewer_preferences && permissions == actual_permissions) { cut_test_pass (); } else { gchar *inspected_expected; gchar *inspected_actual; const gchar *message; inspected_expected = inspect_property (title, format, author, subject, keywords, creation_date, mod_date, creator, producer, linearized, mode, layout, viewer_preferences, permissions); inspected_actual = inspect_property (actual_title, actual_format, actual_author, actual_subject, actual_keywords, actual_creation_date, actual_mod_date, actual_creator, actual_producer, actual_linearized, actual_mode, actual_layout, actual_viewer_preferences, actual_permissions); message = cut_take_printf ("expected: <%s>\n" " actual: <%s>", inspected_expected, inspected_actual); message = cut_append_diff (message, inspected_expected, inspected_actual); g_free (inspected_expected); g_free (inspected_actual); cut_fail ("%s", message); } }