null+****@clear*****
null+****@clear*****
2011年 12月 28日 (水) 13:13:42 JST
Kouhei Sutou 2011-12-28 13:13:42 +0900 (Wed, 28 Dec 2011) New Revision: 483080cde5e1d4e4d26f1f81666fafcb292c6137 Log: [geo] add tests for abbreviated approximate type for geo_distance(). refs #1226 Modified files: test/unit/core/test-command-select-geo.c Modified: test/unit/core/test-command-select-geo.c (+60 -12) =================================================================== --- test/unit/core/test-command-select-geo.c 2011-12-28 13:06:41 +0900 (7e2c7ec) +++ test/unit/core/test-command-select-geo.c 2011-12-28 13:13:42 +0900 (c4fc270) @@ -22,9 +22,12 @@ #include "../lib/grn-assertions.h" void test_default(void); -void test_rectangle(void); -void test_sphere(void); -void test_ellipsoid(void); +void data_rectangle(void); +void test_rectangle(gconstpointer data); +void data_sphere(void); +void test_sphere(gconstpointer data); +void data_ellipsoid(void); +void test_ellipsoid(gconstpointer data); static gchar *tmp_directory; @@ -123,7 +126,21 @@ test_default(void) } void -test_rectangle(void) +data_rectangle(void) +{ +#define ADD_DATA(label, type) \ + gcut_add_datum(label, \ + "approximate-type", G_TYPE_STRING, type, \ + NULL) + + ADD_DATA("full", "rectangle"); + ADD_DATA("abbreviation", "rect"); + +#undef ADD_DATA +} + +void +test_rectangle(gconstpointer data) { gdouble yurakucho_latitude = 35.67487; gdouble yurakucho_longitude = 139.76352; @@ -148,14 +165,29 @@ test_rectangle(void) "--output_columns 'name, _score, location' " "--filter 'geo_in_circle(location, \"%s\", %d)' " "--scorer " - "'_score = geo_distance(location, \"%s\", \"rectangle\") * 1000 * 1000'", + "'_score = geo_distance(location, \"%s\", \"%s\") * 1000 * 1000'", grn_test_location_string(yurakucho_latitude, yurakucho_longitude), distance, - grn_test_location_string(yurakucho_latitude, yurakucho_longitude)))); + grn_test_location_string(yurakucho_latitude, yurakucho_longitude), + gcut_data_get_string(data, "approximate-type")))); +} + +void +data_sphere(void) +{ +#define ADD_DATA(label, type) \ + gcut_add_datum(label, \ + "approximate-type", G_TYPE_STRING, type, \ + NULL) + + ADD_DATA("full", "sphere"); + ADD_DATA("abbreviation", "sphr"); + +#undef ADD_DATA } void -test_sphere(void) +test_sphere(gconstpointer data) { gdouble yurakucho_latitude = 35.67487; gdouble yurakucho_longitude = 139.76352; @@ -180,14 +212,29 @@ test_sphere(void) "--output_columns 'name, _score, location' " "--filter 'geo_in_circle(location, \"%s\", %d)' " "--scorer " - "'_score = geo_distance(location, \"%s\", \"sphere\") * 1000 * 1000'", + "'_score = geo_distance(location, \"%s\", \"%s\") * 1000 * 1000'", grn_test_location_string(yurakucho_latitude, yurakucho_longitude), distance, - grn_test_location_string(yurakucho_latitude, yurakucho_longitude)))); + grn_test_location_string(yurakucho_latitude, yurakucho_longitude), + gcut_data_get_string(data, "approximate-type")))); +} + +void +data_ellipsoid(void) +{ +#define ADD_DATA(label, type) \ + gcut_add_datum(label, \ + "approximate-type", G_TYPE_STRING, type, \ + NULL) + + ADD_DATA("full", "ellipsoid"); + ADD_DATA("abbreviation", "ellip"); + +#undef ADD_DATA } void -test_ellipsoid(void) +test_ellipsoid(gconstpointer data) { gdouble yurakucho_latitude = 35.67487; gdouble yurakucho_longitude = 139.76352; @@ -212,8 +259,9 @@ test_ellipsoid(void) "--output_columns 'name, _score, location' " "--filter 'geo_in_circle(location, \"%s\", %d)' " "--scorer " - "'_score = geo_distance(location, \"%s\", \"ellipsoid\") * 1000 * 1000'", + "'_score = geo_distance(location, \"%s\", \"%s\") * 1000 * 1000'", grn_test_location_string(yurakucho_latitude, yurakucho_longitude), distance, - grn_test_location_string(yurakucho_latitude, yurakucho_longitude)))); + grn_test_location_string(yurakucho_latitude, yurakucho_longitude), + gcut_data_get_string(data, "approximate-type")))); }