From ea48ae0f753121476b525584744c236dc22d73db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 27 May 2017 14:42:05 +0200 Subject: [PATCH] Add test for #914 (stringify truthy exprs in standard way) --- CMakeLists.txt | 1 + .../Baselines/console.std.approved.txt | 15 ++++++++-- .../Baselines/console.sw.approved.txt | 21 ++++++++++---- .../SelfTest/Baselines/junit.sw.approved.txt | 7 ++++- .../SelfTest/Baselines/xml.sw.approved.txt | 21 ++++++++++---- projects/SelfTest/DecompositionTests.cpp | 28 +++++++++++++++++++ 6 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 projects/SelfTest/DecompositionTests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bd7dd1f..6e608fa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/CmdLineTests.cpp ${SELF_TEST_DIR}/CompilationTests.cpp ${SELF_TEST_DIR}/ConditionTests.cpp + ${SELF_TEST_DIR}/DecompositionTests.cpp ${SELF_TEST_DIR}/EnumToString.cpp ${SELF_TEST_DIR}/ExceptionTests.cpp ${SELF_TEST_DIR}/GeneratorTests.cpp diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 0ad362e9..19e545ba 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -595,6 +595,17 @@ MessageTests.cpp:: warning: toString(p): 0x +------------------------------------------------------------------------------- +Reconstruction should be based on stringification: #914 +------------------------------------------------------------------------------- +DecompositionTests.cpp: +............................................................................... + +DecompositionTests.cpp:: FAILED: + CHECK( truthy(false) ) +with expansion: + Hey, its truthy! + ------------------------------------------------------------------------------- SCOPED_INFO is reset for each loop ------------------------------------------------------------------------------- @@ -942,6 +953,6 @@ with expansion: "first" == "second" =============================================================================== -test cases: 167 | 119 passed | 44 failed | 4 failed as expected -assertions: 967 | 859 passed | 87 failed | 21 failed as expected +test cases: 168 | 119 passed | 45 failed | 4 failed as expected +assertions: 968 | 859 passed | 88 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index c1d8865a..cdc414a4 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -819,7 +819,7 @@ TrickyTests.cpp:: PASSED: REQUIRE( a ) with expansion: - true + 0x TrickyTests.cpp:: PASSED: @@ -4571,7 +4571,7 @@ TrickyTests.cpp:: PASSED: CHECK( True ) with expansion: - true + 1 TrickyTests.cpp:: PASSED: @@ -4583,7 +4583,7 @@ TrickyTests.cpp:: PASSED: CHECK_FALSE( False ) with expansion: - !false + !0 ------------------------------------------------------------------------------- Operators at different namespace levels not hijacked by Koenig lookup @@ -6437,6 +6437,17 @@ TestMain.cpp:: PASSED: REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) ) +------------------------------------------------------------------------------- +Reconstruction should be based on stringification: #914 +------------------------------------------------------------------------------- +DecompositionTests.cpp: +............................................................................... + +DecompositionTests.cpp:: FAILED: + CHECK( truthy(false) ) +with expansion: + Hey, its truthy! + ------------------------------------------------------------------------------- SCOPED_INFO is reset for each loop ------------------------------------------------------------------------------- @@ -9472,6 +9483,6 @@ MiscTests.cpp:: PASSED: =============================================================================== -test cases: 167 | 118 passed | 45 failed | 4 failed as expected -assertions: 969 | 859 passed | 89 failed | 21 failed as expected +test cases: 168 | 118 passed | 46 failed | 4 failed as expected +assertions: 970 | 859 passed | 90 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 6237fb63..b723f207 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,6 +1,6 @@ - + @@ -443,6 +443,11 @@ MessageTests.cpp: + + +DecompositionTests.cpp: + + current counter 10 diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 83d9a421..6361fee3 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -890,7 +890,7 @@ a - true + 0x @@ -4695,7 +4695,7 @@ re>" True - true + 1 @@ -4711,7 +4711,7 @@ re>" !False - !false + !0 @@ -6912,6 +6912,17 @@ re>" + + + + truthy(false) + + + Hey, its truthy! + + + + current counter 0 @@ -10132,7 +10143,7 @@ spanner - + - + diff --git a/projects/SelfTest/DecompositionTests.cpp b/projects/SelfTest/DecompositionTests.cpp new file mode 100644 index 00000000..f2e04260 --- /dev/null +++ b/projects/SelfTest/DecompositionTests.cpp @@ -0,0 +1,28 @@ +/* + * Created by Martin on 27/5/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * 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 + +struct truthy { + truthy(bool b):m_value(b){} + operator bool() const { + return false; + } + bool m_value; +}; + +std::ostream& operator<<(std::ostream& o, truthy) { + o << "Hey, its truthy!"; + return o; +} + +#include "catch.hpp" + +TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") { + CHECK(truthy(false)); +}