Boost.Test > Components > The Test Tools > Output operations testing > boost::test_tools::ostream_test_stream

# boost::test_tools::ostream_test_stream

The class boost::test_tools::ostream_test_stream encapsulates procedures needed for effective and convenient operator<<( std::ostream&, ... ) correctness check.

## Synopsis

    class output_test_stream {
    pubic:
        explicit  output_test_stream( std::string const& pattern_file = std::string(),
                                      bool match_or_save = true );

        explicit  output_test_stream( char const* pattern_file = NULL,
                                      bool match_or_save = true );

                  ~output_test_stream();

        bool      is_empty( bool flush_stream = true );
        bool      check_length( std::size_t length, bool flush_stream = true );
        bool      is_equal( char const* arg, bool flush_stream = true );
        bool      is_equal( std::string const& arg, bool flush_stream = true );
        bool      is_equal( char const* arg, std::size_t n,
                            bool flush_stream = true );

        bool      match_pattern( bool flush_stream = true );

        void      flush();
    };

### Description

### explicit output_test_stream( std::string const& pattern_file, bool match_or_save )
explicit output_test_stream( char const* pattern_file, bool match_or_save )

The class output_test_stream constructors accept pattern file name and boolean switch match_or_save that are used by match_pattern facility. If they are not present you can still use other testing mechanisms.

### void flush()

Effects:

This method cleans the content of the output_test_stream instance.

### bool is_empty( bool flush_stream )

Effects:

This method checks that the content of the output_test_stream instance is empty. The flush_stream argument manage automatic call of the method output_test_stream::flush() after check is done.

Returns:

true if check successful, false otherwise.

### bool check_length( std::size_t length, bool flush_stream )

Effects:

This method checks that the length of the content of the output_test_stream instance is equal to supplied length value. The flush_stream argument manage automatic call of the method output_test_stream::flush() after check is done.

Returns:

true if check successful, false otherwise.

### bool is_equal( char const* arg, bool flush_stream )
bool is_equal( std::string const& arg, bool flush_stream )
bool is_equal( char const* arg, std::size_t n, bool flush_stream )

Effects:

The overloaded method output_test_stream::is_equal(...) checks that the content of the output_test_stream instance is equal to supplied character string. The first version compare with null-terminated string. The second compare with a reference to std::string object. And finally the third version compare with probably not null-terminated string defined by pointer to the string begin and the string length. The flush_stream argument manage automatic call of the method output_test_stream::flush() after check is done.

Returns:

true if check successful, false otherwise.

### bool match_pattern( bool flush_stream )

Effects:

This method matches the content of the output_test_stream instance versus the pattern file. The pattern file name is specified in the class output_test_stream constructor. If second argument of the class output_test_stream constructor is false, then every call of the method output_test_stream::match_pattern(...) will cause the output_test_stream instance content to be stored at the end of the pattern file. The flush_stream argument manage automatic call of the method output_test_stream::flush() after check is done.

Returns:

true if check successful, false otherwise.