diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-07-10 17:36:59 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-07-15 15:39:22 +0000 |
commit | 2ef06d7de7cd52c9c41c6275413688e4359f979f (patch) | |
tree | 311aad2ed3470a737c42f37c8f1391abd4afd523 /searchlib/src/tests/common | |
parent | 5fc7cc737144fc27ed7de2761a2f041750c949c7 (diff) |
split out geo location parser into its own distinct class
Diffstat (limited to 'searchlib/src/tests/common')
-rw-r--r-- | searchlib/src/tests/common/location/geo_location_test.cpp | 11 | ||||
-rw-r--r-- | searchlib/src/tests/common/location/location_test.cpp | 39 |
2 files changed, 12 insertions, 38 deletions
diff --git a/searchlib/src/tests/common/location/geo_location_test.cpp b/searchlib/src/tests/common/location/geo_location_test.cpp index 452adea2579..b29133172df 100644 --- a/searchlib/src/tests/common/location/geo_location_test.cpp +++ b/searchlib/src/tests/common/location/geo_location_test.cpp @@ -4,17 +4,18 @@ #include <vespa/searchlib/common/geo_location_spec.h> #include <vespa/vespalib/gtest/gtest.h> +using search::common::GeoLocationParser; using search::common::GeoLocationSpec; bool is_parseable(const char *str) { - GeoLocationSpec loc; - return loc.parseOldFormat(str); + GeoLocationParser parser; + return parser.parseOldFormat(str); } GeoLocationSpec parse(const char *str) { - GeoLocationSpec loc; - EXPECT_TRUE(loc.parseOldFormat(str)); - return loc; + GeoLocationParser parser; + EXPECT_TRUE(parser.parseOldFormat(str)); + return parser.spec(); } TEST(GeoLocationSpec, malformed_bounding_boxes_are_not_parseable) { diff --git a/searchlib/src/tests/common/location/location_test.cpp b/searchlib/src/tests/common/location/location_test.cpp index d781e5b7275..79eec441d62 100644 --- a/searchlib/src/tests/common/location/location_test.cpp +++ b/searchlib/src/tests/common/location/location_test.cpp @@ -3,43 +3,16 @@ #include <vespa/searchlib/common/location.h> #include <vespa/searchlib/attribute/attributeguard.h> - using search::common::Location; - -bool is_parseable(const char *str) { - Location loc; - return loc.parse(str); -} +using search::common::GeoLocationParser; +using search::common::GeoLocationSpec; Location parse(const char *str) { - Location loc; - if (!EXPECT_TRUE(loc.parse(str))) { - fprintf(stderr, " parse error: %s\n", loc.getParseError()); + GeoLocationParser parser; + if (!EXPECT_TRUE(parser.parseOldFormat(str))) { + fprintf(stderr, " parse error: %s\n", parser.getParseError()); } - return loc; -} - -TEST("require that malformed bounding boxes are not parseable") { - EXPECT_TRUE(is_parseable("[2,10,20,30,40]")); - EXPECT_FALSE(is_parseable("[2,10,20,30,40][2,10,20,30,40]")); - EXPECT_FALSE(is_parseable("[1,10,20,30,40]")); - EXPECT_FALSE(is_parseable("[3,10,20,30,40]")); - EXPECT_FALSE(is_parseable("[2, 10, 20, 30, 40]")); - EXPECT_FALSE(is_parseable("[2,10,20,30,40")); - EXPECT_FALSE(is_parseable("[2,10,20,30]")); - EXPECT_FALSE(is_parseable("[10,20,30,40]")); -} - -TEST("require that malformed circles are not parseable") { - EXPECT_TRUE(is_parseable("(2,10,20,5,0,0,0)")); - EXPECT_FALSE(is_parseable("(2,10,20,5,0,0,0)(2,10,20,5,0,0,0)")); - EXPECT_FALSE(is_parseable("(1,10,20,5,0,0,0)")); - EXPECT_FALSE(is_parseable("(3,10,20,5,0,0,0)")); - EXPECT_FALSE(is_parseable("(2, 10, 20, 5, 0, 0, 0)")); - EXPECT_FALSE(is_parseable("(2,10,20,5)")); - EXPECT_FALSE(is_parseable("(2,10,20,5,0,0,0")); - EXPECT_FALSE(is_parseable("(2,10,20,5,0,0,0,1000")); - EXPECT_FALSE(is_parseable("(10,20,5)")); + return Location(parser.spec()); } TEST("require that bounding boxes can be parsed") { |