[Groonga-commit] groonga/grnxx at c3bd825 [master] Add tests for grnxx::Array<bool>.

Back to archive index

susumu.yata null+****@clear*****
Thu May 16 16:27:28 JST 2013


susumu.yata	2013-05-16 16:27:28 +0900 (Thu, 16 May 2013)

  New Revision: c3bd825e0fb215a3a159e99c26a2c55c6e81e6f0
  https://github.com/groonga/grnxx/commit/c3bd825e0fb215a3a159e99c26a2c55c6e81e6f0

  Message:
    Add tests for grnxx::Array<bool>.

  Modified files:
    test/test_array.cpp

  Modified: test/test_array.cpp (+38 -0)
===================================================================
--- test/test_array.cpp    2013-05-16 16:26:10 +0900 (992c090)
+++ test/test_array.cpp    2013-05-16 16:27:28 +0900 (98ce371)
@@ -141,6 +141,43 @@ void test_array3d() {
   }
 }
 
+void test_bit_array() {
+  constexpr std::uint64_t PAGE_SIZE            = 64;
+  constexpr std::uint64_t TABLE_SIZE           = 32;
+  constexpr std::uint64_t SECONDARY_TABLE_SIZE = 16;
+  constexpr std::uint64_t SIZE                 =
+      PAGE_SIZE * TABLE_SIZE * SECONDARY_TABLE_SIZE;
+
+  GRNXX_NOTICE() << __PRETTY_FUNCTION__;
+
+  std::unique_ptr<grnxx::Storage> storage(grnxx::Storage::create(nullptr));
+  grnxx::Array<bool, PAGE_SIZE, TABLE_SIZE, SECONDARY_TABLE_SIZE> array;
+
+  assert(array.create(storage.get(), grnxx::STORAGE_ROOT_NODE_ID));
+  assert(array);
+  assert(array.page_size() == PAGE_SIZE);
+  assert(array.table_size() == TABLE_SIZE);
+  assert(array.secondary_table_size() == SECONDARY_TABLE_SIZE);
+  assert(array.size() == SIZE);
+  for (std::uint64_t i = 0; i < SIZE; ++i) {
+    const bool value = (i % 3) != 0;
+    assert(array.set(i, value));
+  }
+  for (std::uint64_t i = 0; i < SIZE; ++i) {
+    const bool expected_value = (i % 3) != 0;
+    bool value;
+    assert(array.get(i, &value));
+    assert(value == expected_value);
+  }
+  for (std::uint64_t i = 0; i < SIZE; ++i) {
+    const bool expected_value = (i % 3) != 0;
+    assert(array[i] == expected_value);
+  }
+  for (std::uint64_t i = 0; i < (SIZE / PAGE_SIZE); ++i) {
+    assert(array.get_page(i));
+  }
+}
+
 }  // namesapce
 
 int main() {
@@ -151,6 +188,7 @@ int main() {
   test_array1d();
   test_array2d();
   test_array3d();
+  test_bit_array();
 
   return 0;
 }
-------------- next part --------------
HTML����������������������������...
Download 



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