[Groonga-commit] groonga/grnxx at 99f0090 [new_data_types] Add a test for Column<Vector<Bool>>. (#110)

Back to archive index

susumu.yata null+****@clear*****
Mon Nov 17 17:14:09 JST 2014


susumu.yata	2014-11-17 17:14:09 +0900 (Mon, 17 Nov 2014)

  New Revision: 99f00908b9cf1f252dcc910185e9959804f74952
  https://github.com/groonga/grnxx/commit/99f00908b9cf1f252dcc910185e9959804f74952

  Message:
    Add a test for Column<Vector<Bool>>. (#110)

  Modified files:
    test/test_column.cpp

  Modified: test/test_column.cpp (+22 -20)
===================================================================
--- test/test_column.cpp    2014-11-17 17:13:49 +0900 (d6676c4)
+++ test/test_column.cpp    2014-11-17 17:14:09 +0900 (a24aef1)
@@ -90,16 +90,14 @@ void test_column() {
   assert(!reference_column->is_key());
 //  assert(int_column->num_indexes() == 0);
 
-//  // Create a column named "BoolVectorColumn".
-//  // The column stores Text values.
-//  auto bool_vector_column = table->create_column(&error, "BoolVectorColumn",
-//                                                 grnxx::BOOL_VECTOR_DATA);
-//  assert(bool_vector_column);
-//  assert(bool_vector_column->table() == table);
-//  assert(bool_vector_column->name() == "BoolVectorColumn");
-//  assert(bool_vector_column->data_type() == grnxx::BOOL_VECTOR_DATA);
-//  assert(!bool_vector_column->ref_table());
-//  assert(!bool_vector_column->has_key_attribute());
+  // Create a column named "BoolVector".
+  auto bool_vector_column =
+      table->create_column("BoolVector", grnxx::BOOL_VECTOR_DATA);
+  assert(bool_vector_column->table() == table);
+  assert(bool_vector_column->name() == "BoolVector");
+  assert(bool_vector_column->data_type() == grnxx::BOOL_VECTOR_DATA);
+  assert(!bool_vector_column->reference_table());
+  assert(!bool_vector_column->is_key());
 //  assert(bool_vector_column->num_indexes() == 0);
 
 //  // Create a column named "IntVectorColumn".
@@ -191,9 +189,9 @@ void test_column() {
   assert(datum.type() == grnxx::INT_DATA);
   assert(datum.as_int().is_na());
 
-//  assert(bool_vector_column->get(&error, 1, &datum));
-//  assert(datum.type() == grnxx::BOOL_VECTOR_DATA);
-//  assert(datum.force_bool_vector() == grnxx::BoolVector{});
+  bool_vector_column->get(row_id, &datum);
+  assert(datum.type() == grnxx::BOOL_VECTOR_DATA);
+  assert(datum.as_bool_vector().is_na());
 
 //  assert(int_vector_column->get(&error, 1, &datum));
 //  assert(datum.type() == grnxx::INT_VECTOR_DATA);
@@ -249,9 +247,18 @@ void test_column() {
   assert(datum.type() == grnxx::INT_DATA);
   assert(datum.as_int().value() == row_id.value());
 
+  grnxx::Bool bool_vector_value[] = {
+    grnxx::Bool(true),
+    grnxx::Bool(false),
+    grnxx::Bool(true)
+  };
+  grnxx::BoolVector bool_vector(bool_vector_value, 3);
+  bool_vector_column->set(row_id, bool_vector);
+  bool_vector_column->get(row_id, &datum);
+  assert(datum.type() == grnxx::BOOL_VECTOR_DATA);
+  assert((datum.as_bool_vector() == bool_vector).is_true());
+
 //  // Set and get values.
-//  assert(bool_vector_column->set(&error, 1,
-//                                 grnxx::BoolVector{ true, false, true }));
 //  grnxx::Int int_vector_value[] = { 123, -456, 789 };
 //  assert(int_vector_column->set(&error, 1,
 //                                grnxx::IntVector(int_vector_value, 3)));
@@ -270,11 +277,6 @@ void test_column() {
 //  assert(ref_vector_column->set(&error, 1,
 //                                grnxx::IntVector(ref_vector_value, 3)));
 
-//  assert(bool_vector_column->get(&error, 1, &datum));
-//  assert(datum.type() == grnxx::BOOL_VECTOR_DATA);
-//  assert(datum.force_bool_vector() ==
-//         grnxx::BoolVector({ true, false, true }));
-
 //  assert(int_vector_column->get(&error, 1, &datum));
 //  assert(datum.type() == grnxx::INT_VECTOR_DATA);
 //  assert(datum.force_int_vector() ==
-------------- next part --------------
HTML����������������������������...
下載 



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