[Groonga-commit] groonga/grnxx at fcd57da [master] Add a test for grnxx::Storage::num_nodes().

Back to archive index

susumu.yata null+****@clear*****
Fri May 24 10:55:23 JST 2013


susumu.yata	2013-05-24 10:55:23 +0900 (Fri, 24 May 2013)

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

  Message:
    Add a test for grnxx::Storage::num_nodes().

  Modified files:
    test/test_storage.cpp

  Modified: test/test_storage.cpp (+18 -0)
===================================================================
--- test/test_storage.cpp    2013-05-24 10:55:04 +0900 (1712e64)
+++ test/test_storage.cpp    2013-05-24 10:55:23 +0900 (fc69217)
@@ -656,6 +656,23 @@ void test_storage_max_num_files() {
   assert(storage->max_num_files() == options.max_num_files);
 }
 
+void test_storage_num_nodes() {
+  grnxx::StorageNode node;
+  std::unique_ptr<grnxx::Storage> storage(grnxx::Storage::create(nullptr));
+  assert(storage->num_nodes() == 1);
+  node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 24);
+  assert(node);
+  assert(storage->num_nodes() == 2);
+  assert(storage->unlink_node(node.id()));
+  assert(storage->num_nodes() == 2);
+  assert(storage->sweep(grnxx::Duration(0)));
+  assert(storage->num_nodes() == 1);
+  for (int i = 0; i < 16; ++i) {
+    assert(storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 24));
+    assert(storage->num_nodes() == static_cast<std::uint32_t>(i + 2));
+  }
+}
+
 void test_storage_body_usage() {
   uint64_t prev_body_usage = 0;
   grnxx::StorageNode node;
@@ -787,6 +804,7 @@ void test_storage() {
   test_storage_flags();
   test_storage_max_file_size();
   test_storage_max_num_files();
+  test_storage_num_nodes();
   test_storage_body_usage();
   test_storage_body_size();
   test_storage_total_size();
-------------- next part --------------
HTML����������������������������...
下載 



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