summaryrefslogtreecommitdiff
path: root/src/mongo/db/geo/geoparser_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/geo/geoparser_test.cpp')
-rw-r--r--src/mongo/db/geo/geoparser_test.cpp76
1 files changed, 33 insertions, 43 deletions
diff --git a/src/mongo/db/geo/geoparser_test.cpp b/src/mongo/db/geo/geoparser_test.cpp
index a8fc1397659..4f90986d3c1 100644
--- a/src/mongo/db/geo/geoparser_test.cpp
+++ b/src/mongo/db/geo/geoparser_test.cpp
@@ -30,13 +30,13 @@
* This file contains tests for mongo/db/geo/geoparser.cpp.
*/
-#include <string>
#include <sstream>
+#include <string>
#include "mongo/db/geo/geoparser.h"
#include "mongo/db/geo/shapes.h"
-#include "mongo/db/json.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/json.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
@@ -148,16 +148,14 @@ TEST(GeoParser, parseGeoJSONPolygon) {
&polygon));
// And one with a hole.
ASSERT_OK(GeoParser::parseGeoJSONPolygon(
- fromjson(
- "{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]],"
- " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"),
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]],"
+ " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"),
false,
&polygon));
// Latitudes must be OK
ASSERT_NOT_OK(GeoParser::parseGeoJSONPolygon(
- fromjson(
- "{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,91],[0,91],[0,0]],"
- " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"),
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,91],[0,91],[0,0]],"
+ " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"),
false,
&polygon));
// First point must be the same as the last.
@@ -165,9 +163,8 @@ TEST(GeoParser, parseGeoJSONPolygon) {
fromjson("{'type':'Polygon', 'coordinates':[ [[1,2],[3,4],[5,6]] ]}"), false, &polygon));
// Extra elements are allowed
ASSERT_OK(GeoParser::parseGeoJSONPolygon(
- fromjson(
- "{'type':'Polygon', 'coordinates':[ [[0,0,0,0],[5,0,0],[5,5,1],"
- " [0,5],[0,0]] ]}"),
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0,0,0],[5,0,0],[5,5,1],"
+ " [0,5],[0,0]] ]}"),
false,
&polygon));
@@ -185,9 +182,8 @@ TEST(GeoParser, parseGeoJSONPolygon) {
PolygonWithCRS polygonB;
ASSERT_OK(GeoParser::parseGeoJSONPolygon(
- fromjson(
- "{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]],"
- " [[1,1],[1,4],[4,4],[4,1],[1,1]] ]}"),
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]],"
+ " [[1,1],[1,4],[4,4],[4,1],[1,1]] ]}"),
false,
&polygonB));
// We removed this in the hole.
@@ -204,9 +200,8 @@ TEST(GeoParser, parseGeoJSONPolygon) {
PolygonWithCRS polygonD;
ASSERT_OK(GeoParser::parseGeoJSONPolygon(
- fromjson(
- "{'type':'Polygon', 'coordinates':[ [[0,0],[0,5],[5,5],[5,0],[0,0]],"
- " [[1,1],[1,4],[4,4],[4,1],[1,1]] ]}"),
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[0,5],[5,5],[5,0],[0,0]],"
+ " [[1,1],[1,4],[4,4],[4,1],[1,1]] ]}"),
false,
&polygonD));
// Also removed in the loop.
@@ -324,31 +319,28 @@ TEST(GeoParser, parseMultiLine) {
mongo::MultiLineWithCRS ml;
ASSERT_OK(GeoParser::parseMultiLine(
- fromjson(
- "{'type':'MultiLineString','coordinates':[ [[1,1],[2,2],[3,3]],"
- "[[4,5],[6,7]]]}"),
+ fromjson("{'type':'MultiLineString','coordinates':[ [[1,1],[2,2],[3,3]],"
+ "[[4,5],[6,7]]]}"),
false,
&ml));
ASSERT_EQUALS(ml.lines.size(), (size_t)2);
- ASSERT_OK(
- GeoParser::parseMultiLine(fromjson(
- "{'type':'MultiLineString','coordinates':[ [[1,1],[2,2]],"
- "[[4,5],[6,7]]]}"),
- false,
- &ml));
+ ASSERT_OK(GeoParser::parseMultiLine(
+ fromjson("{'type':'MultiLineString','coordinates':[ [[1,1],[2,2]],"
+ "[[4,5],[6,7]]]}"),
+ false,
+ &ml));
ASSERT_EQUALS(ml.lines.size(), (size_t)2);
ASSERT_OK(GeoParser::parseMultiLine(
fromjson("{'type':'MultiLineString','coordinates':[ [[1,1],[2,2]]]}"), false, &ml));
ASSERT_EQUALS(ml.lines.size(), (size_t)1);
- ASSERT_OK(
- GeoParser::parseMultiLine(fromjson(
- "{'type':'MultiLineString','coordinates':[ [[1,1],[2,2]],"
- "[[2,2],[1,1]]]}"),
- false,
- &ml));
+ ASSERT_OK(GeoParser::parseMultiLine(
+ fromjson("{'type':'MultiLineString','coordinates':[ [[1,1],[2,2]],"
+ "[[2,2],[1,1]]]}"),
+ false,
+ &ml));
ASSERT_EQUALS(ml.lines.size(), (size_t)2);
ASSERT_NOT_OK(GeoParser::parseMultiLine(
@@ -365,22 +357,20 @@ TEST(GeoParser, parseMultiPolygon) {
mongo::MultiPolygonWithCRS mp;
ASSERT_OK(GeoParser::parseMultiPolygon(
- fromjson(
- "{'type':'MultiPolygon','coordinates':["
- "[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],"
- "[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],"
- "[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]"
- "]}"),
+ fromjson("{'type':'MultiPolygon','coordinates':["
+ "[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],"
+ "[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],"
+ "[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]"
+ "]}"),
false,
&mp));
ASSERT_EQUALS(mp.polygons.size(), (size_t)2);
ASSERT_OK(GeoParser::parseMultiPolygon(
- fromjson(
- "{'type':'MultiPolygon','coordinates':["
- "[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],"
- "[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]"
- "]}"),
+ fromjson("{'type':'MultiPolygon','coordinates':["
+ "[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],"
+ "[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]"
+ "]}"),
false,
&mp));
ASSERT_EQUALS(mp.polygons.size(), (size_t)1);