[Groonga-commit] groonga/grnxx at b081010 [master] Add a test for Column<Vector<GeoPoint>>. (#110)

Back to archive index

susumu.yata null+****@clear*****
Tue Dec 16 10:54:38 JST 2014


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

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

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

  Modified files:
    test/test_column.cpp

  Modified: test/test_column.cpp (+23 -24)
===================================================================
--- test/test_column.cpp    2014-11-17 17:51:36 +0900 (7fe4745)
+++ test/test_column.cpp    2014-11-17 17:51:51 +0900 (1bbe446)
@@ -121,16 +121,14 @@ void test_column() {
   assert(!float_vector_column->is_key());
 //  assert(float_vector_column->num_indexes() == 0);
 
-//  // Create a column named "GeoPointVectorColumn".
-//  // The column stores Text values.
-//  auto geo_point_vector_column = table->create_column(
-//      &error, "GeoPointVectorColumn", grnxx::GEO_POINT_VECTOR_DATA);
-//  assert(geo_point_vector_column);
-//  assert(geo_point_vector_column->table() == table);
-//  assert(geo_point_vector_column->name() == "GeoPointVectorColumn");
-//  assert(geo_point_vector_column->data_type() == grnxx::GEO_POINT_VECTOR_DATA);
-//  assert(!geo_point_vector_column->ref_table());
-//  assert(!geo_point_vector_column->has_key_attribute());
+  // Create a column named "GeoPointVector".
+  auto geo_point_vector_column =
+      table->create_column("GeoPointVector", grnxx::GEO_POINT_VECTOR_DATA);
+  assert(geo_point_vector_column->table() == table);
+  assert(geo_point_vector_column->name() == "GeoPointVector");
+  assert(geo_point_vector_column->data_type() == grnxx::GEO_POINT_VECTOR_DATA);
+  assert(!geo_point_vector_column->reference_table());
+  assert(!geo_point_vector_column->is_key());
 //  assert(geo_point_vector_column->num_indexes() == 0);
 
 //  // Create a column named "TextVectorColumn".
@@ -198,9 +196,9 @@ void test_column() {
   assert(datum.type() == grnxx::FLOAT_VECTOR_DATA);
   assert(datum.as_float_vector().is_na());
 
-//  assert(geo_point_vector_column->get(&error, 1, &datum));
-//  assert(datum.type() == grnxx::GEO_POINT_VECTOR_DATA);
-//  assert(datum.force_geo_point_vector() == grnxx::GeoPointVector(nullptr, 0));
+  geo_point_vector_column->get(row_id, &datum);
+  assert(datum.type() == grnxx::GEO_POINT_VECTOR_DATA);
+  assert(datum.as_geo_point_vector().is_na());
 
 //  assert(text_vector_column->get(&error, 1, &datum));
 //  assert(datum.type() == grnxx::TEXT_VECTOR_DATA);
@@ -237,7 +235,7 @@ void test_column() {
   text_column->set(row_id, text);
   text_column->get(row_id, &datum);
   assert(datum.type() == grnxx::TEXT_DATA);
-//  assert(datum.as_text() == text);
+  assert((datum.as_text() == text).is_true());
 
   reference_column->set(row_id, row_id);
   reference_column->get(row_id, &datum);
@@ -277,12 +275,18 @@ void test_column() {
   assert(datum.type() == grnxx::FLOAT_VECTOR_DATA);
   assert((datum.as_float_vector() == float_vector).is_true());
 
+  grnxx::GeoPoint geo_point_vector_value[] = {
+    { grnxx::Float(43.068661), grnxx::Float(141.350755) },  // Sapporo.
+    { grnxx::Float(35.681382), grnxx::Float(139.766084) },  // Tokyo.
+    { grnxx::Float(34.702485), grnxx::Float(135.495951) },  // Osaka.
+  };
+  grnxx::GeoPointVector geo_point_vector(geo_point_vector_value, 3);
+  geo_point_vector_column->set(row_id, geo_point_vector);
+  geo_point_vector_column->get(row_id, &datum);
+  assert(datum.type() == grnxx::GEO_POINT_VECTOR_DATA);
+  assert((datum.as_geo_point_vector() == geo_point_vector).is_true());
+
 //  // Set and get values.
-//  grnxx::GeoPoint geo_point_vector_value[] = {
-//    { 123, 456 }, { 789, 123 }, { 456, 789 }
-//  };
-//  assert(geo_point_vector_column->set(
-//      &error, 1, grnxx::GeoPointVector(geo_point_vector_value, 3)));
 //  grnxx::Text text_vector_value[] = { "abc", "DEF", "ghi" };
 //  assert(text_vector_column->set(&error, 1,
 //                                 grnxx::TextVector(text_vector_value, 3)));
@@ -290,11 +294,6 @@ void test_column() {
 //  assert(ref_vector_column->set(&error, 1,
 //                                grnxx::IntVector(ref_vector_value, 3)));
 
-//  assert(geo_point_vector_column->get(&error, 1, &datum));
-//  assert(datum.type() == grnxx::GEO_POINT_VECTOR_DATA);
-//  assert(datum.force_geo_point_vector() ==
-//         grnxx::GeoPointVector(geo_point_vector_value, 3));
-
 //  assert(text_vector_column->get(&error, 1, &datum));
 //  assert(datum.type() == grnxx::TEXT_VECTOR_DATA);
 //  assert(datum.force_text_vector() ==
-------------- next part --------------
HTML����������������������������...
다운로드 



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