diff --git a/CMakeLists.txt b/CMakeLists.txt index e4a74a8d..6fe4e4e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/BDDTests.cpp ${SELF_TEST_DIR}/ClassTests.cpp ${SELF_TEST_DIR}/CmdLineTests.cpp + ${SELF_TEST_DIR}/CompilationTests.cpp ${SELF_TEST_DIR}/ConditionTests.cpp ${SELF_TEST_DIR}/EnumToString.cpp ${SELF_TEST_DIR}/ExceptionTests.cpp @@ -62,6 +63,7 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/PartTrackerTests.cpp ${SELF_TEST_DIR}/TagAliasTests.cpp ${SELF_TEST_DIR}/TestMain.cpp + ${SELF_TEST_DIR}/ToStringGeneralTests.cpp ${SELF_TEST_DIR}/ToStringPair.cpp ${SELF_TEST_DIR}/ToStringTuple.cpp ${SELF_TEST_DIR}/ToStringVector.cpp diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index ea2e1008..2b9f5696 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -829,6 +829,6 @@ with expansion: "first" == "second" =============================================================================== -test cases: 157 | 113 passed | 42 failed | 2 failed as expected -assertions: 913 | 817 passed | 78 failed | 18 failed as expected +test cases: 159 | 115 passed | 42 failed | 2 failed as expected +assertions: 928 | 832 passed | 78 failed | 18 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 2ea4dd0b..8b172f52 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -14,6 +14,18 @@ PASSED: with message: yay +------------------------------------------------------------------------------- +#809 +------------------------------------------------------------------------------- +CompilationTests.cpp: +............................................................................... + +CompilationTests.cpp:: +PASSED: + REQUIRE( 42 == f ) +with expansion: + 42 == {?} + ------------------------------------------------------------------------------- 'Not' checks that should fail ------------------------------------------------------------------------------- @@ -533,6 +545,111 @@ PASSED: with expansion: true +------------------------------------------------------------------------------- +Character pretty printing + Specifically escaped +------------------------------------------------------------------------------- +ToStringGeneralTests.cpp: +............................................................................... + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( tab == '\t' ) +with expansion: + '\t' == '\t' + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( newline == '\n' ) +with expansion: + '\n' == '\n' + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( carr_return == '\r' ) +with expansion: + '\r' == '\r' + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( form_feed == '\f' ) +with expansion: + '\f' == '\f' + +------------------------------------------------------------------------------- +Character pretty printing + General chars +------------------------------------------------------------------------------- +ToStringGeneralTests.cpp: +............................................................................... + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( space == ' ' ) +with expansion: + ' ' == ' ' + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'a' == 'a' + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'z' == 'z' + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'A' == 'A' + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'Z' == 'Z' + +------------------------------------------------------------------------------- +Character pretty printing + Low ASCII +------------------------------------------------------------------------------- +ToStringGeneralTests.cpp: +............................................................................... + +ToStringGeneralTests.cpp:: +PASSED: + CHECK( null_terminator == '\0' ) +with expansion: + 0 == 0 + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 2 == 2 + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 3 == 3 + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 4 == 4 + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 5 == 5 + ------------------------------------------------------------------------------- Comparing function pointers ------------------------------------------------------------------------------- @@ -9025,6 +9142,6 @@ MiscTests.cpp:: PASSED: =============================================================================== -test cases: 157 | 112 passed | 43 failed | 2 failed as expected -assertions: 915 | 817 passed | 80 failed | 18 failed as expected +test cases: 159 | 114 passed | 43 failed | 2 failed as expected +assertions: 930 | 832 passed | 80 failed | 18 failed as expected diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index ee0f5d31..c6905bb5 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -14,6 +14,18 @@ PASSED: with message: yay +------------------------------------------------------------------------------- +#809 +------------------------------------------------------------------------------- +CompilationTests.cpp: +............................................................................... + +CompilationTests.cpp:: +PASSED: + REQUIRE( 42 == f ) +with expansion: + 42 == {?} + ------------------------------------------------------------------------------- 'Not' checks that should fail ------------------------------------------------------------------------------- @@ -35,6 +47,6 @@ ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) =============================================================================== -test cases: 2 | 1 passed | 1 failed -assertions: 5 | 1 passed | 4 failed +test cases: 3 | 2 passed | 1 failed +assertions: 6 | 2 passed | 4 failed diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 55ee56c9..c27d9419 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,8 @@ - + + ConditionTests.cpp: @@ -80,6 +81,9 @@ ExceptionTests.cpp: + + + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 354ed640..a9076d29 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -4,6 +4,17 @@ + + + + 42 == f + + + 42 == {?} + + + + @@ -554,6 +565,130 @@ + +
+ + + tab == '\t' + + + '\t' == '\t' + + + + + newline == '\n' + + + '\n' == '\n' + + + + + carr_return == '\r' + + + '\r' == '\r' + + + + + form_feed == '\f' + + + '\f' == '\f' + + + +
+
+ + + space == ' ' + + + ' ' == ' ' + + + + + c == chars[i] + + + 'a' == 'a' + + + + + c == chars[i] + + + 'z' == 'z' + + + + + c == chars[i] + + + 'A' == 'A' + + + + + c == chars[i] + + + 'Z' == 'Z' + + + +
+
+ + + null_terminator == '\0' + + + 0 == 0 + + + + + c == i + + + 2 == 2 + + + + + c == i + + + 3 == 3 + + + + + c == i + + + 4 == 4 + + + + + c == i + + + 5 == 5 + + + +
+ +
@@ -9520,7 +9655,7 @@ there" - + - + diff --git a/projects/SelfTest/CompilationTests.cpp b/projects/SelfTest/CompilationTests.cpp new file mode 100644 index 00000000..f12372bf --- /dev/null +++ b/projects/SelfTest/CompilationTests.cpp @@ -0,0 +1,24 @@ +/* + * Created by Martin on 17/02/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch.hpp" + + +// This is a minimal example for an issue we have found in 1.7.0 +struct foo { + int i; +}; + +template +bool operator==(const T& val, foo f){ + return val == f.i; +} + +TEST_CASE("#809") { + foo f; f.i = 42; + REQUIRE(42 == f); +} diff --git a/projects/SelfTest/ToStringGeneralTests.cpp b/projects/SelfTest/ToStringGeneralTests.cpp new file mode 100644 index 00000000..a9fa4b83 --- /dev/null +++ b/projects/SelfTest/ToStringGeneralTests.cpp @@ -0,0 +1,40 @@ +/* + * Created by Martin on 17/02/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch.hpp" + + +TEST_CASE( "Character pretty printing" ){ + // + SECTION("Specifically escaped"){ + char tab = '\t'; + char newline = '\n'; + char carr_return = '\r'; + char form_feed = '\f'; + CHECK(tab == '\t'); + CHECK(newline == '\n'); + CHECK(carr_return == '\r'); + CHECK(form_feed == '\f'); + } + SECTION("General chars"){ + char space = ' '; + CHECK(space == ' '); + char chars[] = {'a', 'z', 'A', 'Z'}; + for (int i = 0; i < 4; ++i){ + char c = chars[i]; + REQUIRE(c == chars[i]); + } + } + SECTION("Low ASCII"){ + char null_terminator = '\0'; + CHECK(null_terminator == '\0'); + for (int i = 2; i < 6; ++i){ + char c = static_cast(i); + REQUIRE(c == i); + } + } +}