From 1625efc870f1a8b7c6e6382277ddbb245f91a294 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 10 Jun 2021 18:24:34 +0100 Subject: IVGCVSW-5963 'Move unit tests to new framework' * Used doctest in ArmNN unit tests Signed-off-by: Sadik Armagan Change-Id: Ia9cf5fc72775878885c5f864abf2c56b3a935f1a --- .../test/FloatingPointComparisonTest.cpp | 116 ++++++++++----------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'src/armnnUtils/test/FloatingPointComparisonTest.cpp') diff --git a/src/armnnUtils/test/FloatingPointComparisonTest.cpp b/src/armnnUtils/test/FloatingPointComparisonTest.cpp index dab0deb5e6..7b97404ed3 100644 --- a/src/armnnUtils/test/FloatingPointComparisonTest.cpp +++ b/src/armnnUtils/test/FloatingPointComparisonTest.cpp @@ -5,133 +5,133 @@ #include -#include +#include using namespace armnnUtils; -BOOST_AUTO_TEST_SUITE(FloatingPointComparisonSuite) - -BOOST_AUTO_TEST_CASE(FloatingPointComparisonDefaultTolerance) +TEST_SUITE("FloatingPointComparisonSuite") +{ +TEST_CASE("FloatingPointComparisonDefaultTolerance") { // 1% range of 1.2 is 1.188 -> 1.212 // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(1.2f, 1.17f)); + CHECK(!within_percentage_tolerance(1.2f, 1.17f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(1.2f, 1.213f)); + CHECK(!within_percentage_tolerance(1.2f, 1.213f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(1.2f, 1.189f)); + CHECK(within_percentage_tolerance(1.2f, 1.189f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(1.2f, 1.210f)); + CHECK(within_percentage_tolerance(1.2f, 1.210f)); // Exact match - BOOST_TEST(within_percentage_tolerance(1.2f, 1.2f)); + CHECK(within_percentage_tolerance(1.2f, 1.2f)); // Negative value tests. - BOOST_TEST(!within_percentage_tolerance(-1.2f, -1.17f)); - BOOST_TEST(!within_percentage_tolerance(-1.2f, -1.213f)); - BOOST_TEST(within_percentage_tolerance(-1.2f, -1.189f)); - BOOST_TEST(within_percentage_tolerance(-1.2f, -1.210f)); - BOOST_TEST(within_percentage_tolerance(-1.2f, -1.2f)); + CHECK(!within_percentage_tolerance(-1.2f, -1.17f)); + CHECK(!within_percentage_tolerance(-1.2f, -1.213f)); + CHECK(within_percentage_tolerance(-1.2f, -1.189f)); + CHECK(within_percentage_tolerance(-1.2f, -1.210f)); + CHECK(within_percentage_tolerance(-1.2f, -1.2f)); // Negative & positive tests - BOOST_TEST(!within_percentage_tolerance(1.2f, -1.2f)); - BOOST_TEST(!within_percentage_tolerance(-1.2f, 1.2f)); + CHECK(!within_percentage_tolerance(1.2f, -1.2f)); + CHECK(!within_percentage_tolerance(-1.2f, 1.2f)); // Negative and positive test with large float values. - BOOST_TEST(!within_percentage_tolerance(3.3E+38f, -1.17549435e38f)); - BOOST_TEST(!within_percentage_tolerance(-1.17549435e38f, 3.3E+38f)); + CHECK(!within_percentage_tolerance(3.3E+38f, -1.17549435e38f)); + CHECK(!within_percentage_tolerance(-1.17549435e38f, 3.3E+38f)); // 1% range of 0.04 is 0.0396 -> 0.0404 // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(0.04f, 0.039f)); + CHECK(!within_percentage_tolerance(0.04f, 0.039f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(0.04f, 0.04041f)); + CHECK(!within_percentage_tolerance(0.04f, 0.04041f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(0.04f, 0.0397f)); + CHECK(within_percentage_tolerance(0.04f, 0.0397f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(0.04f, 0.04039f)); + CHECK(within_percentage_tolerance(0.04f, 0.04039f)); // Exact match - BOOST_TEST(within_percentage_tolerance(0.04f, 0.04f)); + CHECK(within_percentage_tolerance(0.04f, 0.04f)); } -BOOST_AUTO_TEST_CASE(FloatingPointComparisonLargePositiveNumbersDefaultTolerance) +TEST_CASE("FloatingPointComparisonLargePositiveNumbersDefaultTolerance") { // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.989f))); + CHECK(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.989f))); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.011f))); + CHECK(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.011f))); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.992f))); + CHECK(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.992f))); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.009f))); + CHECK(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.009f))); // Exact match - BOOST_TEST(within_percentage_tolerance(3.3E+38f, 3.3E+38f)); + CHECK(within_percentage_tolerance(3.3E+38f, 3.3E+38f)); } -BOOST_AUTO_TEST_CASE(FloatingPointComparisonLargeNegativeNumbersDefaultTolerance) +TEST_CASE("FloatingPointComparisonLargeNegativeNumbersDefaultTolerance") { // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * -1.009f))); + CHECK(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * -1.009f))); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * 1.011f))); + CHECK(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * 1.011f))); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f - (-1.17549435e38f * 0.0099f))); + CHECK(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f - (-1.17549435e38f * 0.0099f))); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f + (-1.17549435e38f * 0.0099f))); + CHECK(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f + (-1.17549435e38f * 0.0099f))); // Exact match - BOOST_TEST(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f)); + CHECK(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f)); } -BOOST_AUTO_TEST_CASE(FloatingPointComparisonSpecifiedTolerance) +TEST_CASE("FloatingPointComparisonSpecifiedTolerance") { // 2% range of 1.2 is 1.176 -> 1.224 // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(1.2f, 1.175f, 2.0f)); + CHECK(!within_percentage_tolerance(1.2f, 1.175f, 2.0f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(1.2f, 1.226f, 2.0f)); + CHECK(!within_percentage_tolerance(1.2f, 1.226f, 2.0f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(1.2f, 1.18f, 2.0f)); + CHECK(within_percentage_tolerance(1.2f, 1.18f, 2.0f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(1.2f, 1.22f, 2.0f)); + CHECK(within_percentage_tolerance(1.2f, 1.22f, 2.0f)); // Exact match. - BOOST_TEST(within_percentage_tolerance(1.2f, 1.2f, 2.0f)); + CHECK(within_percentage_tolerance(1.2f, 1.2f, 2.0f)); // 5% range of 6.2 is 5.89 -> 6.51 // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(6.2f, 5.88f, 5.0f)); + CHECK(!within_percentage_tolerance(6.2f, 5.88f, 5.0f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(6.2f, 6.52f, 5.0f)); + CHECK(!within_percentage_tolerance(6.2f, 6.52f, 5.0f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(6.2f, 5.9f, 5.0f)); + CHECK(within_percentage_tolerance(6.2f, 5.9f, 5.0f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(6.2f, 6.5f, 5.0f)); + CHECK(within_percentage_tolerance(6.2f, 6.5f, 5.0f)); // Larger tolerance (unlikely to be used). - BOOST_TEST(within_percentage_tolerance(10.0f, 9.01f, 10.0f)); - BOOST_TEST(!within_percentage_tolerance(10.0f, 8.99f, 10.0f)); + CHECK(within_percentage_tolerance(10.0f, 9.01f, 10.0f)); + CHECK(!within_percentage_tolerance(10.0f, 8.99f, 10.0f)); } -BOOST_AUTO_TEST_CASE(FloatingPointComparisonLargePositiveNumbersSpecifiedTolerance) +TEST_CASE("FloatingPointComparisonLargePositiveNumbersSpecifiedTolerance") { // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.979f), 2.0f)); + CHECK(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.979f), 2.0f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.021f), 2.0f)); + CHECK(!within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.021f), 2.0f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.982f), 2.0f)); + CHECK(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 0.982f), 2.0f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.019f), 2.0f)); + CHECK(within_percentage_tolerance(3.3E+38f, (3.3E+38f * 1.019f), 2.0f)); } -BOOST_AUTO_TEST_CASE(FloatingPointComparisonLargeNegativeNumbersSpecifiedTolerance) +TEST_CASE("FloatingPointComparisonLargeNegativeNumbersSpecifiedTolerance") { // Just below tolerance. - BOOST_TEST(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * -1.019f), 2.0f)); + CHECK(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * -1.019f), 2.0f)); // Just above tolerance. - BOOST_TEST(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * 1.021f), 2.0f)); + CHECK(!within_percentage_tolerance(-1.17549435e38f, (-1.17549435e38f * 1.021f), 2.0f)); // Just inside the lower range. - BOOST_TEST(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f - (-1.17549435e38f * 0.0089f), 2.0f)); + CHECK(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f - (-1.17549435e38f * 0.0089f), 2.0f)); // Just inside the upper range. - BOOST_TEST(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f + (-1.17549435e38f * 0.0089f), 2.0f)); + CHECK(within_percentage_tolerance(-1.17549435e38f, -1.17549435e38f + (-1.17549435e38f * 0.0089f), 2.0f)); } -BOOST_AUTO_TEST_SUITE_END() +} -- cgit v1.2.1