[Groonga-commit] groonga/groonga at 1b27f4a [master] test: add a test for false case of grn_operator_exec_equal()

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Mar 10 15:27:09 JST 2015


Kouhei Sutou	2015-03-10 15:27:09 +0900 (Tue, 10 Mar 2015)

  New Revision: 1b27f4ac7196e98e340638c6b8bc315e733161e4
  https://github.com/groonga/groonga/commit/1b27f4ac7196e98e340638c6b8bc315e733161e4

  Message:
    test: add a test for false case of grn_operator_exec_equal()

  Modified files:
    test/unit/core/test-operator.c

  Modified: test/unit/core/test-operator.c (+45 -0)
===================================================================
--- test/unit/core/test-operator.c    2015-03-10 14:50:48 +0900 (4f590f3)
+++ test/unit/core/test-operator.c    2015-03-10 15:27:09 +0900 (800a714)
@@ -27,6 +27,8 @@
 
 void data_exec_equal_true(void);
 void test_exec_equal_true(gconstpointer data);
+void data_exec_equal_false(void);
+void test_exec_equal_false(gconstpointer data);
 
 static gchar *tmp_directory;
 
@@ -99,6 +101,18 @@ set_one(grn_obj *value, const gchar *type)
   }
 }
 
+static void
+set_two(grn_obj *value, const gchar *type)
+{
+  if (strcmp(type, "text") == 0) {
+    grn_obj_reinit(context, value, GRN_DB_TEXT, 0);
+    GRN_TEXT_SETS(context, value, "2");
+  } else if (strcmp(type, "int32") == 0) {
+    grn_obj_reinit(context, value, GRN_DB_INT32, 0);
+    GRN_INT32_SET(context, value, 2);
+  }
+}
+
 void
 data_exec_equal_true(void)
 {
@@ -129,3 +143,34 @@ test_exec_equal_true(gconstpointer data)
 
   cut_assert_true(grn_operator_exec_equal(context, &lhs, &rhs));
 }
+
+void
+data_exec_equal_false(void)
+{
+#define ADD_DATA(lhs_type, rhs_type)                            \
+  gcut_add_datum(lhs_type " == " rhs_type,                      \
+                 "lhs_type", G_TYPE_STRING, lhs_type,           \
+                 "rhs_type", G_TYPE_STRING, rhs_type,           \
+                 NULL)
+
+  ADD_DATA("text", "text");
+  ADD_DATA("text", "int32");
+  ADD_DATA("int32", "text");
+
+#undef ADD_DATA
+}
+
+void
+test_exec_equal_false(gconstpointer data)
+{
+  const gchar *lhs_type;
+  const gchar *rhs_type;
+
+  lhs_type = gcut_data_get_string(data, "lhs_type");
+  rhs_type = gcut_data_get_string(data, "rhs_type");
+
+  set_one(&lhs, lhs_type);
+  set_two(&rhs, rhs_type);
+
+  cut_assert_false(grn_operator_exec_equal(context, &lhs, &rhs));
+}
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index