diff options
author | Maxim Pimenov <m@maps.me> | 2015-05-22 15:28:20 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:49:17 +0300 |
commit | c93ecfd1b1e4e2c62d6f6148b4854081a06b98e5 (patch) | |
tree | ef876f3df9e0163ca8a63f064f542f2e0d7c60b1 /geometry/geometry_tests | |
parent | f510a3bb6792341cf42ab7048c5b32124ae829cb (diff) |
Rename AlmostEqual into AlmostEqualULPs.
Diffstat (limited to 'geometry/geometry_tests')
-rw-r--r-- | geometry/geometry_tests/angle_test.cpp | 22 | ||||
-rw-r--r-- | geometry/geometry_tests/distance_test.cpp | 34 | ||||
-rw-r--r-- | geometry/geometry_tests/point_test.cpp | 22 | ||||
-rw-r--r-- | geometry/geometry_tests/spline_test.cpp | 6 | ||||
-rw-r--r-- | geometry/geometry_tests/vector_test.cpp | 2 |
5 files changed, 43 insertions, 43 deletions
diff --git a/geometry/geometry_tests/angle_test.cpp b/geometry/geometry_tests/angle_test.cpp index 54fd651a0d..866b2b904e 100644 --- a/geometry/geometry_tests/angle_test.cpp +++ b/geometry/geometry_tests/angle_test.cpp @@ -31,12 +31,12 @@ UNIT_TEST(Atan) UNIT_TEST(Atan2) { - TEST_ALMOST_EQUAL(atan2(1, 0), pi/2.0, ()); - TEST_ALMOST_EQUAL(atan2(-1, 0), -pi/2.0, ()); - TEST_ALMOST_EQUAL(atan2(0, 1), 0.0, ()); - TEST_ALMOST_EQUAL(atan2(0, -1), pi, ()); + TEST_ALMOST_EQUAL_ULPS(atan2(1, 0), pi/2.0, ()); + TEST_ALMOST_EQUAL_ULPS(atan2(-1, 0), -pi/2.0, ()); + TEST_ALMOST_EQUAL_ULPS(atan2(0, 1), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(atan2(0, -1), pi, ()); - TEST_ALMOST_EQUAL(atan2(1, 1), pi/4.0, ()); + TEST_ALMOST_EQUAL_ULPS(atan2(1, 1), pi/4.0, ()); } namespace @@ -67,16 +67,16 @@ UNIT_TEST(Average) UNIT_TEST(ShortestDistance) { - TEST_ALMOST_EQUAL(ang::GetShortestDistance(0, math::pi), math::pi, ()); - TEST_ALMOST_EQUAL(ang::GetShortestDistance(0, math::pi + 1), -math::pi + 1, ()); + TEST_ALMOST_EQUAL_ULPS(ang::GetShortestDistance(0, math::pi), math::pi, ()); + TEST_ALMOST_EQUAL_ULPS(ang::GetShortestDistance(0, math::pi + 1), -math::pi + 1, ()); - TEST_ALMOST_EQUAL(ang::GetShortestDistance(math::pi - 1, 0), -math::pi + 1, ()); - TEST_ALMOST_EQUAL(ang::GetShortestDistance(math::pi + 1, 0), math::pi - 1, ()); + TEST_ALMOST_EQUAL_ULPS(ang::GetShortestDistance(math::pi - 1, 0), -math::pi + 1, ()); + TEST_ALMOST_EQUAL_ULPS(ang::GetShortestDistance(math::pi + 1, 0), math::pi - 1, ()); } UNIT_TEST(TwoVectorsAngle){ - TEST_ALMOST_EQUAL(ang::TwoVectorsAngle(m2::Point<double>({0, 0}), + TEST_ALMOST_EQUAL_ULPS(ang::TwoVectorsAngle(m2::Point<double>({0, 0}), m2::Point<double>({0, 1}), m2::Point<double>(1, 0)), 3 * math::pi2, ()); - TEST_ALMOST_EQUAL(ang::TwoVectorsAngle(m2::Point<double>({1, 1}), + TEST_ALMOST_EQUAL_ULPS(ang::TwoVectorsAngle(m2::Point<double>({1, 1}), m2::Point<double>({2, 2}), m2::Point<double>(1, 2)), math::pi4, ()); } diff --git a/geometry/geometry_tests/distance_test.cpp b/geometry/geometry_tests/distance_test.cpp index e3f23252a8..aff4236b85 100644 --- a/geometry/geometry_tests/distance_test.cpp +++ b/geometry/geometry_tests/distance_test.cpp @@ -8,13 +8,13 @@ void FloatingPointsTest() m2::DistanceToLineSquare<PointT> d; d.SetBounds(PointT(-1, 3), PointT(2, 1)); - TEST_ALMOST_EQUAL(d(PointT(-1, 3)), 0.0, ()); - TEST_ALMOST_EQUAL(d(PointT(2, 1)), 0.0, ()); - TEST_ALMOST_EQUAL(d(PointT(-0.5, 0.5)), 3.25, ()); - TEST_ALMOST_EQUAL(d(PointT(3.5, 0.0)), 3.25, ()); - TEST_ALMOST_EQUAL(d(PointT(4.0, 4.0)), 13.0, ()); - TEST_ALMOST_EQUAL(d(PointT(0.5, 2.0)), 0.0, ()); - TEST_ALMOST_EQUAL(d(PointT(0.0, 1.25)), 0.5 * 0.5 + 0.75 * 0.75, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(-1, 3)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(2, 1)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(-0.5, 0.5)), 3.25, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(3.5, 0.0)), 3.25, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(4.0, 4.0)), 13.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(0.5, 2.0)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(PointT(0.0, 1.25)), 0.5 * 0.5 + 0.75 * 0.75, ()); } UNIT_TEST(DistanceToLineSquare2D_Floating) @@ -28,13 +28,13 @@ UNIT_TEST(DistanceToLineSquare2D_Integer) m2::DistanceToLineSquare<m2::PointI> d; d.SetBounds(m2::PointI(-1, 3), m2::PointI(2, 1)); - TEST_ALMOST_EQUAL(d(m2::PointI(-1, 3)), 0.0, ()); - TEST_ALMOST_EQUAL(d(m2::PointI(2, 1)), 0.0, ()); - TEST_ALMOST_EQUAL(d(m2::PointI(4, 4)), 13.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(m2::PointI(-1, 3)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(m2::PointI(2, 1)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(m2::PointI(4, 4)), 13.0, ()); double const sqSin = 4.0 / m2::PointI(-1, 3).SquareLength(m2::PointI(2, 1)); - TEST_ALMOST_EQUAL(d(m2::PointI(0, 1)), 4.0*sqSin, ()); - TEST_ALMOST_EQUAL(d(m2::PointI(-1, 1)), 9.0*sqSin, ()); + TEST_ALMOST_EQUAL_ULPS(d(m2::PointI(0, 1)), 4.0*sqSin, ()); + TEST_ALMOST_EQUAL_ULPS(d(m2::PointI(-1, 1)), 9.0*sqSin, ()); } UNIT_TEST(DistanceToLineSquare2D_DegenerateSection) @@ -43,10 +43,10 @@ UNIT_TEST(DistanceToLineSquare2D_DegenerateSection) m2::DistanceToLineSquare<P> d; d.SetBounds(P(5, 5), P(5, 5)); - TEST_ALMOST_EQUAL(d(P(5, 5)), 0.0, ()); - TEST_ALMOST_EQUAL(d(P(6, 6)), 2.0, ()); - TEST_ALMOST_EQUAL(d(P(0, 0)), 50.0, ()); - TEST_ALMOST_EQUAL(d(P(-1, -2)), 36.0 + 49.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(P(5, 5)), 0.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(P(6, 6)), 2.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(P(0, 0)), 50.0, ()); + TEST_ALMOST_EQUAL_ULPS(d(P(-1, -2)), 36.0 + 49.0, ()); } UNIT_TEST(PointProjectionTests_Smoke) @@ -71,6 +71,6 @@ UNIT_TEST(PointProjectionTests_Smoke) for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) { p.SetBounds(arr[i][1], arr[i][2]); - TEST(m2::AlmostEqual(p(arr[i][0]), arr[i][3]), (i)); + TEST(m2::AlmostEqualULPs(p(arr[i][0]), arr[i][3]), (i)); } } diff --git a/geometry/geometry_tests/point_test.cpp b/geometry/geometry_tests/point_test.cpp index 8024b4281a..116c8ef246 100644 --- a/geometry/geometry_tests/point_test.cpp +++ b/geometry/geometry_tests/point_test.cpp @@ -63,22 +63,22 @@ UNIT_TEST(GetArrowPoints) { array<m2::PointF, 3> arrPntsFlt; m2::GetArrowPoints(m2::PointF(0, 0), m2::PointF(1, 0), 1.f, 1.f, arrPntsFlt); - TEST(m2::AlmostEqual(arrPntsFlt[0], m2::PointF(1.f, 1.f)), ()); - TEST(m2::AlmostEqual(arrPntsFlt[1], m2::PointF(2.f, 0.f)), ()); - TEST(m2::AlmostEqual(arrPntsFlt[2], m2::PointF(1.f, -1.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsFlt[0], m2::PointF(1.f, 1.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsFlt[1], m2::PointF(2.f, 0.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsFlt[2], m2::PointF(1.f, -1.f)), ()); array<m2::PointD, 3> arrPntsDbl; m2::GetArrowPoints(m2::PointD(-1., 2.), m2::PointD(-1., 100.), 2., 5., arrPntsDbl); - TEST(m2::AlmostEqual(arrPntsDbl[0], m2::PointD(-3.f, 100.f)), ()); - TEST(m2::AlmostEqual(arrPntsDbl[1], m2::PointD(-1.f, 105.f)), ()); - TEST(m2::AlmostEqual(arrPntsDbl[2], m2::PointD(1.f, 100.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsDbl[0], m2::PointD(-3.f, 100.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsDbl[1], m2::PointD(-1.f, 105.f)), ()); + TEST(m2::AlmostEqualULPs(arrPntsDbl[2], m2::PointD(1.f, 100.f)), ()); } UNIT_TEST(PointAtSegment) { - TEST(m2::AlmostEqual(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(1, 0), 0.5f), m2::PointF(0.5f, 0.f)), ()); - TEST(m2::AlmostEqual(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(0, 1), 0.3f), m2::PointF(0.f, 0.3f)), ()); - TEST(m2::AlmostEqual(m2::PointAtSegment(m2::PointD(0., 0.), m2::PointD(30., 40.), 5.), m2::PointD(3., 4.)), ()); - TEST(m2::AlmostEqual(m2::PointAtSegment(m2::PointF(-3, -4), m2::PointF(-30, -40), 5.f), m2::PointF(-6.f, -8.f)), ()); - TEST(m2::AlmostEqual(m2::PointAtSegment(m2::PointD(14., -48.), m2::PointD(70., -240.), 25.), m2::PointD(21., -72.)), ()); + TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(1, 0), 0.5f), m2::PointF(0.5f, 0.f)), ()); + TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(0, 1), 0.3f), m2::PointF(0.f, 0.3f)), ()); + TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointD(0., 0.), m2::PointD(30., 40.), 5.), m2::PointD(3., 4.)), ()); + TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(-3, -4), m2::PointF(-30, -40), 5.f), m2::PointF(-6.f, -8.f)), ()); + TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointD(14., -48.), m2::PointD(70., -240.), 25.), m2::PointD(21., -72.)), ()); } diff --git a/geometry/geometry_tests/spline_test.cpp b/geometry/geometry_tests/spline_test.cpp index 4b0ccc69cb..f649302c5e 100644 --- a/geometry/geometry_tests/spline_test.cpp +++ b/geometry/geometry_tests/spline_test.cpp @@ -10,8 +10,8 @@ void TestPointDDir(PointD const & dst, PointD const & src) { double len1 = dst.Length(); double len2 = src.Length(); - TEST_ALMOST_EQUAL(dst.x/len1, src.x/len2, ()); - TEST_ALMOST_EQUAL(dst.y/len1, src.y/len2, ()); + TEST_ALMOST_EQUAL_ULPS(dst.x/len1, src.x/len2, ()); + TEST_ALMOST_EQUAL_ULPS(dst.y/len1, src.y/len2, ()); } UNIT_TEST(SmoothedDirections) @@ -202,6 +202,6 @@ UNIT_TEST(Length) double l3 = p3.Length(p4); double l4 = p4.Length(p5); double len2 = l1 + l2 + l3 + l4; - TEST_ALMOST_EQUAL(len1, len2, ()); + TEST_ALMOST_EQUAL_ULPS(len1, len2, ()); } diff --git a/geometry/geometry_tests/vector_test.cpp b/geometry/geometry_tests/vector_test.cpp index 1709833ec1..0b8ea7ee7c 100644 --- a/geometry/geometry_tests/vector_test.cpp +++ b/geometry/geometry_tests/vector_test.cpp @@ -8,7 +8,7 @@ namespace template <class T, size_t N> bool EqualArrays(T (&a1)[N], T (&a2)[N]) { for (size_t i = 0; i < N; ++i) - if (!my::AlmostEqual(a1[i], a2[i])) + if (!my::AlmostEqualULPs(a1[i], a2[i])) return false; return true; } |