Add IStream::isStdOut

This commit is contained in:
Martin Hořeňovský 2022-02-21 23:48:15 +01:00
parent 1d4b42ad7b
commit 715cd25081
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
21 changed files with 162 additions and 14 deletions

View File

@ -99,6 +99,7 @@ namespace Detail {
public: // IStream public: // IStream
std::ostream& stream() const override { return m_os; } std::ostream& stream() const override { return m_os; }
bool isStdout() const override { return true; }
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -25,6 +25,9 @@ namespace Catch {
struct IStream { struct IStream {
virtual ~IStream(); // = default virtual ~IStream(); // = default
virtual std::ostream& stream() const = 0; virtual std::ostream& stream() const = 0;
// Win32 colour supports requires us to identify whether a stream
// is backed by stdout (so we can colour it) or not (and we can't).
virtual bool isStdout() const { return false; }
}; };
auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream const>; auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream const>;

View File

@ -90,6 +90,7 @@ set(TEST_SOURCES
${SELF_TEST_DIR}/IntrospectiveTests/TestSpecParser.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/TestSpecParser.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/TextFlow.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/TextFlow.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Sharding.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Sharding.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Stream.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp

View File

@ -122,11 +122,13 @@ Nor would this
:test-result: PASS Composed matchers shortcircuit :test-result: PASS Composed matchers shortcircuit
:test-result: FAIL Contains string matcher :test-result: FAIL Contains string matcher
:test-result: PASS Copy and then generate a range :test-result: PASS Copy and then generate a range
:test-result: PASS Cout stream properly declares it writes to stdout
:test-result: FAIL Custom exceptions can be translated when testing for nothrow :test-result: FAIL Custom exceptions can be translated when testing for nothrow
:test-result: FAIL Custom exceptions can be translated when testing for throwing as something else :test-result: FAIL Custom exceptions can be translated when testing for throwing as something else
:test-result: FAIL Custom std-exceptions can be custom translated :test-result: FAIL Custom std-exceptions can be custom translated
:test-result: PASS Default scale is invisible to comparison :test-result: PASS Default scale is invisible to comparison
:test-result: PASS Directly creating an EnumInfo :test-result: PASS Directly creating an EnumInfo
:test-result: PASS Empty stream name opens cout stream
:test-result: PASS Empty tag is not allowed :test-result: PASS Empty tag is not allowed
:test-result: FAIL EndsWith string matcher :test-result: FAIL EndsWith string matcher
:test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM :test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM

View File

@ -120,11 +120,13 @@
:test-result: PASS Composed matchers shortcircuit :test-result: PASS Composed matchers shortcircuit
:test-result: FAIL Contains string matcher :test-result: FAIL Contains string matcher
:test-result: PASS Copy and then generate a range :test-result: PASS Copy and then generate a range
:test-result: PASS Cout stream properly declares it writes to stdout
:test-result: FAIL Custom exceptions can be translated when testing for nothrow :test-result: FAIL Custom exceptions can be translated when testing for nothrow
:test-result: FAIL Custom exceptions can be translated when testing for throwing as something else :test-result: FAIL Custom exceptions can be translated when testing for throwing as something else
:test-result: FAIL Custom std-exceptions can be custom translated :test-result: FAIL Custom std-exceptions can be custom translated
:test-result: PASS Default scale is invisible to comparison :test-result: PASS Default scale is invisible to comparison
:test-result: PASS Directly creating an EnumInfo :test-result: PASS Directly creating an EnumInfo
:test-result: PASS Empty stream name opens cout stream
:test-result: PASS Empty tag is not allowed :test-result: PASS Empty tag is not allowed
:test-result: FAIL EndsWith string matcher :test-result: FAIL EndsWith string matcher
:test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM :test-result: PASS Enums can quickly have stringification enabled using REGISTER_ENUM

View File

@ -479,6 +479,7 @@ Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1 Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: call_count == 1 for: 1 == 1 Generators.tests.cpp:<line number>: passed: call_count == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: make_data().size() == test_count for: 6 == 6 Generators.tests.cpp:<line number>: passed: make_data().size() == test_count for: 6 == 6
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "-" )->isStdout() for: true
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom()
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom std exception' Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom std exception'
@ -489,6 +490,7 @@ ToString.tests.cpp:<line number>: passed: enumInfo->lookup(1) == "Value2" for: V
ToString.tests.cpp:<line number>: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} ToString.tests.cpp:<line number>: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **}
== ==
"{** unexpected enum value **}" "{** unexpected enum value **}"
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "" )->isStdout() for: true
Tag.tests.cpp:<line number>: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) Tag.tests.cpp:<line number>: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo )
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring"
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive) Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive)

View File

@ -477,6 +477,7 @@ Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1 Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: call_count == 1 for: 1 == 1 Generators.tests.cpp:<line number>: passed: call_count == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: make_data().size() == test_count for: 6 == 6 Generators.tests.cpp:<line number>: passed: make_data().size() == test_count for: 6 == 6
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "-" )->isStdout() for: true
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom()
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom std exception' Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom std exception'
@ -487,6 +488,7 @@ ToString.tests.cpp:<line number>: passed: enumInfo->lookup(1) == "Value2" for: V
ToString.tests.cpp:<line number>: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} ToString.tests.cpp:<line number>: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **}
== ==
"{** unexpected enum value **}" "{** unexpected enum value **}"
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "" )->isStdout() for: true
Tag.tests.cpp:<line number>: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) Tag.tests.cpp:<line number>: passed: Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo )
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring" Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring"
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive) Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive)

View File

@ -1395,6 +1395,6 @@ due to unexpected exception with message:
Why would you throw a std::string? Why would you throw a std::string?
=============================================================================== ===============================================================================
test cases: 381 | 305 passed | 69 failed | 7 failed as expected test cases: 383 | 307 passed | 69 failed | 7 failed as expected
assertions: 2211 | 2056 passed | 128 failed | 27 failed as expected assertions: 2213 | 2058 passed | 128 failed | 27 failed as expected

View File

@ -3805,6 +3805,17 @@ Generators.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
6 == 6 6 == 6
-------------------------------------------------------------------------------
Cout stream properly declares it writes to stdout
-------------------------------------------------------------------------------
Stream.tests.cpp:<line number>
...............................................................................
Stream.tests.cpp:<line number>: PASSED:
REQUIRE( Catch::makeStream( "-" )->isStdout() )
with expansion:
true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Custom exceptions can be translated when testing for nothrow Custom exceptions can be translated when testing for nothrow
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -3876,6 +3887,17 @@ with expansion:
== ==
"{** unexpected enum value **}" "{** unexpected enum value **}"
-------------------------------------------------------------------------------
Empty stream name opens cout stream
-------------------------------------------------------------------------------
Stream.tests.cpp:<line number>
...............................................................................
Stream.tests.cpp:<line number>: PASSED:
REQUIRE( Catch::makeStream( "" )->isStdout() )
with expansion:
true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Empty tag is not allowed Empty tag is not allowed
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -17764,6 +17786,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 381 | 291 passed | 83 failed | 7 failed as expected test cases: 383 | 293 passed | 83 failed | 7 failed as expected
assertions: 2226 | 2056 passed | 143 failed | 27 failed as expected assertions: 2228 | 2058 passed | 143 failed | 27 failed as expected

View File

@ -3803,6 +3803,17 @@ Generators.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
6 == 6 6 == 6
-------------------------------------------------------------------------------
Cout stream properly declares it writes to stdout
-------------------------------------------------------------------------------
Stream.tests.cpp:<line number>
...............................................................................
Stream.tests.cpp:<line number>: PASSED:
REQUIRE( Catch::makeStream( "-" )->isStdout() )
with expansion:
true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Custom exceptions can be translated when testing for nothrow Custom exceptions can be translated when testing for nothrow
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -3874,6 +3885,17 @@ with expansion:
== ==
"{** unexpected enum value **}" "{** unexpected enum value **}"
-------------------------------------------------------------------------------
Empty stream name opens cout stream
-------------------------------------------------------------------------------
Stream.tests.cpp:<line number>
...............................................................................
Stream.tests.cpp:<line number>: PASSED:
REQUIRE( Catch::makeStream( "" )->isStdout() )
with expansion:
true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Empty tag is not allowed Empty tag is not allowed
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -17756,6 +17778,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 381 | 291 passed | 83 failed | 7 failed as expected test cases: 383 | 293 passed | 83 failed | 7 failed as expected
assertions: 2226 | 2056 passed | 143 failed | 27 failed as expected assertions: 2228 | 2058 passed | 143 failed | 27 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="17" failures="126" tests="2226" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="126" tests="2228" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
@ -425,6 +425,7 @@ Matchers.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/from var and iterators" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/from var and iterators" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/From a temporary container" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/From a temporary container" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/Final validation" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/Final validation" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Cout stream properly declares it writes to stdout" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}" status="run">
<error message="throwCustom()" type="REQUIRE_NOTHROW"> <error message="throwCustom()" type="REQUIRE_NOTHROW">
FAILED: FAILED:
@ -450,6 +451,7 @@ Exception.tests.cpp:<line number>
</testcase> </testcase>
<testcase classname="<exe-name>.global" name="Default scale is invisible to comparison" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Default scale is invisible to comparison" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Directly creating an EnumInfo" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Directly creating an EnumInfo" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Empty stream name opens cout stream" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Empty tag is not allowed" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Empty tag is not allowed" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="EndsWith string matcher" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="EndsWith string matcher" time="{duration}" status="run">
<failure message="testStringForMatching(), EndsWith( &quot;Substring&quot; )" type="CHECK_THAT"> <failure message="testStringForMatching(), EndsWith( &quot;Substring&quot; )" type="CHECK_THAT">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuites> <testsuites>
<testsuite name="<exe-name>" errors="17" failures="126" tests="2226" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="126" tests="2228" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
@ -424,6 +424,7 @@ Matchers.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/from var and iterators" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/from var and iterators" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/From a temporary container" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/From a temporary container" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/Final validation" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Copy and then generate a range/Final validation" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Cout stream properly declares it writes to stdout" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}" status="run">
<error message="throwCustom()" type="REQUIRE_NOTHROW"> <error message="throwCustom()" type="REQUIRE_NOTHROW">
FAILED: FAILED:
@ -449,6 +450,7 @@ Exception.tests.cpp:<line number>
</testcase> </testcase>
<testcase classname="<exe-name>.global" name="Default scale is invisible to comparison" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Default scale is invisible to comparison" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Directly creating an EnumInfo" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Directly creating an EnumInfo" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Empty stream name opens cout stream" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Empty tag is not allowed" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Empty tag is not allowed" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="EndsWith string matcher" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="EndsWith string matcher" time="{duration}" status="run">
<failure message="testStringForMatching(), EndsWith( &quot;Substring&quot; )" type="CHECK_THAT"> <failure message="testStringForMatching(), EndsWith( &quot;Substring&quot; )" type="CHECK_THAT">

View File

@ -216,6 +216,10 @@
<testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/> <testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/> <testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/>
</file> </file>
<file path="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp">
<testCase name="Cout stream properly declares it writes to stdout" duration="{duration}"/>
<testCase name="Empty stream name opens cout stream" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/IntrospectiveTests/String.tests.cpp"> <file path="tests/<exe-name>/IntrospectiveTests/String.tests.cpp">
<testCase name="StringRef/Empty string" duration="{duration}"/> <testCase name="StringRef/Empty string" duration="{duration}"/>
<testCase name="StringRef/From string literal" duration="{duration}"/> <testCase name="StringRef/From string literal" duration="{duration}"/>

View File

@ -215,6 +215,10 @@
<testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/> <testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/> <testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/>
</file> </file>
<file path="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp">
<testCase name="Cout stream properly declares it writes to stdout" duration="{duration}"/>
<testCase name="Empty stream name opens cout stream" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/IntrospectiveTests/String.tests.cpp"> <file path="tests/<exe-name>/IntrospectiveTests/String.tests.cpp">
<testCase name="StringRef/Empty string" duration="{duration}"/> <testCase name="StringRef/Empty string" duration="{duration}"/>
<testCase name="StringRef/From string literal" duration="{duration}"/> <testCase name="StringRef/From string literal" duration="{duration}"/>

View File

@ -956,6 +956,8 @@ ok {test-number} - elem % 2 == 1 for: 1 == 1
ok {test-number} - call_count == 1 for: 1 == 1 ok {test-number} - call_count == 1 for: 1 == 1
# Copy and then generate a range # Copy and then generate a range
ok {test-number} - make_data().size() == test_count for: 6 == 6 ok {test-number} - make_data().size() == test_count for: 6 == 6
# Cout stream properly declares it writes to stdout
ok {test-number} - Catch::makeStream( "-" )->isStdout() for: true
# Custom exceptions can be translated when testing for nothrow # Custom exceptions can be translated when testing for nothrow
not ok {test-number} - unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() not ok {test-number} - unexpected exception with message: 'custom exception - not std'; expression was: throwCustom()
# Custom exceptions can be translated when testing for throwing as something else # Custom exceptions can be translated when testing for throwing as something else
@ -972,6 +974,8 @@ ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1"
ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2"
# Directly creating an EnumInfo # Directly creating an EnumInfo
ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}"
# Empty stream name opens cout stream
ok {test-number} - Catch::makeStream( "" )->isStdout() for: true
# Empty tag is not allowed # Empty tag is not allowed
ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo )
# EndsWith string matcher # EndsWith string matcher
@ -4454,5 +4458,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} - ok {test-number} -
# xmlentitycheck # xmlentitycheck
ok {test-number} - ok {test-number} -
1..2226 1..2228

View File

@ -954,6 +954,8 @@ ok {test-number} - elem % 2 == 1 for: 1 == 1
ok {test-number} - call_count == 1 for: 1 == 1 ok {test-number} - call_count == 1 for: 1 == 1
# Copy and then generate a range # Copy and then generate a range
ok {test-number} - make_data().size() == test_count for: 6 == 6 ok {test-number} - make_data().size() == test_count for: 6 == 6
# Cout stream properly declares it writes to stdout
ok {test-number} - Catch::makeStream( "-" )->isStdout() for: true
# Custom exceptions can be translated when testing for nothrow # Custom exceptions can be translated when testing for nothrow
not ok {test-number} - unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() not ok {test-number} - unexpected exception with message: 'custom exception - not std'; expression was: throwCustom()
# Custom exceptions can be translated when testing for throwing as something else # Custom exceptions can be translated when testing for throwing as something else
@ -970,6 +972,8 @@ ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1"
ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2"
# Directly creating an EnumInfo # Directly creating an EnumInfo
ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}"
# Empty stream name opens cout stream
ok {test-number} - Catch::makeStream( "" )->isStdout() for: true
# Empty tag is not allowed # Empty tag is not allowed
ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo ) ok {test-number} - Catch::TestCaseInfo( "", { "fake test name", "[]" }, dummySourceLineInfo )
# EndsWith string matcher # EndsWith string matcher
@ -4446,5 +4450,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} - ok {test-number} -
# xmlentitycheck # xmlentitycheck
ok {test-number} - ok {test-number} -
1..2226 1..2228

View File

@ -279,6 +279,8 @@ Matchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringFor
##teamcity[testFinished name='Contains string matcher' duration="{duration}"] ##teamcity[testFinished name='Contains string matcher' duration="{duration}"]
##teamcity[testStarted name='Copy and then generate a range'] ##teamcity[testStarted name='Copy and then generate a range']
##teamcity[testFinished name='Copy and then generate a range' duration="{duration}"] ##teamcity[testFinished name='Copy and then generate a range' duration="{duration}"]
##teamcity[testStarted name='Cout stream properly declares it writes to stdout']
##teamcity[testFinished name='Cout stream properly declares it writes to stdout' duration="{duration}"]
##teamcity[testStarted name='Custom exceptions can be translated when testing for nothrow'] ##teamcity[testStarted name='Custom exceptions can be translated when testing for nothrow']
Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom exception - not std"|n REQUIRE_NOTHROW( throwCustom() )|nwith expansion:|n throwCustom()|n'] Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom exception - not std"|n REQUIRE_NOTHROW( throwCustom() )|nwith expansion:|n throwCustom()|n']
##teamcity[testFinished name='Custom exceptions can be translated when testing for nothrow' duration="{duration}"] ##teamcity[testFinished name='Custom exceptions can be translated when testing for nothrow' duration="{duration}"]
@ -292,6 +294,8 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom
##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"] ##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"]
##teamcity[testStarted name='Directly creating an EnumInfo'] ##teamcity[testStarted name='Directly creating an EnumInfo']
##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"] ##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"]
##teamcity[testStarted name='Empty stream name opens cout stream']
##teamcity[testFinished name='Empty stream name opens cout stream' duration="{duration}"]
##teamcity[testStarted name='Empty tag is not allowed'] ##teamcity[testStarted name='Empty tag is not allowed']
##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"] ##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"]
##teamcity[testStarted name='EndsWith string matcher'] ##teamcity[testStarted name='EndsWith string matcher']

View File

@ -279,6 +279,8 @@ Matchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringFor
##teamcity[testFinished name='Contains string matcher' duration="{duration}"] ##teamcity[testFinished name='Contains string matcher' duration="{duration}"]
##teamcity[testStarted name='Copy and then generate a range'] ##teamcity[testStarted name='Copy and then generate a range']
##teamcity[testFinished name='Copy and then generate a range' duration="{duration}"] ##teamcity[testFinished name='Copy and then generate a range' duration="{duration}"]
##teamcity[testStarted name='Cout stream properly declares it writes to stdout']
##teamcity[testFinished name='Cout stream properly declares it writes to stdout' duration="{duration}"]
##teamcity[testStarted name='Custom exceptions can be translated when testing for nothrow'] ##teamcity[testStarted name='Custom exceptions can be translated when testing for nothrow']
Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom exception - not std"|n REQUIRE_NOTHROW( throwCustom() )|nwith expansion:|n throwCustom()|n'] Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom exception - not std"|n REQUIRE_NOTHROW( throwCustom() )|nwith expansion:|n throwCustom()|n']
##teamcity[testFinished name='Custom exceptions can be translated when testing for nothrow' duration="{duration}"] ##teamcity[testFinished name='Custom exceptions can be translated when testing for nothrow' duration="{duration}"]
@ -292,6 +294,8 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "custom
##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"] ##teamcity[testFinished name='Default scale is invisible to comparison' duration="{duration}"]
##teamcity[testStarted name='Directly creating an EnumInfo'] ##teamcity[testStarted name='Directly creating an EnumInfo']
##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"] ##teamcity[testFinished name='Directly creating an EnumInfo' duration="{duration}"]
##teamcity[testStarted name='Empty stream name opens cout stream']
##teamcity[testFinished name='Empty stream name opens cout stream' duration="{duration}"]
##teamcity[testStarted name='Empty tag is not allowed'] ##teamcity[testStarted name='Empty tag is not allowed']
##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"] ##teamcity[testFinished name='Empty tag is not allowed' duration="{duration}"]
##teamcity[testStarted name='EndsWith string matcher'] ##teamcity[testStarted name='EndsWith string matcher']

View File

@ -4205,6 +4205,17 @@ Nor would this
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Cout stream properly declares it writes to stdout" tags="[streams]" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Original>
Catch::makeStream( "-" )->isStdout()
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Custom exceptions can be translated when testing for nothrow" tags="[!throws][.][failing]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" > <TestCase name="Custom exceptions can be translated when testing for nothrow" tags="[!throws][.][failing]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Expression success="false" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" > <Expression success="false" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Original> <Original>
@ -4287,6 +4298,17 @@ Nor would this
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Empty stream name opens cout stream" tags="[streams]" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Original>
Catch::makeStream( "" )->isStdout()
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Empty tag is not allowed" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" > <TestCase name="Empty tag is not allowed" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Expression success="true" type="REQUIRE_THROWS" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" > <Expression success="true" type="REQUIRE_THROWS" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Original> <Original>
@ -20879,6 +20901,6 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="2056" failures="143" expectedFailures="27"/> <OverallResults successes="2058" failures="143" expectedFailures="27"/>
<OverallResultsCases successes="291" failures="83" expectedFailures="7"/> <OverallResultsCases successes="293" failures="83" expectedFailures="7"/>
</Catch2TestRun> </Catch2TestRun>

View File

@ -4205,6 +4205,17 @@ Nor would this
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Cout stream properly declares it writes to stdout" tags="[streams]" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Original>
Catch::makeStream( "-" )->isStdout()
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Custom exceptions can be translated when testing for nothrow" tags="[!throws][.][failing]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" > <TestCase name="Custom exceptions can be translated when testing for nothrow" tags="[!throws][.][failing]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Expression success="false" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" > <Expression success="false" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Original> <Original>
@ -4287,6 +4298,17 @@ Nor would this
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Empty stream name opens cout stream" tags="[streams]" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp" >
<Original>
Catch::makeStream( "" )->isStdout()
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Empty tag is not allowed" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" > <TestCase name="Empty tag is not allowed" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Expression success="true" type="REQUIRE_THROWS" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" > <Expression success="true" type="REQUIRE_THROWS" filename="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp" >
<Original> <Original>
@ -20878,6 +20900,6 @@ There is no extra whitespace here
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="2056" failures="143" expectedFailures="27"/> <OverallResults successes="2058" failures="143" expectedFailures="27"/>
<OverallResultsCases successes="291" failures="83" expectedFailures="7"/> <OverallResultsCases successes="293" failures="83" expectedFailures="7"/>
</Catch2TestRun> </Catch2TestRun>

View File

@ -0,0 +1,19 @@
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_stream.hpp>
TEST_CASE( "Cout stream properly declares it writes to stdout", "[streams]" ) {
REQUIRE( Catch::makeStream( "-" )->isStdout() );
}
TEST_CASE( "Empty stream name opens cout stream", "[streams]" ) {
REQUIRE( Catch::makeStream( "" )->isStdout() );
}