|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86596 - in trunk/libs/geometry/test: algorithms multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2013-11-09 06:52:56
Author: barendgehrels
Date: 2013-11-09 06:52:56 EST (Sat, 09 Nov 2013)
New Revision: 86596
URL: http://svn.boost.org/trac/boost/changeset/86596
Log:
[geometry] fixed WKT errors in convert-unit-tests. We now check extra on num_points
Text files modified:
trunk/libs/geometry/test/algorithms/convert.cpp | 45 ++++++++++++++++++++++++++-------------
trunk/libs/geometry/test/algorithms/test_convert.hpp | 24 ++++++++++++++-------
trunk/libs/geometry/test/multi/algorithms/multi_convert.cpp | 16 +++++++++----
3 files changed, 57 insertions(+), 28 deletions(-)
Modified: trunk/libs/geometry/test/algorithms/convert.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/convert.cpp Sat Nov 9 06:50:21 2013 (r86595)
+++ trunk/libs/geometry/test/algorithms/convert.cpp 2013-11-09 06:52:56 EST (Sat, 09 Nov 2013) (r86596)
@@ -71,7 +71,8 @@
>
(
"POLYGON((1 1,2 2,3 0,1 1))",
- "POLYGON((1 1,2 2,3 0))"
+ "POLYGON((1 1,2 2,3 0))",
+ 3
);
test_mixed
@@ -81,7 +82,8 @@
>
(
"POLYGON((1 1,2 2,3 0))",
- "POLYGON((1 1,2 2,3 0,1 1))"
+ "POLYGON((1 1,2 2,3 0,1 1))",
+ 4
);
// Polygon
@@ -102,7 +104,8 @@
>
(
"POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
- "POLYGON((0 0,5 0,5 5,0 5),(1 1,2 4,3 2))"
+ "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))",
+ 7 // WKT is closed, polygon is open
);
// (polygon uses ring, so other tests omitted here)
@@ -133,7 +136,8 @@
>
(
"POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
- "POLYGON((0 0,0 5,5 5,5 0,0 0))"
+ "POLYGON((0 0,0 5,5 5,5 0,0 0))",
+ 5
);
// point -> box
@@ -144,7 +148,8 @@
>
(
"POINT(0 0)",
- "POLYGON((0 0,0 0,0 0,0 0,0 0))"
+ "POLYGON((0 0,0 0,0 0,0 0,0 0))",
+ 4
);
// segment -> line
@@ -155,7 +160,8 @@
>
(
"LINESTRING(0 0,1 1)",
- "LINESTRING(0 0,1 1)"
+ "LINESTRING(0 0,1 1)",
+ 2
);
// box -> ring ( <- is NYI)
@@ -166,7 +172,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,0 2,2 2,2 0,0 0))"
+ "POLYGON((0 0,0 2,2 2,2 0,0 0))",
+ 5
);
test_mixed
@@ -176,7 +183,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,2 0,2 2,0 2,0 0))"
+ "POLYGON((0 0,2 0,2 2,0 2,0 0))",
+ 5
);
test_mixed
@@ -186,7 +194,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,0 2,2 2,2 0))"
+ "POLYGON((0 0,0 2,2 2,2 0))",
+ 4
);
test_mixed
@@ -196,7 +205,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,2 0,2 2,0 2))"
+ "POLYGON((0 0,2 0,2 2,0 2))",
+ 4
);
// box -> polygon ( <- is NYI)
@@ -207,7 +217,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,0 2,2 2,2 0,0 0))"
+ "POLYGON((0 0,0 2,2 2,2 0,0 0))",
+ 5
);
test_mixed
@@ -217,7 +228,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,2 0,2 2,0 2,0 0))"
+ "POLYGON((0 0,2 0,2 2,0 2,0 0))",
+ 5
);
test_mixed
@@ -227,7 +239,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,0 2,2 2,2 0))"
+ "POLYGON((0 0,0 2,2 2,2 0,0 0))",
+ 4 // WKT is closed, polygon is open
);
test_mixed
@@ -237,7 +250,8 @@
>
(
"BOX(0 0,2 2)",
- "POLYGON((0 0,2 0,2 2,0 2))"
+ "POLYGON((0 0,2 0,2 2,0 2,0 0))",
+ 4 // WKT is closed, polygon is open
);
}
@@ -270,7 +284,8 @@
>
(
"LINESTRING(1 2 3,4 5 6)",
- "LINESTRING(1 2 3,4 5 6)"
+ "LINESTRING(1 2 3,4 5 6)",
+ 2
);
}
Modified: trunk/libs/geometry/test/algorithms/test_convert.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_convert.hpp Sat Nov 9 06:50:21 2013 (r86595)
+++ trunk/libs/geometry/test/algorithms/test_convert.hpp 2013-11-09 06:52:56 EST (Sat, 09 Nov 2013) (r86596)
@@ -33,7 +33,7 @@
template <typename Geometry2, typename Geometry1>
-void check_mixed(Geometry1 const& geometry1, std::string const& expected)
+void check_mixed(Geometry1 const& geometry1, std::string const& expected, int expected_point_count)
{
Geometry2 geometry2;
bg::convert(geometry1, geometry2);
@@ -41,29 +41,37 @@
std::ostringstream out;
out << bg::wkt(geometry2);
BOOST_CHECK_EQUAL(out.str(), expected);
+
+ std::size_t n = bg::num_points(geometry2);
+ BOOST_CHECK_MESSAGE(expected_point_count < 0 || int(n) == expected_point_count,
+ "convert: "
+ << " #points expected: " << expected_point_count
+ << " detected: " << n
+ << " expected wkt: " << expected
+ );
}
template <typename Geometry1, typename Geometry2>
-void test_mixed(std::string const& wkt, std::string const& expected)
+void test_mixed(std::string const& wkt, std::string const& expected, int expected_point_count)
{
Geometry1 geometry1;
bg::read_wkt(wkt, geometry1);
- check_mixed<Geometry2>(geometry1, expected);
- check_mixed<Geometry2>(boost::variant<Geometry1>(geometry1), expected);
+ check_mixed<Geometry2>(geometry1, expected, expected_point_count);
+ check_mixed<Geometry2>(boost::variant<Geometry1>(geometry1), expected, expected_point_count);
}
template <typename Geometry1, typename Geometry2>
void test_mixed_identical_result(std::string const& wkt)
{
- test_mixed<Geometry1, Geometry2>(wkt, wkt);
- test_mixed<Geometry2, Geometry1>(wkt, wkt);
+ test_mixed<Geometry1, Geometry2>(wkt, wkt, -1);
+ test_mixed<Geometry2, Geometry1>(wkt, wkt, -1);
}
template <typename Geometry1, typename Geometry2>
void test_mixed_reversible_result(std::string const& wkt1, std::string const& wkt2)
{
- test_mixed<Geometry1, Geometry2>(wkt1, wkt2);
- test_mixed<Geometry2, Geometry1>(wkt2, wkt1);
+ test_mixed<Geometry1, Geometry2>(wkt1, wkt2, -1);
+ test_mixed<Geometry2, Geometry1>(wkt2, wkt1, -1);
}
#endif
Modified: trunk/libs/geometry/test/multi/algorithms/multi_convert.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_convert.cpp Sat Nov 9 06:50:21 2013 (r86595)
+++ trunk/libs/geometry/test/multi/algorithms/multi_convert.cpp 2013-11-09 06:52:56 EST (Sat, 09 Nov 2013) (r86596)
@@ -8,6 +8,7 @@
#include <algorithms/test_convert.hpp>
#include <boost/geometry/multi/algorithms/convert.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
#include <boost/geometry/multi/geometries/multi_point.hpp>
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
@@ -41,7 +42,8 @@
>
(
"POINT(1 1)",
- "MULTIPOINT((1 1))"
+ "MULTIPOINT((1 1))",
+ 1
);
test_mixed
<
@@ -50,7 +52,8 @@
>
(
"LINESTRING(1 1,2 2)",
- "MULTILINESTRING((1 1,2 2))"
+ "MULTILINESTRING((1 1,2 2))",
+ 2
);
test_mixed
<
@@ -59,7 +62,8 @@
>
(
"LINESTRING(1 1,2 2)",
- "MULTILINESTRING((1 1,2 2))"
+ "MULTILINESTRING((1 1,2 2))",
+ 2
);
test_mixed
<
@@ -68,7 +72,8 @@
>
(
"BOX(0 0,1 1)",
- "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))"
+ "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))",
+ 5
);
test_mixed
<
@@ -77,7 +82,8 @@
>
(
"POLYGON((0 0,0 1,1 1,1 0,0 0))",
- "MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))"
+ "MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))",
+ 5
);
// Multi -> single: should not compile (because multi often have 0 or >1 elements)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk