[Groonga-commit] groonga/groonga [master] test: migrate a test from Cutter to grntest style

アーカイブの一覧に戻る

null+****@clear***** null+****@clear*****
2012年 4月 20日 (金) 15:59:52 JST


khayashi	2012-04-20 15:59:52 +0900 (Fri, 20 Apr 2012)

  New Revision: eb334556cacef72403277286ca0856e567637eaf

  Log:
    test: migrate a test from Cutter to grntest style
    
    The test checks the value of load command option(--each) accepts brace.

  Added files:
    test/function/suite/load/each/scalar-geo-point-with-brace.expected
    test/function/suite/load/each/scalar-geo-point-with-brace.test
  Modified files:
    test/unit/core/test-command-load.c

  Added: test/function/suite/load/each/scalar-geo-point-with-brace.expected (+57 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/load/each/scalar-geo-point-with-brace.expected    2012-04-20 15:59:52 +0900 (9587d37)
@@ -0,0 +1,57 @@
+table_create Users TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users location COLUMN_SCALAR WGS84GeoPoint
+[[0,0.0,0.0],true]
+column_create Users distance_from_tokyo_tocho COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+load --table Users --each 'distance_from_tokyo_tocho = geo_distance(location, "128481998x502890001")'
+[
+{"_key": "yurakucho", "location": "128429532x503148672"},
+{"_key": "asagaya", "location": "128536272x502686360"}
+]
+[[0,0.0,0.0],2]
+select Users
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "distance_from_tokyo_tocho",
+          "UInt32"
+        ],
+        [
+          "location",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        1,
+        "yurakucho",
+        6674,
+        "128429532x503148672"
+      ],
+      [
+        2,
+        "asagaya",
+        5364,
+        "128536272x502686360"
+      ]
+    ]
+  ]
+]

  Added: test/function/suite/load/each/scalar-geo-point-with-brace.test (+12 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/load/each/scalar-geo-point-with-brace.test    2012-04-20 15:59:52 +0900 (c4f747f)
@@ -0,0 +1,12 @@
+table_create Users TABLE_HASH_KEY ShortText
+column_create Users location COLUMN_SCALAR WGS84GeoPoint
+column_create Users distance_from_tokyo_tocho COLUMN_SCALAR UInt32
+
+load --table Users \
+--each 'distance_from_tokyo_tocho = geo_distance(location, "128481998x502890001")'
+[
+{"_key": "yurakucho", "location": "128429532x503148672"},
+{"_key": "asagaya", "location": "128536272x502686360"}
+]
+
+select Users

  Modified: test/unit/core/test-command-load.c (+0 -59)
===================================================================
--- test/unit/core/test-command-load.c    2012-04-20 11:31:46 +0900 (cef2687)
+++ test/unit/core/test-command-load.c    2012-04-20 15:59:52 +0900 (e2fd67e)
@@ -457,65 +457,6 @@ test_invalid_table_name(void)
     "]");
 }
 
-void
-data_each(void)
-{
-#define ADD_DATUM(label, load_values_format)                            \
-  gcut_add_datum(label,                                                 \
-                 "load-values-format", G_TYPE_STRING, load_values_format, \
-                 NULL)
-
-  ADD_DATUM("brace",
-            "{\"_key\": \"alice\", \"location\": \"%s\"},"
-            "{\"_key\": \"bob\", \"location\": \"%s\"}");
-
-  ADD_DATUM("bracket",
-            "[\"_key\", \"location\"],"
-            "[\"alice\", \"%s\"],"
-            "[\"bob\", \"%s\"]");
-
-#undef ADD_DATUM
-}
-
-void
-test_each(gconstpointer data)
-{
-  gdouble tokyo_tocho_latitude = 35.689444;
-  gdouble tokyo_tocho_longitude = 139.691667;
-  gdouble yurakucho_latitude = 35.67487;
-  gdouble yurakucho_longitude = 139.76352;
-  gdouble asagaya_latitude = 35.70452;
-  gdouble asagaya_longitude = 139.6351;
-
-  assert_send_command("table_create Users TABLE_HASH_KEY ShortText");
-  assert_send_command("column_create Users location "
-                      "COLUMN_SCALAR WGS84GeoPoint");
-  assert_send_command("column_create Users distance_from_tokyo_tocho "
-                      "COLUMN_SCALAR UInt32");
-  cut_assert_equal_string(
-    "2",
-    send_command(
-      cut_take_printf(
-        "load "
-        "--table Users "
-        "--each 'distance_from_tokyo_tocho = geo_distance(location, \"%s\")' "
-        "--values '[%s]'",
-        grn_test_location_string(tokyo_tocho_latitude, tokyo_tocho_longitude),
-        cut_take_printf(gcut_data_get_string(data, "load-values-format"),
-                        grn_test_location_string(yurakucho_latitude,
-                                                 yurakucho_longitude),
-                        grn_test_location_string(asagaya_latitude,
-                                                 asagaya_longitude)))));
-  cut_assert_equal_string(
-    "[[[2],"
-     "[[\"_id\",\"UInt32\"],"
-      "[\"_key\",\"ShortText\"],"
-      "[\"distance_from_tokyo_tocho\",\"UInt32\"],"
-      "[\"location\",\"WGS84GeoPoint\"]],"
-     "[1,\"alice\",6674,\"128429532x503148672\"],"
-     "[2,\"bob\",5364,\"128536272x502686360\"]]]",
-    send_command("select Users"));
-}
 
 void
 test_vector_reference_column(void)




Groonga-commit メーリングリストの案内
アーカイブの一覧に戻る