Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class output_test_stream

boost::test_tools::output_test_stream — Class to be used to simplify testing of ostream-based output operations.

Synopsis

// In header: <boost/test/tools/output_test_stream.hpp>


class output_test_stream : public wrapped_stream {
public:
  // construct/copy/destruct
  explicit output_test_stream(const_string = const_string(), bool = true, 
                              bool = true);
  ~output_test_stream();

  // public member functions
  assertion_result is_empty(bool = true);
  assertion_result check_length(std::size_t, bool = true);
  assertion_result is_equal(const_string, bool = true);
  assertion_result match_pattern(bool = true);
  void flush();

  // private member functions
  std::size_t length();
  void sync();
};

Description

output_test_stream public construct/copy/destruct

  1. explicit output_test_stream(const_string pattern_file_name = const_string(), 
                                bool match_or_save = true, 
                                bool text_or_binary = true);
    Constructor.

    Parameters:

    match_or_save

    if true, the pattern file will be read, otherwise it will be written

    pattern_file_name

    indicates the name of the file for matching. If the string is empty, the standard input or output streams are used instead (depending on match_or_save)

    text_or_binary

    if false, opens the stream in binary mode. Otherwise the stream is opened with default flags and the carriage returns are ignored.

  2. ~output_test_stream();

output_test_stream public member functions

  1. assertion_result is_empty(bool flush_stream = true);
    Checks if the stream is empty.

    Parameters:

    flush_stream

    if true, flushes the stream after the call

  2. assertion_result check_length(std::size_t length, bool flush_stream = true);
    Checks the length of the stream.

    Parameters:

    flush_stream

    if true, flushes the stream after the call. Set to false to call additional checks on the same content.

    length

    target length

  3. assertion_result is_equal(const_string arg_, bool flush_stream = true);
    Checks the content of the stream against a string.

    Parameters:

    arg_

    the target stream

    flush_stream

    if true, flushes the stream after the call.

  4. assertion_result match_pattern(bool flush_stream = true);
    Checks the content of the stream against a pattern file.

    Parameters:

    flush_stream

    if true, flushes the stream after the call.

  5. void flush();
    Flushes the stream.

output_test_stream private member functions

  1. std::size_t length();
  2. void sync();

PrevUpHomeNext