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
  virtual assertion_result is_empty(bool = true);
  virtual assertion_result check_length(std::size_t, bool = true);
  virtual assertion_result is_equal(const_string, bool = true);
  virtual assertion_result match_pattern(bool = true);
  void flush();

  // protected member functions
  virtual std::string get_stream_string_representation() const;

  // private member functions
  std::size_t length();
  virtual 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. virtual 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. virtual 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. virtual 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. virtual assertion_result match_pattern(bool flush_stream = true);
    Checks the content of the stream against a pattern file.

    Parameters:

    flush_stream

    if true, flushes/resets the stream after the call.

  5. void flush();
    Flushes the stream.

output_test_stream protected member functions

  1. virtual std::string get_stream_string_representation() const;
    Returns the string representation of the stream.

    May be overriden in order to mutate the string before the matching operations.

output_test_stream private member functions

  1. std::size_t length();
    Length of the stream.
  2. virtual void sync();
    Synching the stream into an internal string representation.

PrevUpHomeNext