Ejemplo n.º 1
0
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));
  }
}
Ejemplo n.º 2
0
void
grn_test_assert_equal_rc_helper(grn_rc expected, grn_rc actual,
                                const gchar *expression_expected,
                                const gchar *expression_actual)
{
  if (expected == actual) {
    cut_test_pass();
  } else {
    cut_test_fail(cut_take_printf("<%s> == <%s>\n"
                                  "expected: <%s>\n"
                                  " but was: <%s>",
                                  expression_expected,
                                  expression_actual,
                                  grn_rc_to_string(expected),
                                  grn_rc_to_string(actual)));
  }
}
Ejemplo n.º 3
0
void
grn_test_assert_context_helper (grn_ctx *context, const gchar *expression)
{
  if (!context) {
    cut_set_message("context should not NULL");
    cut_assert_null_helper(context, expression);
  } else if (context->rc == GRN_SUCCESS) {
    cut_test_pass();
  } else {
    cut_test_fail(cut_take_printf("<(%s)->rc> != <GRN_SUCCESS>\n"
                                  "expected: <%s> is <%s>\n"
                                  "%s:%d: %s(): %s",
                                  expression,
                                  grn_rc_to_string(context->rc),
                                  grn_rc_to_string(GRN_SUCCESS),
                                  context->errfile, context->errline,
                                  context->errfunc, context->errbuf));
  }
}
Ejemplo n.º 4
0
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));
  }
}
Ejemplo n.º 5
0
void
grn_test_assert_helper(grn_rc rc, const gchar *expression)
{
  if (rc == GRN_SUCCESS) {
    cut_test_pass();
  } else {
    cut_test_fail(cut_take_printf("expected: <%s> == grn_success\n"
                                  " but was: <%s>",
                                  expression,
                                  grn_rc_to_string(rc)));
  }
}