Stream.tests.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright Catch2 Authors
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // https://www.boost.org/LICENSE_1_0.txt)
  5. // SPDX-License-Identifier: BSL-1.0
  6. #include <catch2/catch_test_macros.hpp>
  7. #include <catch2/internal/catch_istream.hpp>
  8. TEST_CASE( "Cout stream properly declares it writes to stdout", "[streams]" ) {
  9. REQUIRE( Catch::makeStream( "-" )->isConsole() );
  10. }
  11. TEST_CASE( "Empty stream name opens cout stream", "[streams]" ) {
  12. REQUIRE( Catch::makeStream( "" )->isConsole() );
  13. }
  14. TEST_CASE( "stdout and stderr streams have %-starting name", "[streams]" ) {
  15. REQUIRE( Catch::makeStream( "%stderr" )->isConsole() );
  16. REQUIRE( Catch::makeStream( "%stdout" )->isConsole() );
  17. }
  18. TEST_CASE( "request an unknown %-starting stream fails", "[streams]" ) {
  19. REQUIRE_THROWS( Catch::makeStream( "%somestream" ) );
  20. }
  21. TEST_CASE( "makeStream recognizes %debug stream name", "[streams]" ) {
  22. REQUIRE_NOTHROW( Catch::makeStream( "%debug" ) );
  23. }