Skip to content

Commit

Permalink
test geo_in_rectangle: migrate out of range error tests to grntest style
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Dec 7, 2013
1 parent 125a117 commit 01c6078
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 92 deletions.
4 changes: 2 additions & 2 deletions lib/geo.c
Expand Up @@ -1088,7 +1088,7 @@ in_rectangle_data_validate(grn_ctx *ctx,
if (top_left->longitude <= GRN_GEO_MIN_LONGITUDE) {
ERR(GRN_INVALID_ARGUMENT,
"%s: top left point's longitude is too small: "
"<%d>(max:%d): (%d,%d) (%d,%d)",
"<%d>(min:%d): (%d,%d) (%d,%d)",
process_name,
GRN_GEO_MIN_LONGITUDE, top_left->longitude,
top_left->latitude, top_left->longitude,
Expand Down Expand Up @@ -1121,7 +1121,7 @@ in_rectangle_data_validate(grn_ctx *ctx,
if (bottom_right->longitude <= GRN_GEO_MIN_LONGITUDE) {
ERR(GRN_INVALID_ARGUMENT,
"%s: bottom right point's longitude is too small: "
"<%d>(max:%d): (%d,%d) (%d,%d)",
"<%d>(min:%d): (%d,%d) (%d,%d)",
process_name,
GRN_GEO_MIN_LONGITUDE, bottom_right->longitude,
top_left->latitude, top_left->longitude,
Expand Down
3 changes: 2 additions & 1 deletion test/command/fixture/geo/in_rectangle/ddl.grn
@@ -1,6 +1,7 @@
#@disable-logging
table_create LandMarks TABLE_NO_KEY
column_create LandMarks point COLUMN_SCALAR WGS84GeoPoint

table_create Points TABLE_PAT_KEY WGS84GeoPoint
column_create Points land_mark_index COLUMN_INDEX LandMarks point

#@enable-logging
3 changes: 1 addition & 2 deletions test/command/fixture/geo/in_rectangle/north_east.grn
@@ -1,6 +1,6 @@
#@disable-logging
#@include fixture/geo/in_rectangle/ddl.grn

#@disable-logging
load --table LandMarks
[
["point"],
Expand Down Expand Up @@ -261,5 +261,4 @@ load --table LandMarks
["15x14"],
["15x15"]
]

#@enable-logging
3 changes: 1 addition & 2 deletions test/command/fixture/geo/in_rectangle/north_west.grn
@@ -1,6 +1,6 @@
#@disable-logging
#@include fixture/geo/in_rectangle/ddl.grn

#@disable-logging
load --table LandMarks
[
["point"],
Expand Down Expand Up @@ -261,5 +261,4 @@ load --table LandMarks
["15x-15"],
["15x-16"]
]

#@enable-logging
3 changes: 1 addition & 2 deletions test/command/fixture/geo/in_rectangle/south_east.grn
@@ -1,6 +1,6 @@
#@disable-logging
#@include fixture/geo/in_rectangle/ddl.grn

#@disable-logging
load --table LandMarks
[
["point"],
Expand Down Expand Up @@ -261,5 +261,4 @@ load --table LandMarks
["-16x14"],
["-16x15"]
]

#@enable-logging
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x0", "90.0x0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): bottom right point's latitude is too big: <324000000>(max:324000000): (0,0) (324000000,0)"
],
[

]
]
#|e| geo_in_rectangle(): bottom right point's latitude is too big: <324000000>(max:324000000): (0,0) (324000000,0)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x0", "90.0x0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x0", "0x180.0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): bottom right point's longitude is too big: <648000000>(max:648000000): (0,0) (0,648000000)"
],
[

]
]
#|e| geo_in_rectangle(): bottom right point's longitude is too big: <648000000>(max:648000000): (0,0) (0,648000000)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x0", "0x180.0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x0", "-90.0x0")'
[
[
[
-38,
0.0,
0.0
],
"geo_in_rectangle(): the Southern Hemisphere is not implemented."
],
[

]
]
#|e| geo_in_rectangle(): the Southern Hemisphere is not implemented.
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x0", "-90.0x0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x0", "0x-180.0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): bottom right point's longitude is too small: <-648000000>(min:-648000000): (0,0) (0,-648000000)"
],
[

]
]
#|e| geo_in_rectangle(): bottom right point's longitude is too small: <-648000000>(min:-648000000): (0,0) (0,-648000000)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x0", "0x-180.0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "90.0x0", "0x0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): top left point's latitude is too big: <324000000>(max:324000000): (324000000,0) (0,0)"
],
[

]
]
#|e| geo_in_rectangle(): top left point's latitude is too big: <324000000>(max:324000000): (324000000,0) (0,0)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "90.0x0", "0x0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x180.0", "0x0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): top left point's longitude is too big: <648000000>(max:648000000): (0,648000000) (0,0)"
],
[

]
]
#|e| geo_in_rectangle(): top left point's longitude is too big: <648000000>(max:648000000): (0,648000000) (0,0)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x180.0", "0x0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "-90.0x0", "0x0")'
[
[
[
-38,
0.0,
0.0
],
"geo_in_rectangle(): the Southern Hemisphere is not implemented."
],
[

]
]
#|e| geo_in_rectangle(): the Southern Hemisphere is not implemented.
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "-90.0x0", "0x0")'
@@ -0,0 +1,15 @@
select LandMarks --filter 'geo_in_rectangle(point, "0x-180.0", "0x0")'
[
[
[
-22,
0.0,
0.0
],
"geo_in_rectangle(): top left point's longitude is too small: <-648000000>(min:-648000000): (0,-648000000) (0,0)"
],
[

]
]
#|e| geo_in_rectangle(): top left point's longitude is too small: <-648000000>(min:-648000000): (0,-648000000) (0,0)
@@ -0,0 +1,3 @@
#@include fixture/geo/in_rectangle/ddl.grn

select LandMarks --filter 'geo_in_rectangle(point, "0x-180.0", "0x0")'
83 changes: 0 additions & 83 deletions test/unit/story/test-taiyaki.c
Expand Up @@ -22,11 +22,6 @@
#include "../lib/grn-assertions.h"

void test_in_circle(void);
void test_in_rectangle_over_border(void);
void test_in_rectangle_over_top_left_latitude(void);
void test_in_rectangle_over_top_left_longitude(void);
void test_in_rectangle_over_bottom_right_latitude(void);
void test_in_rectangle_over_bottom_right_longitude(void);
void test_sort(void);
void test_filter_by_tag_and_sort_by_distance_from_tokyo_tocho(void);
void test_in_circle_and_tag(void);
Expand Down Expand Up @@ -131,84 +126,6 @@ test_in_circle(void)
grn_test_location_string(yurakucho_latitude, yurakucho_longitude))));
}

void
test_in_rectangle_over_border(void)
{
grn_test_assert_send_command_error(
context,
GRN_FUNCTION_NOT_IMPLEMENTED,
"geo_in_rectangle(): the Southern Hemisphere is not implemented.",
"select Shops "
"--sortby '+name' "
"--output_columns 'name, location' "
"--filter 'geo_in_rectangle(location, "
"\"35.73360x-139.7394\", \"-35.62614x139.7714\")'");
}

void
test_in_rectangle_over_top_left_latitude(void)
{
grn_test_assert_send_command_error(
context,
GRN_INVALID_ARGUMENT,
"geo_in_rectangle(): top left point's latitude is too big: "
"<324000000>(max:324000000): "
"(324000000,503061840) (128254104,50317704",
"select Shops "
"--sortby '+name' "
"--output_columns 'name, location' "
"--filter "
"'geo_in_rectangle(location, \"90.0x139.7394\", \"35.62614x139.7714\")'");
}

void
test_in_rectangle_over_top_left_longitude(void)
{
grn_test_assert_send_command_error(
context,
GRN_INVALID_ARGUMENT,
"geo_in_rectangle(): top left point's longitude is too big: "
"<648000000>(max:648000000): "
"(128640960,648000000) (128254104,5031770",
"select Shops "
"--sortby '+name' "
"--output_columns 'name, location' "
"--filter "
"'geo_in_rectangle(location, \"35.73360x180.0\", \"35.62614x139.7714\")'");
}

void
test_in_rectangle_over_bottom_right_latitude(void)
{
grn_test_assert_send_command_error(
context,
GRN_INVALID_ARGUMENT,
"geo_in_rectangle(): bottom right point's latitude is too big: "
"<324000000>(max:324000000): "
"(128640960,503061840) (324000000,5031",
"select Shops "
"--sortby '+name' "
"--output_columns 'name, location' "
"--filter "
"'geo_in_rectangle(location, \"35.73360x139.7394\", \"90.0x139.7714\")'");
}

void
test_in_rectangle_over_bottom_right_longitude(void)
{
grn_test_assert_send_command_error(
context,
GRN_INVALID_ARGUMENT,
"geo_in_rectangle(): bottom right point's longitude is too big: "
"<648000000>(max:648000000): "
"(128640960,503061840) (128254104,648",
"select Shops "
"--sortby '+name' "
"--output_columns 'name, location' "
"--filter "
"'geo_in_rectangle(location, \"35.73360x139.7394\", \"35.62614x180.0\")'");
}

void
test_sort(void)
{
Expand Down

0 comments on commit 01c6078

Please sign in to comment.