null+****@clear*****
null+****@clear*****
2012年 2月 10日 (金) 15:54:53 JST
Kouhei Sutou 2012-02-10 15:54:53 +0900 (Fri, 10 Feb 2012)
New Revision: 9b3c89b905be5834dae39cb36f0886c16e87ab53
Log:
[test] add grn_test_assert_equal_type().
Modified files:
test/unit/lib/grn-assertions.c
test/unit/lib/grn-assertions.h
Modified: test/unit/lib/grn-assertions.c (+39 -1)
===================================================================
--- test/unit/lib/grn-assertions.c 2012-02-10 15:54:27 +0900 (6fb74c0)
+++ test/unit/lib/grn-assertions.c 2012-02-10 15:54:53 +0900 (e603d87)
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
- Copyright (C) 2008-2010 Kouhei Sutou <kou****@clear*****>
+ Copyright (C) 2008-2012 Kouhei Sutou <kou****@clear*****>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -100,6 +100,44 @@ grn_test_assert_equal_id_helper(grn_ctx *context,
}
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));
+ }
+}
+
+void
grn_test_assert_equal_record_id_helper(grn_ctx *context, grn_obj *table,
grn_id expected, grn_id actual,
const gchar *expression_context,
Modified: test/unit/lib/grn-assertions.h (+18 -1)
===================================================================
--- test/unit/lib/grn-assertions.h 2012-02-10 15:54:27 +0900 (e58fd96)
+++ test/unit/lib/grn-assertions.h 2012-02-10 15:54:53 +0900 (c0616b1)
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
- Copyright (C) 2008-2010 Kouhei Sutou <kou****@clear*****>
+ Copyright (C) 2008-2012 Kouhei Sutou <kou****@clear*****>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -47,6 +47,16 @@
__VA_ARGS__), \
grn_test_assert_equal_id(context, expected, actual))
+#define grn_test_assert_equal_type(context, expected, actual, ...) \
+ cut_trace_with_info_expression( \
+ cut_test_with_user_message( \
+ grn_test_assert_equal_type_helper((context), \
+ (expected), (actual), \
+ #context, \
+ #expected, #actual), \
+ __VA_ARGS__), \
+ grn_test_assert_equal_type(context, expected, actual))
+
#define grn_test_assert_equal_record_id(context, table, \
expected, actual, ...) \
cut_trace_with_info_expression( \
@@ -182,6 +192,13 @@ void grn_test_assert_equal_id_helper(grn_ctx *context,
const gchar *expression_context,
const gchar *expression_expected,
const gchar *expression_actual);
+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);
void grn_test_assert_equal_record_id_helper
(grn_ctx *context,
grn_obj *table,