diff --git a/include/external/clara.hpp b/include/external/clara.hpp index 20c6da707d..c7348bf95b 100644 --- a/include/external/clara.hpp +++ b/include/external/clara.hpp @@ -111,6 +111,9 @@ class Column { m_suffix = false; auto width = m_column.m_width - indent(); m_end = m_pos; + if (line()[m_pos] == '\n') { + ++m_end; + } while (m_end < line().size() && line()[m_end] != '\n') ++m_end; diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 20ecb7bb0c..99eca94da3 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -14,6 +14,9 @@ Compilation.tests.cpp:: passed: std::memcmp(uarr, "123", sizeof(uar Compilation.tests.cpp:: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' Compilation.tests.cpp:: passed: Compilation.tests.cpp:: passed: h1 == h2 for: [1403 helper] == [1403 helper] +Message.tests.cpp:: warning: ' +This info message starts with a linebreak' with 1 message: ' +This warning message starts with a linebreak' This would not be caught previously Nor would this Tricky.tests.cpp:: failed: explicitly with 1 message: '1514' @@ -1502,5 +1505,5 @@ Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -Failed 77 test cases, failed 138 assertions. +Failed 78 test cases, failed 139 assertions. diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index d69a96c78a..3b6f20684c 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1,6 +1,4 @@ Filters: ~[!nonportable]~[!benchmark]~[approvals] -This would not be caught previously -Nor would this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is a host application. @@ -8,6 +6,18 @@ Run with -? for options Randomness seeded to: 1 +------------------------------------------------------------------------------- +#1455 - INFO and WARN can start with a linebreak +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: warning: + +This warning message starts with a linebreak + +This would not be caught previously +Nor would this ------------------------------------------------------------------------------- #1514: stderr/stdout is not captured in tests aborted by an exception ------------------------------------------------------------------------------- @@ -1265,6 +1275,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 257 | 191 passed | 62 failed | 4 failed as expected +test cases: 258 | 192 passed | 62 failed | 4 failed as expected assertions: 1419 | 1276 passed | 122 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index d7a1628292..c63de78ac3 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -134,6 +134,21 @@ Compilation.tests.cpp:: PASSED: with expansion: [1403 helper] == [1403 helper] +------------------------------------------------------------------------------- +#1455 - INFO and WARN can start with a linebreak +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: warning: + +This info message starts with a linebreak + +This warning message starts with a linebreak + + +No assertions in test case '#1455 - INFO and WARN can start with a linebreak' + This would not be caught previously Nor would this ------------------------------------------------------------------------------- @@ -11113,6 +11128,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 257 | 176 passed | 77 failed | 4 failed as expected -assertions: 1435 | 1276 passed | 138 failed | 21 failed as expected +test cases: 258 | 176 passed | 78 failed | 4 failed as expected +assertions: 1436 | 1276 passed | 139 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index d3da893464..bfa6675066 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -134,6 +134,21 @@ Compilation.tests.cpp:: PASSED: with expansion: [1403 helper] == [1403 helper] +------------------------------------------------------------------------------- +#1455 - INFO and WARN can start with a linebreak +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: warning: + +This info message starts with a linebreak + +This warning message starts with a linebreak + + +No assertions in test case '#1455 - INFO and WARN can start with a linebreak' + This would not be caught previously Nor would this ------------------------------------------------------------------------------- @@ -336,12 +351,7 @@ Condition.tests.cpp:: FAILED: Condition.tests.cpp:: FAILED: CHECK( true != true ) -Condition.tests.cpp:: FAILED: - CHECK( !true ) -with expansion: - false - =============================================================================== -test cases: 17 | 13 passed | 2 failed | 2 failed as expected +test cases: 18 | 13 passed | 3 failed | 2 failed as expected assertions: 40 | 33 passed | 4 failed | 3 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index e985133b10..ed0ecfc588 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -5,7 +5,7 @@ loose text artifact - + @@ -14,6 +14,7 @@ loose text artifact + 1514 diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 20fc7f7072..b526a5f7f6 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -142,6 +142,17 @@ + + + +This info message starts with a linebreak + + + +This warning message starts with a linebreak + + + 1514 @@ -13388,7 +13399,7 @@ loose text artifact - + - + diff --git a/projects/SelfTest/UsageTests/Message.tests.cpp b/projects/SelfTest/UsageTests/Message.tests.cpp index c955822f48..50992cebb9 100644 --- a/projects/SelfTest/UsageTests/Message.tests.cpp +++ b/projects/SelfTest/UsageTests/Message.tests.cpp @@ -14,6 +14,13 @@ TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) { WARN( "this is a " << "warning" ); // This should always output the message but then continue } +TEST_CASE( "#1455 - INFO and WARN can start with a linebreak", "[messages][.]" ) { + // Previously these would be hidden from the console reporter output, + // because it would fail at properly reflowing the text + INFO( "\nThis info message starts with a linebreak" ); + WARN( "\nThis warning message starts with a linebreak" ); +} + TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) { SUCCEED( "this is a " << "success" ); } diff --git a/third_party/clara.hpp b/third_party/clara.hpp index 6be5a98b14..9f4f1b2c31 100644 --- a/third_party/clara.hpp +++ b/third_party/clara.hpp @@ -110,6 +110,9 @@ namespace clara { namespace TextFlow { m_suffix = false; auto width = m_column.m_width-indent(); m_end = m_pos; + if (line()[m_pos] == '\n') { + ++m_end; + } while( m_end < line().size() && line()[m_end] != '\n' ) ++m_end;