mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
Updated WKT test w.r.t. ttmath
[SVN r76855]
This commit is contained in:
parent
18ef2e7e03
commit
cbdb6c26cc
@ -12,7 +12,6 @@
|
|||||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
//#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -58,40 +57,27 @@ void test_wkt(std::string const& wkt, std::size_t n, double len = 0,
|
|||||||
BOOST_CHECK_CLOSE(double(bg::perimeter(geometry)), peri, 0.0001);
|
BOOST_CHECK_CLOSE(double(bg::perimeter(geometry)), peri, 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
// String comparison: only for int/double/float etc
|
std::ostringstream out;
|
||||||
// GMP/CLN add +e01, L0, etc
|
out << bg::wkt(geometry);
|
||||||
if (boost::is_fundamental
|
BOOST_CHECK_EQUAL(boost::to_upper_copy(out.str()),
|
||||||
<
|
boost::to_upper_copy(wkt));
|
||||||
typename bg::coordinate_type<G>::type
|
|
||||||
>::type::value)
|
|
||||||
{
|
|
||||||
std::ostringstream out;
|
|
||||||
out << bg::wkt(geometry);
|
|
||||||
BOOST_CHECK_EQUAL(boost::to_upper_copy(out.str()),
|
|
||||||
boost::to_upper_copy(wkt));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G>
|
template <typename G>
|
||||||
void test_relaxed_wkt(std::string const& wkt, std::string const& expected)
|
void test_relaxed_wkt(std::string const& wkt, std::string const& expected)
|
||||||
{
|
{
|
||||||
if (boost::is_fundamental
|
std::string e;
|
||||||
<
|
G geometry;
|
||||||
typename bg::coordinate_type<G>::type
|
bg::read_wkt(wkt, geometry);
|
||||||
>::type::value)
|
std::ostringstream out;
|
||||||
{
|
out << bg::wkt(geometry);
|
||||||
std::string e;
|
|
||||||
G geometry;
|
|
||||||
bg::read_wkt(wkt, geometry);
|
|
||||||
std::ostringstream out;
|
|
||||||
out << bg::wkt(geometry);
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(boost::to_upper_copy(out.str()), boost::to_upper_copy(expected));
|
BOOST_CHECK_EQUAL(boost::to_upper_copy(out.str()), boost::to_upper_copy(expected));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename G>
|
template <typename G>
|
||||||
void test_wrong_wkt(std::string const& wkt, std::string const& start)
|
void test_wrong_wkt(std::string const& wkt, std::string const& start)
|
||||||
{
|
{
|
||||||
@ -106,8 +92,29 @@ void test_wrong_wkt(std::string const& wkt, std::string const& start)
|
|||||||
e = ex.what();
|
e = ex.what();
|
||||||
boost::to_lower(e);
|
boost::to_lower(e);
|
||||||
}
|
}
|
||||||
BOOST_CHECK_MESSAGE(boost::starts_with(e, start), " Expected:"
|
catch(...)
|
||||||
<< start << " Got:" << e << " with WKT: " << wkt);
|
{
|
||||||
|
e = "other exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check = true;
|
||||||
|
|
||||||
|
#if defined(HAVE_TTMATH)
|
||||||
|
// For ttmath we skip bad lexical casts
|
||||||
|
typedef typename bg::coordinate_type<G>::type ct;
|
||||||
|
|
||||||
|
if (boost::is_same<ct, ttmath_big>::type::value
|
||||||
|
&& boost::starts_with(start, "bad lexical cast"))
|
||||||
|
{
|
||||||
|
check = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (check)
|
||||||
|
{
|
||||||
|
BOOST_CHECK_MESSAGE(boost::starts_with(e, start), " Expected:"
|
||||||
|
<< start << " Got:" << e << " with WKT: " << wkt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G>
|
template <typename G>
|
||||||
@ -126,7 +133,7 @@ void test_all()
|
|||||||
using namespace boost::geometry;
|
using namespace boost::geometry;
|
||||||
typedef bg::model::point<T, 2, bg::cs::cartesian> P;
|
typedef bg::model::point<T, 2, bg::cs::cartesian> P;
|
||||||
|
|
||||||
test_wkt<P >("POINT(1 2)", 1);
|
test_wkt<P>("POINT(1 2)", 1);
|
||||||
test_wkt<bg::model::linestring<P> >("LINESTRING(1 1,2 2,3 3)", 3, 2 * sqrt(2.0));
|
test_wkt<bg::model::linestring<P> >("LINESTRING(1 1,2 2,3 3)", 3, 2 * sqrt(2.0));
|
||||||
test_wkt<bg::model::polygon<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0)"
|
test_wkt<bg::model::polygon<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0)"
|
||||||
",(1 1,1 2,2 2,2 1,1 1),(1 1,1 2,2 2,2 1,1 1))", 15, 0, 18, 24);
|
",(1 1,1 2,2 2,2 1,1 1),(1 1,1 2,2 2,2 1,1 1))", 15, 0, 18, 24);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)\wkt"
|
IntermediateDirectory="$(ConfigurationName)\wkt"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
InheritedPropertySheets="..\..\boost.vsprops"
|
InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.vsprops"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
@ -93,7 +93,7 @@
|
|||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)\wkt"
|
IntermediateDirectory="$(ConfigurationName)\wkt"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
InheritedPropertySheets="..\..\boost.vsprops"
|
InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.vsprops"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user