mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
Fixed some 'double comparison' tests.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
@@ -67,7 +67,11 @@ UNIT_TEST(AlmostEqualULPs_double)
|
|||||||
TEST(!base::AlmostEqualULPs(1.0, -1.0), ());
|
TEST(!base::AlmostEqualULPs(1.0, -1.0), ());
|
||||||
TEST(!base::AlmostEqualULPs(2.0, -2.0), ());
|
TEST(!base::AlmostEqualULPs(2.0, -2.0), ());
|
||||||
TEST(!base::AlmostEqualULPs(dmax, -dmax), ());
|
TEST(!base::AlmostEqualULPs(dmax, -dmax), ());
|
||||||
|
|
||||||
|
// That's why AlmostEqualULPs is a strange function, IMHO.
|
||||||
TEST(!base::AlmostEqualULPs(0.0, eps), ());
|
TEST(!base::AlmostEqualULPs(0.0, eps), ());
|
||||||
|
TEST(!base::AlmostEqualULPs(-eps, 0.0), ());
|
||||||
|
TEST(!base::AlmostEqualULPs(eps, 2.0*eps), ());
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_TEST(AlmostEqualULPs_float)
|
UNIT_TEST(AlmostEqualULPs_float)
|
||||||
@@ -91,7 +95,11 @@ UNIT_TEST(AlmostEqualULPs_float)
|
|||||||
TEST(!base::AlmostEqualULPs(1.0f, -1.0f), ());
|
TEST(!base::AlmostEqualULPs(1.0f, -1.0f), ());
|
||||||
TEST(!base::AlmostEqualULPs(2.0f, -2.0f), ());
|
TEST(!base::AlmostEqualULPs(2.0f, -2.0f), ());
|
||||||
TEST(!base::AlmostEqualULPs(dmax, -dmax), ());
|
TEST(!base::AlmostEqualULPs(dmax, -dmax), ());
|
||||||
|
|
||||||
|
// That's why AlmostEqualULPs is a strange function, IMHO.
|
||||||
TEST(!base::AlmostEqualULPs(0.0f, eps), ());
|
TEST(!base::AlmostEqualULPs(0.0f, eps), ());
|
||||||
|
TEST(!base::AlmostEqualULPs(-eps, 0.0f), ());
|
||||||
|
TEST(!base::AlmostEqualULPs(eps, 2.0f*eps), ());
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_TEST(AlmostEqual_Smoke)
|
UNIT_TEST(AlmostEqual_Smoke)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "testing/testing.hpp"
|
#include "testing/testing.hpp"
|
||||||
|
|
||||||
#include "drape_frontend/path_text_handle.hpp"
|
#include "drape_frontend/path_text_handle.hpp"
|
||||||
|
#include "drape_frontend/visual_params.hpp"
|
||||||
|
|
||||||
#include "base/logging.hpp"
|
#include "base/logging.hpp"
|
||||||
|
|
||||||
@@ -15,10 +16,12 @@ bool IsSmooth(m2::SplineEx const & spline)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
UNIT_TEST(Rounding_Spline)
|
UNIT_TEST(Rounding_Spline)
|
||||||
{
|
{
|
||||||
|
df::VisualParams::Init(1.0, 1024);
|
||||||
|
|
||||||
m2::SplineEx spline1;
|
m2::SplineEx spline1;
|
||||||
df::AddPointAndRound(spline1, m2::PointD(0, 200));
|
df::AddPointAndRound(spline1, m2::PointD(0, 200));
|
||||||
df::AddPointAndRound(spline1, m2::PointD(0, 0));
|
df::AddPointAndRound(spline1, m2::PointD(0, 0));
|
||||||
|
|||||||
@@ -12,15 +12,38 @@ using namespace std;
|
|||||||
using m2::Spline;
|
using m2::Spline;
|
||||||
using m2::PointD;
|
using m2::PointD;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
double constexpr kAlmostZero = 1.0E-16;
|
||||||
|
|
||||||
|
void TestEqual(double x, double y)
|
||||||
|
{
|
||||||
|
if (fabs(x) < kAlmostZero || fabs(y) < kAlmostZero)
|
||||||
|
TEST_ALMOST_EQUAL_ABS(x, y, kAlmostZero, ());
|
||||||
|
else
|
||||||
|
TEST_ALMOST_EQUAL_ULPS(x, y, ());
|
||||||
|
}
|
||||||
|
|
||||||
void TestPointDDir(PointD const & dst, PointD const & src)
|
void TestPointDDir(PointD const & dst, PointD const & src)
|
||||||
{
|
{
|
||||||
double const len1 = dst.Length();
|
double const len1 = dst.Length();
|
||||||
double const len2 = src.Length();
|
double const len2 = src.Length();
|
||||||
TEST_ALMOST_EQUAL_ULPS(dst.x/len1, src.x/len2, ());
|
if (len1 < kAlmostZero || len2 < kAlmostZero)
|
||||||
TEST_ALMOST_EQUAL_ULPS(dst.y/len1, src.y/len2, ());
|
{
|
||||||
|
TestEqual(dst.x, src.x);
|
||||||
|
TestEqual(dst.y, src.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TestEqual(dst.x/len1, src.x/len2);
|
||||||
|
TestEqual(dst.y/len1, src.y/len2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_TEST(SmoothedDirections)
|
} // namespace
|
||||||
|
|
||||||
|
UNIT_TEST(Spline_SmoothedDirections)
|
||||||
{
|
{
|
||||||
vector<PointD> path;
|
vector<PointD> path;
|
||||||
path.push_back(PointD(0, 0));
|
path.push_back(PointD(0, 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user