From 78e11c76251e106389956776e36b824a50e49d7c Mon Sep 17 00:00:00 2001 From: Menno Fraters Date: Tue, 22 Feb 2022 14:29:58 -0800 Subject: [PATCH 1/5] Update doctest with few modifications. --- tests/doctest.h | 146 ++++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 68 deletions(-) diff --git a/tests/doctest.h b/tests/doctest.h index 5fefe7186..3b6e965b1 100644 --- a/tests/doctest.h +++ b/tests/doctest.h @@ -497,8 +497,6 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP namespace doctest { -class Contains; - DOCTEST_INTERFACE extern bool is_running_in_test; // A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length @@ -581,21 +579,12 @@ class DOCTEST_INTERFACE String int compare(const char* other, bool no_case = false) const; int compare(const String& other, bool no_case = false) const; - const char *compare(const Contains& other) const; -}; - -class DOCTEST_INTERFACE Contains { -public: - Contains(const char* string); - - String string; }; DOCTEST_INTERFACE String operator+(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs); -DOCTEST_INTERFACE bool operator!=(const String& lhs, const Contains& rhs); DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs); @@ -603,6 +592,22 @@ DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs); DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in); +class DOCTEST_INTERFACE Contains { +public: + explicit Contains(const String& string); + + bool checkWith(const String& other) const; + + String string; +}; + +DOCTEST_INTERFACE String toString(const Contains& in); + +DOCTEST_INTERFACE bool operator==(const String& lhs, const Contains& rhs); +DOCTEST_INTERFACE bool operator==(const Contains& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator!=(const String& lhs, const Contains& rhs); +DOCTEST_INTERFACE bool operator!=(const Contains& lhs, const String& rhs); + namespace Color { enum Enum { @@ -755,10 +760,27 @@ struct DOCTEST_INTERFACE AssertData String m_decomp; // for specific exception-related asserts - bool m_threw_as; - const char* m_exception_type; - String m_exception_string; - bool m_contains; + bool m_threw_as; + const char* m_exception_type; + class DOCTEST_INTERFACE StringContains { + private: + Contains content; + bool isContains; + + public: + StringContains() : content(String()), isContains(false) { } + StringContains(const String& str) : content(str), isContains(false) { } + StringContains(const Contains& cntn) : content(cntn), isContains(true) { } + + bool check(const String& str) { return isContains ? (content == str) : (content.string == str); } + + operator const String&() const { return content.string; } + + const char* c_str() const { return content.string.c_str(); } + } m_exception_string; + + AssertData(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const StringContains& exception_string); }; struct DOCTEST_INTERFACE MessageData @@ -1531,10 +1553,10 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP struct DOCTEST_INTERFACE ResultBuilder : public AssertData { ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type = "", const char* exception_string = ""); + const char* exception_type = "", const String& exception_string = ""); ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, Contains exception_string); + const char* exception_type, const Contains& exception_string); void setResult(const Result& res); @@ -3655,29 +3677,33 @@ int String::compare(const String& other, bool no_case) const { return compare(other.c_str(), no_case); } -const char *String::compare(const Contains& other) const { - return strstr(c_str(), other.string.c_str()); -} - -Contains::Contains(const char* in){ - string = String(in); - } - // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) String operator+(const String& lhs, const String& rhs) { return String(lhs) += rhs; } -// clang-format off bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; } bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; } -bool operator!=(const String& lhs, const Contains& rhs) { return lhs.compare(rhs) == nullptr; } bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; } bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; } bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; } bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; } -// clang-format on std::ostream& operator<<(std::ostream& s, const String& in) { return s << in.c_str(); } +Contains::Contains(const String& str) : string(str) { } + +bool Contains::checkWith(const String& full_string) const { + return strstr(full_string.c_str(), string.c_str()) != nullptr; +} + +String toString(const Contains& in) { + return "Contains( " + in.string + " )"; +} + +bool operator==(const String& lhs, const Contains& rhs) { return rhs.checkWith(lhs); } +bool operator==(const Contains& lhs, const String& rhs) { return lhs.checkWith(rhs); } +bool operator!=(const String& lhs, const Contains& rhs) { return !rhs.checkWith(lhs); } +bool operator!=(const Contains& lhs, const String& rhs) { return !lhs.checkWith(rhs); } + namespace { void color_to_stream(std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;) } // namespace @@ -4730,44 +4756,26 @@ namespace { } #endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH } // namespace -namespace detail { - ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const char* exception_string) { - m_test_case = g_cs->currentTest; - m_at = at; - m_file = file; - m_line = line; - m_expr = expr; - m_failed = true; - m_threw = false; - m_threw_as = false; - m_exception_type = exception_type; - m_exception_string = String(exception_string); - m_contains = false; + +AssertData::AssertData(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const StringContains& exception_string) + : m_test_case(g_cs->currentTest), m_at(at), m_file(file), m_line(line), m_expr(expr), + m_failed(true), m_threw(false), m_threw_as(false), m_exception_type(exception_type), + m_exception_string(exception_string) { #if DOCTEST_MSVC - if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC - ++m_expr; + if (m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC + ++m_expr; #endif // MSVC - } +} +namespace detail { ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, Contains exception_string) { - m_test_case = g_cs->currentTest; - m_at = at; - m_file = file; - m_line = line; - m_expr = expr; - m_failed = true; - m_threw = false; - m_threw_as = false; - m_exception_type = exception_type; - m_exception_string = exception_string.string; - m_contains = true; -#if DOCTEST_MSVC - if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC - ++m_expr; -#endif // MSVC - } + const char* exception_type, const String& exception_string) + : AssertData(at, file, line, expr, exception_type, exception_string) { } + + ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const Contains& exception_string) + : AssertData(at, file, line, expr, exception_type, exception_string) { } void ResultBuilder::setResult(const Result& res) { m_decomp = res.m_decomp; @@ -4783,11 +4791,11 @@ namespace detail { if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional m_failed = !m_threw; } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT - m_failed = !m_threw_as || ( m_contains ? m_exception != Contains(m_exception_string.c_str()) : m_exception != String(m_exception_string)); + m_failed = !m_threw_as || !m_exception_string.check(m_exception); } else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional m_failed = !m_threw_as; } else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional - m_failed = ( m_contains ? m_exception != Contains(m_exception_string.c_str()) : m_exception != String(m_exception_string)); + m_failed = !m_exception_string.check(m_exception); } else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional m_failed = m_threw; } @@ -5506,7 +5514,8 @@ namespace { } else if((rb.m_at & assertType::is_throws_as) && (rb.m_at & assertType::is_throws_with)) { //!OCLINT s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" - << rb.m_exception_string << "\", " << rb.m_exception_type << " ) " << Color::None; + << rb.m_exception_string.c_str() + << "\", " << rb.m_exception_type << " ) " << Color::None; if(rb.m_threw) { if(!rb.m_failed) { s << "threw as expected!\n"; @@ -5527,7 +5536,8 @@ namespace { } else if(rb.m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" - << rb.m_exception_string << "\" ) " << Color::None + << rb.m_exception_string.c_str() + << "\" ) " << Color::None << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : "threw a DIFFERENT exception: ") : "did NOT throw at all!") @@ -6346,8 +6356,8 @@ namespace { char character = *current++; if(seenBackslash) { seenBackslash = false; - if(character == ',') { - s.put(','); + if(character == ',' || character == '\\') { + s.put(character); continue; } s.put('\\'); From d57f65639ac9f7b26a299abeab6da811a401fd26 Mon Sep 17 00:00:00 2001 From: Menno Fraters Date: Wed, 16 Mar 2022 14:31:21 -0700 Subject: [PATCH 2/5] fix type issues in unit tests. --- tests/unit_tests/unit_test_world_builder.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit_tests/unit_test_world_builder.cc b/tests/unit_tests/unit_test_world_builder.cc index ba7d58d01..8cd42b8e6 100644 --- a/tests/unit_tests/unit_test_world_builder.cc +++ b/tests/unit_tests/unit_test_world_builder.cc @@ -767,7 +767,7 @@ TEST_CASE("WorldBuilder C wrapper") const char *world_builder_file2 = file.c_str(); has_output_dir = false; - create_world(ptr_ptr_world, world_builder_file2, &has_output_dir, "", 1.0); + create_world(ptr_ptr_world, world_builder_file2, &has_output_dir, "", 1); CHECK_THROWS_WITH(temperature_2d(*ptr_ptr_world, 1, 2, 0, 10, &temperature), @@ -3865,12 +3865,12 @@ TEST_CASE("WorldBuilder Parameters") CHECK_THROWS_WITH(prm.get("non existent unsigned int"), Contains("internal error: could not retrieve the default value at")); - CHECK(prm.get("unsigned int") == Approx(4.0)); + CHECK(prm.get("unsigned int") == 4); CHECK_THROWS_WITH(prm.get("non existent unsigned int"), Contains("internal error: could not retrieve the default value at")); - CHECK(prm.get("unsigned int") == Approx(4.0)); + CHECK(prm.get("unsigned int") == 4); CHECK_THROWS_WITH(prm.get("non existent double"), @@ -3938,14 +3938,14 @@ TEST_CASE("WorldBuilder Parameters") std::vector v_size_t = prm.get_vector("now existent unsigned int vector"); CHECK(v_size_t.size() == 2); - CHECK(v_size_t[0] == Approx(1.0)); - CHECK(v_size_t[1] == Approx(1.0)); + CHECK(v_size_t[0] == 1); + CHECK(v_size_t[1] == 1); v_size_t = prm.get_vector("unsigned int array"); CHECK(v_size_t.size() == 3); - CHECK(v_size_t[0] == Approx(25.0)); - CHECK(v_size_t[1] == Approx(26.0)); - CHECK(v_size_t[2] == Approx(27.0)); + CHECK(v_size_t[0] == 25); + CHECK(v_size_t[1] == 26); + CHECK(v_size_t[2] == 27); CHECK_THROWS_WITH(prm.get_vector("non existent unsigned int vector"), From c547ebee87c3e11691e102e1add1c5f33dac7c93 Mon Sep 17 00:00:00 2001 From: Menno Fraters Date: Wed, 16 Mar 2022 14:38:36 -0700 Subject: [PATCH 3/5] fix type issues in unit tests. --- tests/unit_tests/unit_test_world_builder.cc | 254 ++++++++++---------- 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/tests/unit_tests/unit_test_world_builder.cc b/tests/unit_tests/unit_test_world_builder.cc index 8cd42b8e6..951c392d4 100644 --- a/tests/unit_tests/unit_test_world_builder.cc +++ b/tests/unit_tests/unit_test_world_builder.cc @@ -4752,8 +4752,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -4776,7 +4776,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-4); // practically zero CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.598958)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-5); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -4805,8 +4805,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(std::sqrt(10*10+10*10))); CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -4832,8 +4832,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -4858,8 +4858,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(std::sqrt(10*10+10*10))); CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -4886,7 +4886,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); @@ -4913,7 +4913,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(std::fabs(distance_from_planes.fraction_of_section) < 1e-14); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); @@ -4941,7 +4941,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); @@ -4968,8 +4968,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); // The old method for slabs can not provide the corners when out of bounds and returns a nan. The new method can do this, @@ -4994,8 +4994,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{0.,10.,10.}}); @@ -5022,8 +5022,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); // The old method for slabs can not provide the corners when out of bounds and returns a nan. The new method can do this, @@ -5048,8 +5048,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); CHECK(distance_from_planes.closest_trench_point.get_array()[0] == Approx(25.)); @@ -5080,8 +5080,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-3.5355339059)); CHECK(distance_from_planes.distance_along_plane == Approx(10.6066017178)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.75)); CHECK(distance_from_planes.depth_reference_surface == Approx(7.5)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -5109,8 +5109,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(3.5355339059)); CHECK(distance_from_planes.distance_along_plane == Approx(10.6066017178)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.75)); @@ -5137,7 +5137,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(3.5355339059)); CHECK(distance_from_planes.distance_along_plane == Approx(17.6776695297)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0176776695)); @@ -5165,7 +5165,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(3.5355339059)); CHECK(distance_from_planes.distance_along_plane == Approx(17.6776695297)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0176776695)); @@ -5203,7 +5203,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // different angle @@ -5238,8 +5238,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(distance_from_planes.distance_along_plane == Approx(10.8239219938)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.7653668647)); // check interpolation 1 (in the middle of a segment with 22.5 degree and a segement with 45) @@ -5266,7 +5266,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(12.0268977387)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.8504300948)); // check interpolation 2 (at the end of the segment at 45 degree) @@ -5293,7 +5293,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(14.1421356237)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // check length interpolation with 90 degree angles for simplicity @@ -5340,8 +5340,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(100.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // check length interpolation first segment center 2 @@ -5367,7 +5367,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(101.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.01)); @@ -5394,7 +5394,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(200.0)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5423,8 +5423,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); @@ -5454,7 +5454,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(75.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // check length interpolation second segment center 2 @@ -5536,8 +5536,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // Now check the end of the second segment, each segment should have a length of 50. @@ -5565,7 +5565,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(50.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // check length interpolation second segment center 2 @@ -5647,8 +5647,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); } @@ -5737,7 +5737,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5765,7 +5765,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(5.0)); // checked that it should be about 5 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5793,7 +5793,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-5.0)); // checked that it should be about -5 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5822,8 +5822,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(2.9289321881)); @@ -5850,8 +5850,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-10.0)); // checked that it should be about -10 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(2.9289321881)); @@ -5882,8 +5882,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca // where the check point has angle 0. This means that the distanceAlongPlate is zero. CHECK(distance_from_planes.distance_along_plane == Approx(0.0)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); @@ -5911,8 +5911,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(0.0)); @@ -5944,7 +5944,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 5)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(5.0)); @@ -5972,8 +5972,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45.0 * Utilities::const_pi/180 * 5)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6014,8 +6014,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 11 @@ -6041,8 +6041,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); // curve test 12 @@ -6068,7 +6068,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(135.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); CHECK(distance_from_planes.depth_reference_surface == Approx(17.0710678119)); @@ -6097,7 +6097,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6138,8 +6138,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); // curve test 15 @@ -6165,8 +6165,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 16 @@ -6192,8 +6192,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-1.0)); // checked that it should be about -1 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 16 @@ -6219,8 +6219,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(1.0)); // checked that it should be about -1 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 17 @@ -6246,7 +6246,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6274,7 +6274,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-1.0)); // checked that it should be about 1 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6301,7 +6301,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(1.0)); // checked that it should be about 1 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6343,8 +6343,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0/3.0)); // curve test 21 @@ -6370,8 +6370,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(2.0/3.0)); // curve test 21 @@ -6397,8 +6397,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 22 @@ -6424,7 +6424,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(315.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6468,7 +6468,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-7.3205080757)); // checked that it should be about -7.3 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(9.5531661812)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.2163468959)); @@ -6499,8 +6499,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::isinf(distance_from_planes.distance_from_plane)); CHECK(std::isinf(distance_from_planes.distance_along_plane)); CHECK(distance_from_planes.fraction_of_section == Approx(0.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // curve test change reference point 2 @@ -6526,7 +6526,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(2.3463313527)); // checked that it should be about 2.3 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(11.780972451)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); @@ -6571,8 +6571,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(2.0/3.0)); // curve test reverse angle 1 @@ -6615,8 +6615,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test reverse angle 2 @@ -6642,7 +6642,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6669,7 +6669,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(135.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); @@ -6698,7 +6698,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.1 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0011111111)); @@ -6726,7 +6726,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90.001 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.000011111111)); @@ -6767,8 +6767,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test reverse angle 6 @@ -6795,8 +6795,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test reverse angle 6 @@ -6823,8 +6823,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(45 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6852,7 +6852,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(46 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0222222222)); @@ -6882,7 +6882,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(0.0697227738)); // checked that it should be small positive this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx((90 - 44.4093) * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0131266424)); @@ -6910,7 +6910,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_from_plane == Approx(-0.0692053058)); // checked that it should be small negative this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx((90 - 43.585) * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(0.031445048)); @@ -6938,7 +6938,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(distance_from_planes.distance_along_plane == Approx(90 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); + CHECK(distance_from_planes.section == 0); CHECK(distance_from_planes.segment == Approx(1.0)); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6968,8 +6968,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // global_x_list test 2 @@ -6996,8 +6996,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(0.25)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // global_x_list test 3 @@ -7024,8 +7024,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(0.375)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // global_x_list test 4 @@ -7052,8 +7052,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); // global_x_list test 5 @@ -7081,7 +7081,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-12); CHECK(distance_from_planes.fraction_of_section == Approx(0.75)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-12); @@ -7111,7 +7111,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); } @@ -7174,8 +7174,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(std::fabs(distance_from_planes.fraction_of_section) < 1e-14); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); @@ -7202,8 +7202,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); @@ -7234,8 +7234,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); @@ -7261,8 +7261,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(distance_from_planes.distance_from_plane == Approx(10*sqrt(2)/4)); // checked it with a geometric drawing CHECK(distance_from_planes.distance_along_plane == Approx(10*sqrt(2)/4)); // checked it with a geometric drawing CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.25)); @@ -7297,8 +7297,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(distance_from_planes.distance_from_plane == Approx(10*sqrt(2)/2)); // checked it with a geometric drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); // checked it with a geometric drawing CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-14); @@ -7323,8 +7323,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked it with a geometric drawing CHECK(distance_from_planes.distance_along_plane == Approx(10*sqrt(2)/2)); // checked it with a geometric drawing CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); // spherical curve test 1 @@ -7361,8 +7361,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes sp CHECK(distance_from_planes.distance_from_plane == Approx(4.072033215)); // see comment at the top of the test CHECK(distance_from_planes.distance_along_plane == Approx(6.6085171895)); // see comment at the top of the test CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(0.0)); - CHECK(distance_from_planes.segment == Approx(0.0)); + CHECK(distance_from_planes.section == 0); + CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.4672927318));*/ } From b9913946d5999ccb6612dc8a634ba5c881b031e2 Mon Sep 17 00:00:00 2001 From: Menno Fraters Date: Wed, 16 Mar 2022 14:44:40 -0700 Subject: [PATCH 4/5] fix type issues in unit tests. --- tests/unit_tests/unit_test_world_builder.cc | 86 ++++++++++----------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/unit_tests/unit_test_world_builder.cc b/tests/unit_tests/unit_test_world_builder.cc index 951c392d4..c893385f3 100644 --- a/tests/unit_tests/unit_test_world_builder.cc +++ b/tests/unit_tests/unit_test_world_builder.cc @@ -4777,7 +4777,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.598958)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-5); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); compare_vectors_approx(std::vector(std::begin(distance_from_planes.closest_trench_point.get_array()), @@ -4887,7 +4887,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{10.,10.,10.}}); @@ -4914,7 +4914,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(std::fabs(distance_from_planes.fraction_of_section) < 1e-14); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{0.,10.,10.}}); @@ -4942,7 +4942,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(sqrt(20*20+20*20))); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0707106781)); // practically zero CHECK(distance_from_planes.depth_reference_surface == Approx(20.0)); CHECK(distance_from_planes.closest_trench_point.get_array() == std::array {{20.,10.,10.}}); @@ -5138,7 +5138,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(17.6776695297)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0176776695)); @@ -5166,7 +5166,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(17.6776695297)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0176776695)); // add coordinate @@ -5202,7 +5202,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // practically zero CHECK(distance_from_planes.distance_along_plane == Approx(std::sqrt(10*10+10*10))); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5265,7 +5265,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(12.0268977387)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.8504300948)); @@ -5292,7 +5292,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(14.1421356237)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5368,7 +5368,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(101.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.01)); // check length interpolation first segment center 3 @@ -5395,7 +5395,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(200.0)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5453,7 +5453,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(75.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5480,8 +5480,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(76.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.section == 1); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.01333333333333)); // check length interpolation second segment center 3 @@ -5507,8 +5507,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(150.0)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); - CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.section == 1); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5564,7 +5564,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(50.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5591,8 +5591,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(51.0)); // practically zero CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.section == 1); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.02)); // check length interpolation second segment center 3 @@ -5618,8 +5618,8 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); CHECK(distance_from_planes.distance_along_plane == Approx(100.0)); CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(1.0)); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.section == 1); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -5738,7 +5738,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5766,7 +5766,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5794,7 +5794,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(10.0)); @@ -5945,7 +5945,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.0 * Utilities::const_pi/180 * 5)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); CHECK(distance_from_planes.depth_reference_surface == Approx(5.0)); @@ -6069,7 +6069,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(135.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); CHECK(distance_from_planes.depth_reference_surface == Approx(17.0710678119)); @@ -6098,7 +6098,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 14 @@ -6247,7 +6247,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6275,7 +6275,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test 19 @@ -6302,7 +6302,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(270.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -6425,7 +6425,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(315.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test start 45 degree 1 @@ -6469,7 +6469,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(9.5531661812)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.2163468959)); // curve test change reference point 1 @@ -6527,7 +6527,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(11.780972451)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); // curve test angle interpolation 1 @@ -6643,7 +6643,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(180.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); // curve test reverse angle 3 @@ -6670,7 +6670,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(135.0 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.5)); // curve test reverse angle 4 @@ -6699,7 +6699,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.1 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0011111111)); @@ -6727,7 +6727,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90.001 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.000011111111)); // curve test reverse angle 6 @@ -6853,7 +6853,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(46 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0222222222)); @@ -6883,7 +6883,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx((90 - 44.4093) * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0131266424)); // curve test reverse angle 9 @@ -6911,7 +6911,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx((90 - 43.585) * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(0.031445048)); // curve test reverse angle 10 @@ -6939,7 +6939,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(distance_from_planes.distance_along_plane == Approx(90 * Utilities::const_pi/180 * 10)); CHECK(distance_from_planes.fraction_of_section == Approx(0.5)); CHECK(distance_from_planes.section == 0); - CHECK(distance_from_planes.segment == Approx(1.0)); + CHECK(distance_from_planes.segment == 1); CHECK(distance_from_planes.fraction_of_segment == Approx(1.0)); @@ -7080,7 +7080,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-12); CHECK(distance_from_planes.fraction_of_section == Approx(0.75)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(std::fabs(distance_from_planes.fraction_of_segment) < 1e-12); @@ -7110,7 +7110,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca CHECK(std::fabs(distance_from_planes.distance_from_plane) < 1e-14); // checked that it should be about 0 this with a drawing CHECK(std::fabs(distance_from_planes.distance_along_plane) < 1e-14); CHECK(distance_from_planes.fraction_of_section == Approx(1.0)); - CHECK(distance_from_planes.section == Approx(1.0)); + CHECK(distance_from_planes.section == 1); CHECK(distance_from_planes.segment == 0); CHECK(distance_from_planes.fraction_of_segment == Approx(0.0)); From 11f60118b931e79ba9fc6048eccd3d72aec9a2b5 Mon Sep 17 00:00:00 2001 From: Menno Fraters Date: Wed, 16 Mar 2022 14:55:32 -0700 Subject: [PATCH 5/5] revort doctest changes. --- tests/doctest.h | 146 ++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 78 deletions(-) diff --git a/tests/doctest.h b/tests/doctest.h index 3b6e965b1..5fefe7186 100644 --- a/tests/doctest.h +++ b/tests/doctest.h @@ -497,6 +497,8 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP namespace doctest { +class Contains; + DOCTEST_INTERFACE extern bool is_running_in_test; // A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length @@ -579,12 +581,21 @@ class DOCTEST_INTERFACE String int compare(const char* other, bool no_case = false) const; int compare(const String& other, bool no_case = false) const; + const char *compare(const Contains& other) const; +}; + +class DOCTEST_INTERFACE Contains { +public: + Contains(const char* string); + + String string; }; DOCTEST_INTERFACE String operator+(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator!=(const String& lhs, const Contains& rhs); DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs); DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs); @@ -592,22 +603,6 @@ DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs); DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in); -class DOCTEST_INTERFACE Contains { -public: - explicit Contains(const String& string); - - bool checkWith(const String& other) const; - - String string; -}; - -DOCTEST_INTERFACE String toString(const Contains& in); - -DOCTEST_INTERFACE bool operator==(const String& lhs, const Contains& rhs); -DOCTEST_INTERFACE bool operator==(const Contains& lhs, const String& rhs); -DOCTEST_INTERFACE bool operator!=(const String& lhs, const Contains& rhs); -DOCTEST_INTERFACE bool operator!=(const Contains& lhs, const String& rhs); - namespace Color { enum Enum { @@ -760,27 +755,10 @@ struct DOCTEST_INTERFACE AssertData String m_decomp; // for specific exception-related asserts - bool m_threw_as; - const char* m_exception_type; - class DOCTEST_INTERFACE StringContains { - private: - Contains content; - bool isContains; - - public: - StringContains() : content(String()), isContains(false) { } - StringContains(const String& str) : content(str), isContains(false) { } - StringContains(const Contains& cntn) : content(cntn), isContains(true) { } - - bool check(const String& str) { return isContains ? (content == str) : (content.string == str); } - - operator const String&() const { return content.string; } - - const char* c_str() const { return content.string.c_str(); } - } m_exception_string; - - AssertData(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const StringContains& exception_string); + bool m_threw_as; + const char* m_exception_type; + String m_exception_string; + bool m_contains; }; struct DOCTEST_INTERFACE MessageData @@ -1553,10 +1531,10 @@ DOCTEST_CLANG_SUPPRESS_WARNING_POP struct DOCTEST_INTERFACE ResultBuilder : public AssertData { ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type = "", const String& exception_string = ""); + const char* exception_type = "", const char* exception_string = ""); ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const Contains& exception_string); + const char* exception_type, Contains exception_string); void setResult(const Result& res); @@ -3677,33 +3655,29 @@ int String::compare(const String& other, bool no_case) const { return compare(other.c_str(), no_case); } +const char *String::compare(const Contains& other) const { + return strstr(c_str(), other.string.c_str()); +} + +Contains::Contains(const char* in){ + string = String(in); + } + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) String operator+(const String& lhs, const String& rhs) { return String(lhs) += rhs; } +// clang-format off bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; } bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; } +bool operator!=(const String& lhs, const Contains& rhs) { return lhs.compare(rhs) == nullptr; } bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; } bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; } bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; } bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; } +// clang-format on std::ostream& operator<<(std::ostream& s, const String& in) { return s << in.c_str(); } -Contains::Contains(const String& str) : string(str) { } - -bool Contains::checkWith(const String& full_string) const { - return strstr(full_string.c_str(), string.c_str()) != nullptr; -} - -String toString(const Contains& in) { - return "Contains( " + in.string + " )"; -} - -bool operator==(const String& lhs, const Contains& rhs) { return rhs.checkWith(lhs); } -bool operator==(const Contains& lhs, const String& rhs) { return lhs.checkWith(rhs); } -bool operator!=(const String& lhs, const Contains& rhs) { return !rhs.checkWith(lhs); } -bool operator!=(const Contains& lhs, const String& rhs) { return !lhs.checkWith(rhs); } - namespace { void color_to_stream(std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;) } // namespace @@ -4756,26 +4730,44 @@ namespace { } #endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH } // namespace - -AssertData::AssertData(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const StringContains& exception_string) - : m_test_case(g_cs->currentTest), m_at(at), m_file(file), m_line(line), m_expr(expr), - m_failed(true), m_threw(false), m_threw_as(false), m_exception_type(exception_type), - m_exception_string(exception_string) { -#if DOCTEST_MSVC - if (m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC - ++m_expr; -#endif // MSVC -} - namespace detail { ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const String& exception_string) - : AssertData(at, file, line, expr, exception_type, exception_string) { } + const char* exception_type, const char* exception_string) { + m_test_case = g_cs->currentTest; + m_at = at; + m_file = file; + m_line = line; + m_expr = expr; + m_failed = true; + m_threw = false; + m_threw_as = false; + m_exception_type = exception_type; + m_exception_string = String(exception_string); + m_contains = false; +#if DOCTEST_MSVC + if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC + ++m_expr; +#endif // MSVC + } ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, - const char* exception_type, const Contains& exception_string) - : AssertData(at, file, line, expr, exception_type, exception_string) { } + const char* exception_type, Contains exception_string) { + m_test_case = g_cs->currentTest; + m_at = at; + m_file = file; + m_line = line; + m_expr = expr; + m_failed = true; + m_threw = false; + m_threw_as = false; + m_exception_type = exception_type; + m_exception_string = exception_string.string; + m_contains = true; +#if DOCTEST_MSVC + if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC + ++m_expr; +#endif // MSVC + } void ResultBuilder::setResult(const Result& res) { m_decomp = res.m_decomp; @@ -4791,11 +4783,11 @@ namespace detail { if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional m_failed = !m_threw; } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT - m_failed = !m_threw_as || !m_exception_string.check(m_exception); + m_failed = !m_threw_as || ( m_contains ? m_exception != Contains(m_exception_string.c_str()) : m_exception != String(m_exception_string)); } else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional m_failed = !m_threw_as; } else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional - m_failed = !m_exception_string.check(m_exception); + m_failed = ( m_contains ? m_exception != Contains(m_exception_string.c_str()) : m_exception != String(m_exception_string)); } else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional m_failed = m_threw; } @@ -5514,8 +5506,7 @@ namespace { } else if((rb.m_at & assertType::is_throws_as) && (rb.m_at & assertType::is_throws_with)) { //!OCLINT s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" - << rb.m_exception_string.c_str() - << "\", " << rb.m_exception_type << " ) " << Color::None; + << rb.m_exception_string << "\", " << rb.m_exception_type << " ) " << Color::None; if(rb.m_threw) { if(!rb.m_failed) { s << "threw as expected!\n"; @@ -5536,8 +5527,7 @@ namespace { } else if(rb.m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" - << rb.m_exception_string.c_str() - << "\" ) " << Color::None + << rb.m_exception_string << "\" ) " << Color::None << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : "threw a DIFFERENT exception: ") : "did NOT throw at all!") @@ -6356,8 +6346,8 @@ namespace { char character = *current++; if(seenBackslash) { seenBackslash = false; - if(character == ',' || character == '\\') { - s.put(character); + if(character == ',') { + s.put(','); continue; } s.put('\\');