[Groonga-commit] groonga/grnxx at abc0b97 [master] Add tests for Column<T>::contains/find_one(). (#135)

Back to archive index

susumu.yata null+****@clear*****
Fri Dec 26 16:27:55 JST 2014


susumu.yata	2014-12-26 16:27:55 +0900 (Fri, 26 Dec 2014)

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

  Message:
    Add tests for Column<T>::contains/find_one(). (#135)

  Modified files:
    test/test_column.cpp

  Modified: test/test_column.cpp (+32 -0)
===================================================================
--- test/test_column.cpp    2014-12-26 16:13:43 +0900 (b01b954)
+++ test/test_column.cpp    2014-12-26 16:27:55 +0900 (2459174)
@@ -312,6 +312,38 @@ void test_contains_and_find_one() {
     column->remove_index("Index");
   } catch (...) {
   }
+
+  // Remove non-N/A values.
+  for (size_t i = 0; i < NUM_ROWS; ++i) {
+    if (!values[i].is_na()) {
+      table->remove_row(grnxx::Int(i));
+    }
+  }
+
+  // Test all the values.
+  for (size_t i = 0; i < NUM_ROWS; ++i) {
+    if (!values[i].is_na()) {
+      assert(!column->contains(values[i]));
+      assert(column->find_one(values[i]).is_na());
+    }
+  }
+  assert(column->contains(T::na()));
+  assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS)));
+
+  // Test all the values with index if available.
+  try {
+    column->create_index("Index", grnxx::TREE_INDEX);
+    for (size_t i = 0; i < NUM_ROWS; ++i) {
+      if (!values[i].is_na()) {
+        assert(!column->contains(values[i]));
+        assert(column->find_one(values[i]).is_na());
+      }
+    }
+    assert(column->contains(T::na()));
+    assert(column->find_one(T::na()).match(grnxx::Int(NUM_ROWS)));
+    column->remove_index("Index");
+  } catch (...) {
+  }
 }
 
 void test_contains_and_find_one_for_all_data_types() {
-------------- next part --------------
HTML����������������������������...
다운로드 



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