diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/all_features/CMakeLists.txt | 19 | ||||
-rw-r--r-- | examples/all_features/namespace1.cpp | 27 | ||||
-rw-r--r-- | examples/all_features/namespace2.cpp | 24 | ||||
-rw-r--r-- | examples/all_features/namespace3.cpp | 22 | ||||
-rw-r--r-- | examples/all_features/namespace4.cpp | 37 | ||||
-rw-r--r-- | examples/all_features/namespace5.cpp | 39 | ||||
-rw-r--r-- | examples/all_features/namespace6.cpp | 41 | ||||
-rw-r--r-- | examples/all_features/namespace7.cpp | 41 | ||||
-rw-r--r-- | examples/all_features/namespace8.cpp | 45 | ||||
-rw-r--r-- | examples/all_features/namespace9.cpp | 44 | ||||
-rw-r--r-- | examples/all_features/test_output/filter_2.txt | 2 | ||||
-rw-r--r-- | examples/all_features/test_output/filter_2_xml.txt | 11 |
12 files changed, 350 insertions, 2 deletions
diff --git a/examples/all_features/CMakeLists.txt b/examples/all_features/CMakeLists.txt index f2573963..829c15bd 100644 --- a/examples/all_features/CMakeLists.txt +++ b/examples/all_features/CMakeLists.txt @@ -22,6 +22,15 @@ set(files_all ${files_with_output} concurrency.cpp ../../scripts/coverage_maxout.cpp + namespace1.cpp + namespace2.cpp + namespace3.cpp + namespace4.cpp + namespace5.cpp + namespace6.cpp + namespace7.cpp + namespace8.cpp + namespace9.cpp ) # add the executable @@ -49,6 +58,16 @@ if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL) doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp -d) # duration: there is no output anyway endif() +doctest_add_test(NO_OUTPUT NAME namespace1.cpp ${common_args} -sf=*namespace1.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace2.cpp ${common_args} -sf=*namespace2.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace3.cpp ${common_args} -sf=*namespace3.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace4.cpp ${common_args} -sf=*namespace4.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace5.cpp ${common_args} -sf=*namespace5.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace6.cpp ${common_args} -sf=*namespace6.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace7.cpp ${common_args} -sf=*namespace7.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace8.cpp ${common_args} -sf=*namespace8.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace9.cpp ${common_args} -sf=*namespace9.cpp ) + # add this separately since the file has a non-straightforward path doctest_add_test(NAME coverage_maxout.cpp ${common_args} -sf=*coverage_maxout.cpp) diff --git a/examples/all_features/namespace1.cpp b/examples/all_features/namespace1.cpp new file mode 100644 index 00000000..4014ab54 --- /dev/null +++ b/examples/all_features/namespace1.cpp @@ -0,0 +1,27 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user1 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user1 + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user1::label& lhs, const user1::label& rhs) { return lhs.i == rhs.i; } + + +TEST_CASE("namespace 1 global operator") { + user1::label a; + user1::label b; + CHECK(a == b); +} diff --git a/examples/all_features/namespace2.cpp b/examples/all_features/namespace2.cpp new file mode 100644 index 00000000..3dc1d556 --- /dev/null +++ b/examples/all_features/namespace2.cpp @@ -0,0 +1,24 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user2 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user2::label& lhs, const user2::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user2 + +TEST_CASE("namespace 2 friend operator") { + user2::label a; + user2::label b; + REQUIRE(a == b); +} diff --git a/examples/all_features/namespace3.cpp b/examples/all_features/namespace3.cpp new file mode 100644 index 00000000..a1015aa0 --- /dev/null +++ b/examples/all_features/namespace3.cpp @@ -0,0 +1,22 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user3 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user3::label& rhs) const { return i == rhs.i; } +}; +} // namespace user3 + +TEST_CASE("namespace 3 member operator") { + user3::label a; + user3::label b; + REQUIRE(a == b); +} diff --git a/examples/all_features/namespace4.cpp b/examples/all_features/namespace4.cpp new file mode 100644 index 00000000..88d74628 --- /dev/null +++ b/examples/all_features/namespace4.cpp @@ -0,0 +1,37 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user4 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user4::label& rhs) const { return i == rhs.i; } +}; +} // namespace user4 + +namespace user5 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user5::label& rhs) const { return i == rhs.i; } +}; +} // namespace user5 + +TEST_CASE("namespace 4 member vs member") { + user4::label a4; + user4::label b4; + + user5::label a5; + user5::label b5; + + REQUIRE(a4 == b4); + REQUIRE(a5 == b5); +} diff --git a/examples/all_features/namespace5.cpp b/examples/all_features/namespace5.cpp new file mode 100644 index 00000000..20fb0d77 --- /dev/null +++ b/examples/all_features/namespace5.cpp @@ -0,0 +1,39 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user6::label& rhs) const { return i == rhs.i; } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user7::label& lhs, const user7::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user7 + +TEST_CASE("namespace 5 member vs friend") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/examples/all_features/namespace6.cpp b/examples/all_features/namespace6.cpp new file mode 100644 index 00000000..e8c66e2a --- /dev/null +++ b/examples/all_features/namespace6.cpp @@ -0,0 +1,41 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user6::label& lhs, const user6::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user7::label& lhs, const user7::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user7 + +TEST_CASE("namespace 6 friend vs friend") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/examples/all_features/namespace7.cpp b/examples/all_features/namespace7.cpp new file mode 100644 index 00000000..c2c27322 --- /dev/null +++ b/examples/all_features/namespace7.cpp @@ -0,0 +1,41 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user6::label& rhs) const { return i == rhs.i; } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user7 + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user7::label& lhs, const user7::label& rhs) { return lhs.i == rhs.i; } + +TEST_CASE("namespace 7 member vs global") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/examples/all_features/namespace8.cpp b/examples/all_features/namespace8.cpp new file mode 100644 index 00000000..cfc2131b --- /dev/null +++ b/examples/all_features/namespace8.cpp @@ -0,0 +1,45 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user6::label& lhs, const user6::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user6 + +namespace user8 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user8 + + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user8::label& lhs, const user8::label& rhs) { return lhs.i == rhs.i; } + + +TEST_CASE("namespace 8 friend vs global") { + user6::label a6; + user6::label b6; + + user8::label a8; + user8::label b8; + + REQUIRE(a6 == b6); + REQUIRE(a8 == b8); +} diff --git a/examples/all_features/namespace9.cpp b/examples/all_features/namespace9.cpp new file mode 100644 index 00000000..078e6235 --- /dev/null +++ b/examples/all_features/namespace9.cpp @@ -0,0 +1,44 @@ +#include <doctest/doctest.h> + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include <cstdint> +#include <sstream> +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user9a { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user9a + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") +bool operator==(const user9a::label& lhs, const user9a::label& rhs) { return lhs.i == rhs.i; } + +namespace user9b { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user9b + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user9b::label& lhs, const user9b::label& rhs) { return lhs.i == rhs.i; } + +TEST_CASE("namespace 9 both global") { + user9a::label a1; + user9a::label a2; + + user9b::label b1; + user9b::label b2; + + REQUIRE(a1 == a2); + REQUIRE(b1 == b2); +} diff --git a/examples/all_features/test_output/filter_2.txt b/examples/all_features/test_output/filter_2.txt index 18fe1062..8abc26e2 100644 --- a/examples/all_features/test_output/filter_2.txt +++ b/examples/all_features/test_output/filter_2.txt @@ -1,6 +1,6 @@ [doctest] run with "--help" for options =============================================================================== -[doctest] test cases: 0 | 0 passed | 0 failed | 81 skipped +[doctest] test cases: 0 | 0 passed | 0 failed | 90 skipped [doctest] assertions: 0 | 0 passed | 0 failed | [doctest] Status: SUCCESS! Program code. diff --git a/examples/all_features/test_output/filter_2_xml.txt b/examples/all_features/test_output/filter_2_xml.txt index fde7c970..9bec5b7b 100644 --- a/examples/all_features/test_output/filter_2_xml.txt +++ b/examples/all_features/test_output/filter_2_xml.txt @@ -75,6 +75,15 @@ <TestCase name="multiple types<>" filename="templated_test_cases.cpp" line="0" skipped="true"/> <TestCase name="multiple types<>" filename="templated_test_cases.cpp" line="0" skipped="true"/> <TestCase name="multiple types<>" filename="templated_test_cases.cpp" line="0" skipped="true"/> + <TestCase name="namespace 1 global operator" filename="namespace1.cpp" line="0" skipped="true"/> + <TestCase name="namespace 2 friend operator" filename="namespace2.cpp" line="0" skipped="true"/> + <TestCase name="namespace 3 member operator" filename="namespace3.cpp" line="0" skipped="true"/> + <TestCase name="namespace 4 member vs member" filename="namespace4.cpp" line="0" skipped="true"/> + <TestCase name="namespace 5 member vs friend" filename="namespace5.cpp" line="0" skipped="true"/> + <TestCase name="namespace 6 friend vs friend" filename="namespace6.cpp" line="0" skipped="true"/> + <TestCase name="namespace 7 member vs global" filename="namespace7.cpp" line="0" skipped="true"/> + <TestCase name="namespace 8 friend vs global" filename="namespace8.cpp" line="0" skipped="true"/> + <TestCase name="namespace 9 both global" filename="namespace9.cpp" line="0" skipped="true"/> <TestCase name="normal macros" filename="assertion_macros.cpp" line="0" skipped="true"/> </TestSuite> <TestSuite name="ts1"> @@ -119,6 +128,6 @@ <TestCase name="will end from an unknown exception" filename="coverage_maxout.cpp" line="0" skipped="true"/> </TestSuite> <OverallResultsAsserts successes="0" failures="0"/> - <OverallResultsTestCases successes="0" failures="0" skipped="81"/> + <OverallResultsTestCases successes="0" failures="0" skipped="90"/> </doctest> Program code. |