コード例 #1
0
void
soupcut_client_assert_equal_body_helper (const gchar   *expected,
                                         SoupCutClient *client,
                                         const gchar   *expression_expected,
                                         const gchar   *expression_client)
{
    const gchar *body;
    SoupMessage *message;

    message = soupcut_client_get_latest_message(client);
    if (!message) {
        soupcut_test_fail_null_message(client, expression_client);
    }

    body = message->response_body->data;
    if (cut_utils_equal_string(expected, body)) {
        cut_test_pass();
    } else {
        cut_set_expected(cut_take_inspect_string(expected));
        cut_set_actual(cut_take_inspect_string(body));
        cut_test_fail(
            cut_take_printf("<%s == latest_message(%s)[response][body]>",
                            expression_expected,
                            expression_client));
    }
}
コード例 #2
0
void
soupcut_client_assert_equal_content_type_helper (const gchar *expected,
                                                 SoupCutClient *client,
                                                 const gchar *expression_expected,
                                                 const gchar *expression_client)
{
    const gchar *content_type;
    SoupMessage *message;

    message = soupcut_client_get_latest_message(client);
    if (!message) {
        soupcut_test_fail_null_message(client, expression_client);
    }

    content_type = soupcut_message_get_content_type(message);
    if (cut_utils_equal_string(expected, content_type)) {
        cut_test_pass();
    } else {
        cut_set_expected(cut_take_inspect_string(expected));
        cut_set_actual(cut_take_inspect_string(content_type));
        cut_test_fail(
            cut_take_printf("<%s == latest_message(%s)[response][content-type]>",
                            expression_expected,
                            expression_client));
    }
}
コード例 #3
0
void
soupcut_message_assert_equal_content_type_helper (const gchar *expected,
                                                  SoupMessage *message,
                                                  const gchar *expression_expected,
                                                  const gchar *expression_message)
{
    const gchar *content_type;

    content_type = soupcut_message_get_content_type(message);
    if (cut_utils_equal_string(expected, content_type)) {
        cut_test_pass();
    } else {
        cut_set_expected(cut_take_inspect_string(expected));
        cut_set_actual(cut_take_inspect_string(content_type));
        cut_test_fail(cut_take_printf("<%s == %s[response][content-type]>",
                                       expression_expected,
                                       expression_message));
    }
}
コード例 #4
0
CPPCUT_DECL void
cut::assert_equal_reference<std::type_info>(const std::type_info& expected,
                                            const std::type_info& actual,
                                            const char *expression_expected,
                                            const char *expression_actual)
{
    if (expected == actual) {
        cut_test_pass();
    } else {
        std::ostringstream message;

        cut_set_expected(expected.name());
        cut_set_actual(actual.name());

        message << "<" << expression_expected << " == ";
        message << expression_actual << ">";
        cut_test_fail(message.str().c_str());
    }
}
コード例 #5
0
ファイル: grn-assertions.c プロジェクト: WEIC-DEV/groonga
void
grn_test_assert_equal_id_helper(grn_ctx *context,
                                grn_id expected, grn_id actual,
                                const gchar *expression_context,
                                const gchar *expression_expected,
                                const gchar *expression_actual)
{
  if (expected == actual) {
    cut_test_pass();
  } else {
    grn_obj *expected_object, *actual_object;
    grn_obj inspected_expected_object, inspected_actual_object;

    expected_object = grn_ctx_at(context, expected);
    actual_object = grn_ctx_at(context, actual);
    GRN_TEXT_INIT(&inspected_expected_object, 0);
    GRN_TEXT_INIT(&inspected_actual_object, 0);
    grn_inspect(context, &inspected_expected_object, expected_object);
    grn_inspect(context, &inspected_actual_object, actual_object);
    cut_set_expected(
      cut_take_printf("%d: <%.*s>",
                      expected,
                      (int)GRN_TEXT_LEN(&inspected_expected_object),
                      GRN_TEXT_VALUE(&inspected_expected_object)));
    cut_set_actual(
      cut_take_printf("%d: <%.*s>",
                      actual,
                      (int)GRN_TEXT_LEN(&inspected_actual_object),
                      GRN_TEXT_VALUE(&inspected_actual_object)));
    grn_obj_unlink(context, &inspected_expected_object);
    grn_obj_unlink(context, &inspected_actual_object);
    grn_obj_unlink(context, expected_object);
    grn_obj_unlink(context, actual_object);
    cut_test_fail(cut_take_printf("<%s> == <%s> (%s)\n"
                                  " context: <%p>",
                                  expression_expected,
                                  expression_actual,
                                  expression_context,
                                  context));
  }
}
コード例 #6
0
ファイル: grn-assertions.c プロジェクト: WEIC-DEV/groonga
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));
  }
}
コード例 #7
0
void soupcut_client_assert_response_helper (SoupCutClient *client,
                                            const gchar   *expression_client)
{
    SoupMessage *message;

    message = soupcut_client_get_latest_message(client);
    if (!message) {
        soupcut_test_fail_null_message(client, expression_client);
    }

    if (200 <= message->status_code && message->status_code < 300) {
        cut_test_pass();
    } else {
        cut_set_expected("2XX");
        cut_set_actual(cut_take_printf("%u(%s)",
                                       message->status_code,
                                       message->reason_phrase));
        cut_test_fail(
            cut_take_printf("<latest_message(%s)[response][status] == 2XX>",
                            expression_client));
    }
}
コード例 #8
0
ファイル: grn-assertions.c プロジェクト: WEIC-DEV/groonga
void
grn_test_assert_equal_record_id_helper(grn_ctx *context, grn_obj *table,
                                       grn_id expected, grn_id actual,
                                       const gchar *expression_context,
                                       const gchar *expression_table,
                                       const gchar *expression_expected,
                                       const gchar *expression_actual)
{
  if (expected == actual) {
    cut_test_pass();
  } else {
    gchar key[GRN_TABLE_MAX_KEY_SIZE];
    int key_size;
    const gchar *message;
    grn_obj inspected_table;

    key_size = grn_table_get_key(context, table, expected, key, sizeof(key));
    cut_set_expected(cut_take_printf("%d: <%.*s>", expected, key_size, key));
    key_size = grn_table_get_key(context, table, actual, key, sizeof(key));
    cut_set_actual(cut_take_printf("%d: <%.*s>", actual, key_size, key));

    GRN_TEXT_INIT(&inspected_table, 0);
    grn_inspect(context, &inspected_table, table);
    message = cut_take_printf("<%s> == <%s> (context: <%s>, table: <%s>)\n"
                              " context: <%p>\n"
                              "   table: <%.*s>",
                              expression_expected,
                              expression_actual,
                              expression_context,
                              expression_table,
                              context,
                              (int)GRN_TEXT_LEN(&inspected_table),
                              GRN_TEXT_VALUE(&inspected_table));
    grn_obj_unlink(context, &inspected_table);
    cut_test_fail(message);
  }
}
コード例 #9
0
ファイル: grn-assertions.c プロジェクト: WEIC-DEV/groonga
void
grn_test_assert_equal_type_helper(grn_ctx *context,
                                  unsigned char expected,
                                  unsigned char actual,
                                  const gchar *expression_context,
                                  const gchar *expression_expected,
                                  const gchar *expression_actual)
{
  if (expected == actual) {
    cut_test_pass();
  } else {
    grn_obj inspected_expected, inspected_actual;

    GRN_TEXT_INIT(&inspected_expected, 0);
    GRN_TEXT_INIT(&inspected_actual, 0);
    grn_inspect_type(context, &inspected_expected, expected);
    grn_inspect_type(context, &inspected_actual, actual);
    cut_set_expected(
      cut_take_printf("%x: <%.*s>",
                      expected,
                      (int)GRN_TEXT_LEN(&inspected_expected),
                      GRN_TEXT_VALUE(&inspected_expected)));
    cut_set_actual(
      cut_take_printf("%x: <%.*s>",
                      actual,
                      (int)GRN_TEXT_LEN(&inspected_actual),
                      GRN_TEXT_VALUE(&inspected_actual)));
    grn_obj_unlink(context, &inspected_expected);
    grn_obj_unlink(context, &inspected_actual);
    cut_test_fail(cut_take_printf("<%s> == <%s> (%s)\n"
                                  " context: <%p>",
                                  expression_expected,
                                  expression_actual,
                                  expression_context,
                                  context));
  }
}