[Groonga-commit] groonga/groonga [master] Support bool -> bool cast

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Wed Feb 13 22:22:46 JST 2013


Kouhei Sutou	2013-02-13 22:22:46 +0900 (Wed, 13 Feb 2013)

  New Revision: 6e6cc136e1f88b0f108ed10f2e891b96e51bb215
  https://github.com/groonga/groonga/commit/6e6cc136e1f88b0f108ed10f2e891b96e51bb215

  Log:
    Support bool -> bool cast

  Modified files:
    lib/db.c
    test/unit/core/test-cast-basic.c

  Modified: lib/db.c (+3 -0)
===================================================================
--- lib/db.c    2013-02-13 21:46:16 +0900 (ffa060b)
+++ lib/db.c    2013-02-13 22:22:46 +0900 (d78c2d8)
@@ -4209,6 +4209,9 @@ grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
   grn_rc rc = GRN_SUCCESS;
 
   switch (dest->header.domain) {
+  case GRN_DB_BOOL :
+    GRN_BOOL_SET(ctx, dest, GRN_BOOL_VALUE(src));
+    break;
   default :
     SRC2RECORD();
   }

  Modified: test/unit/core/test-cast-basic.c (+24 -0)
===================================================================
--- test/unit/core/test-cast-basic.c    2013-02-13 21:46:16 +0900 (d7effe6)
+++ test/unit/core/test-cast-basic.c    2013-02-13 22:22:46 +0900 (6f205d8)
@@ -50,6 +50,8 @@ void test_text_to_geo_point_mixed_invalid(void);
 void data_text_error(void);
 void test_text_error(gconstpointer data);
 
+void test_bool_to_bool(void);
+
 void data_int32_to_bool(void);
 void test_int32_to_bool(gconstpointer data);
 void test_int32_to_int8(void);
@@ -411,6 +413,28 @@ test_text_error(gconstpointer data)
 }
 
 static void
+set_bool(gboolean boolean)
+{
+  grn_obj_reinit(&context, &src, GRN_DB_BOOL, 0);
+  GRN_BOOL_SET(&context, &src, boolean);
+}
+
+static void
+cast_bool(gboolean boolean)
+{
+  set_bool(boolean);
+  grn_test_assert(grn_obj_cast(&context, &src, &dest, GRN_FALSE));
+}
+
+void
+test_bool_to_bool(void)
+{
+  grn_obj_reinit(&context, &dest, GRN_DB_BOOL, 0);
+  cast_bool(TRUE);
+  cut_assert_true(GRN_BOOL_VALUE(&dest));
+}
+
+static void
 set_int32(gint32 number)
 {
   grn_obj_reinit(&context, &src, GRN_DB_INT32, 0);
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る