From c3a5e21648ba4cde517ed17682b1d61833c27679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 3 Feb 2020 15:07:59 +0100 Subject: [PATCH] Move Approx out of the Detail namespace --- src/catch2/catch.hpp | 2 -- src/catch2/catch_approx.cpp | 13 +++++-------- src/catch2/catch_approx.h | 10 ++++------ src/catch2/catch_matchers_vector.h | 2 +- tests/SelfTest/Baselines/compact.sw.approved.txt | 2 +- tests/SelfTest/Baselines/console.sw.approved.txt | 2 +- tests/SelfTest/Baselines/tap.sw.approved.txt | 2 +- tests/SelfTest/Baselines/xml.sw.approved.txt | 2 +- tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp | 2 +- .../IntrospectiveTests/GeneratorsImpl.tests.cpp | 2 +- tests/SelfTest/UsageTests/Approx.tests.cpp | 2 +- tests/SelfTest/UsageTests/Condition.tests.cpp | 2 +- 12 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/catch2/catch.hpp b/src/catch2/catch.hpp index a26cb080..3ecbdf69 100644 --- a/src/catch2/catch.hpp +++ b/src/catch2/catch.hpp @@ -60,6 +60,4 @@ #include -using Catch::Detail::Approx; - #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED diff --git a/src/catch2/catch_approx.cpp b/src/catch2/catch_approx.cpp index c1a9170f..4296e8d5 100644 --- a/src/catch2/catch_approx.cpp +++ b/src/catch2/catch_approx.cpp @@ -23,7 +23,6 @@ bool marginComparison(double lhs, double rhs, double margin) { } namespace Catch { -namespace Detail { Approx::Approx ( double value ) : m_epsilon( std::numeric_limits::epsilon()*100 ), @@ -70,18 +69,16 @@ namespace Detail { m_epsilon = newEpsilon; } -} // end namespace Detail - namespace literals { - Detail::Approx operator "" _a(long double val) { - return Detail::Approx(val); + Approx operator "" _a(long double val) { + return Approx(val); } - Detail::Approx operator "" _a(unsigned long long val) { - return Detail::Approx(val); + Approx operator "" _a(unsigned long long val) { + return Approx(val); } } // end namespace literals -std::string StringMaker::convert(Catch::Detail::Approx const& value) { +std::string StringMaker::convert(Catch::Approx const& value) { return value.toString(); } diff --git a/src/catch2/catch_approx.h b/src/catch2/catch_approx.h index e6a846b7..9dc9f292 100644 --- a/src/catch2/catch_approx.h +++ b/src/catch2/catch_approx.h @@ -13,7 +13,6 @@ #include namespace Catch { -namespace Detail { class Approx { private: @@ -115,16 +114,15 @@ namespace Detail { double m_scale; double m_value; }; -} // end namespace Detail namespace literals { - Detail::Approx operator "" _a(long double val); - Detail::Approx operator "" _a(unsigned long long val); + Approx operator "" _a(long double val); + Approx operator "" _a(unsigned long long val); } // end namespace literals template<> -struct StringMaker { - static std::string convert(Catch::Detail::Approx const& value); +struct StringMaker { + static std::string convert(Catch::Approx const& value); }; } // end namespace Catch diff --git a/src/catch2/catch_matchers_vector.h b/src/catch2/catch_matchers_vector.h index f41e7fcc..86fb2214 100644 --- a/src/catch2/catch_matchers_vector.h +++ b/src/catch2/catch_matchers_vector.h @@ -124,7 +124,7 @@ namespace Matchers { } std::vector const& m_comparator; - mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); + mutable Catch::Approx approx = Catch::Approx::custom(); }; template diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 6bad3c92..7716196d 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1108,7 +1108,7 @@ CmdLine.tests.cpp:: passed: config.benchmarkSamples == 200 for: 200 CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-resamples=20000" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkResamples == 20000 for: 20000 (0x) == 20000 (0x) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} -CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Detail::Approx(0.99) for: 0.99 == Approx( 0.99 ) +CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkNoAnalysis for: true Misc.tests.cpp:: passed: std::tuple_size::value >= 1 for: 3 >= 1 diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 6665214a..3dc7166c 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -8022,7 +8022,7 @@ with expansion: {?} CmdLine.tests.cpp:: PASSED: - REQUIRE( config.benchmarkConfidenceInterval == Catch::Detail::Approx(0.99) ) + REQUIRE( config.benchmarkConfidenceInterval == Catch::Approx(0.99) ) with expansion: 0.99 == Approx( 0.99 ) diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 9560c81a..d2bda84f 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -2139,7 +2139,7 @@ ok 1067 - config.benchmarkResamples == 20000 for: 20000 (0x) == 2000 # Process can be configured on command line ok 1068 - cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} # Process can be configured on command line -ok 1069 - config.benchmarkConfidenceInterval == Catch::Detail::Approx(0.99) for: 0.99 == Approx( 0.99 ) +ok 1069 - config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) # Process can be configured on command line ok 1070 - cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} # Process can be configured on command line diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 5b07c107..521bdd54 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -10103,7 +10103,7 @@ Nor would this - config.benchmarkConfidenceInterval == Catch::Detail::Approx(0.99) + config.benchmarkConfidenceInterval == Catch::Approx(0.99) 0.99 == Approx( 0.99 ) diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index c2a4db0a..bff30f2c 100644 --- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -489,7 +489,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION("resamples") { CHECK(cli.parse({ "test", "--benchmark-confidence-interval=0.99" })); - REQUIRE(config.benchmarkConfidenceInterval == Catch::Detail::Approx(0.99)); + REQUIRE(config.benchmarkConfidenceInterval == Catch::Approx(0.99)); } SECTION("resamples") { diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 3406480e..17bc58e6 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -178,7 +178,7 @@ TEST_CASE("Generators internals", "[generators][internals]") { } SECTION("Floating Point") { - using Catch::Detail::Approx; + using Catch::Approx; SECTION("Exact") { const auto rangeStart = -1.; const auto rangeEnd = 1.; diff --git a/tests/SelfTest/UsageTests/Approx.tests.cpp b/tests/SelfTest/UsageTests/Approx.tests.cpp index 181d2d4c..9a1f0474 100644 --- a/tests/SelfTest/UsageTests/Approx.tests.cpp +++ b/tests/SelfTest/UsageTests/Approx.tests.cpp @@ -11,7 +11,7 @@ #include -using Catch::Detail::Approx; +using Catch::Approx; namespace { namespace ApproxTests { diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index 489d6994..28ca8dd6 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -14,7 +14,7 @@ #include #include -using Catch::Detail::Approx; +using Catch::Approx; #include #include