The class boost::test_tools::ostream_test_stream encapsulates procedures needed for effective and convenient operator<<( std::ostream&, ... ) correctness check.
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(); };
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.
Effects:
This method cleans the content of the output_test_stream instance.
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.
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.
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.
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.