[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] add bitmap macro and test.

Back to archive index

mir null+****@clear*****
Thu Oct 4 10:19:35 JST 2012


mir	2009-08-08 16:03:21 +0900 (Sat, 08 Aug 2009)

  New Revision: 56e3ca6a88e63ab3188ff7b79bce4188d96a6f46
  https://github.com/mroonga/mroonga/commit/56e3ca6a88e63ab3188ff7b79bce4188d96a6f46

  Log:
    add bitmap macro and test.

  Modified files:
    driver.h
    test/unit/test-driver.c

  Modified: driver.h (+9 -0)
===================================================================
--- driver.h    2009-08-08 13:47:04 +0900 (20172e4)
+++ driver.h    2009-08-08 16:03:21 +0900 (7ea520a)
@@ -95,6 +95,15 @@ typedef struct _mrn_record
 #define MRN_HANDLER_NAME(obj_name) (obj_name - 2)
 #define MRN_TABLE_NAME(name) (name + 2)
 
+typedef unsigned char uchar;
+
+#define MRN_IS_BIT(map,idx) \
+  (uint) (((uchar*)map)[(idx)/8] & (1 << ((idx)&7)))
+#define MRN_SET_BIT(map,idx) \
+  (((uchar*)map)[(idx)/8] |= (1 << ((idx)&7)))
+#define MRN_CLEAR_BIT(map,idx) \
+  (((uchar*)map)[(idx)/8] &= ~(1 << ((idx)&7)))
+
 /* functions */
 int mrn_init();
 int mrn_deinit();

  Modified: test/unit/test-driver.c (+17 -0)
===================================================================
--- test/unit/test-driver.c    2009-08-08 13:47:04 +0900 (4a0824b)
+++ test/unit/test-driver.c    2009-08-08 16:03:21 +0900 (c979669)
@@ -798,3 +798,20 @@ void test_mrn_rnd_next_cond()
   cut_assert_equal_int(0, mrn_drop(ctx, "test/mrn_rnd_next_cond"));
   mrn_deinit_obj_info(ctx, info);
 }
+
+void test_mrn_bitmap_macro()
+{
+  uchar *a;
+  a = g_malloc(128);
+  memset(a,0,128);
+  int i;
+  for (i=0; i < 128*8; i++)
+  {
+    cut_assert_false(MRN_IS_BIT(a,i),"precheck: idx=%d",i);
+    MRN_SET_BIT(a,i);
+    cut_assert_true(MRN_IS_BIT(a,i),"after set: idx=%d",i);
+    MRN_CLEAR_BIT(a,i);
+    cut_assert_false(MRN_IS_BIT(a,i),"after clear: idx=%d",i);
+  }
+  g_free(a);
+}
-------------- next part --------------
HTML����������������������������...
Download 



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