]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/include/boost/test/tools/output_test_stream.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / tools / output_test_stream.hpp
CommitLineData
7c673cae
FG
1// (C) Copyright Gennadiy Rozental 2001.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8/// @file
9/// @brief output_test_stream class definition
10// ***************************************************************************
11
12#ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
13#define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
14
15// Boost.Test
16#include <boost/test/detail/global_typedef.hpp>
17#include <boost/test/utils/wrap_stringstream.hpp>
18#include <boost/test/tools/assertion_result.hpp>
19
20// STL
21#include <cstddef> // for std::size_t
22
23#include <boost/test/detail/suppress_warnings.hpp>
24
25//____________________________________________________________________________//
26
27// ************************************************************************** //
28// ************** output_test_stream ************** //
29// ************************************************************************** //
30
31
32
33namespace boost {
34namespace test_tools {
35
36//! Class to be used to simplify testing of ostream-based output operations
37class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream {
38 typedef unit_test::const_string const_string;
39public:
40 //! Constructor
41 //!
42 //!@param[in] pattern_file_name indicates the name of the file for matching. If the
43 //! string is empty, the standard input or output streams are used instead
44 //! (depending on match_or_save)
45 //!@param[in] match_or_save if true, the pattern file will be read, otherwise it will be
46 //! written
47 //!@param[in] text_or_binary if false, opens the stream in binary mode. Otherwise the stream
48 //! is opened with default flags and the carriage returns are ignored.
49 explicit output_test_stream( const_string pattern_file_name = const_string(),
50 bool match_or_save = true,
51 bool text_or_binary = true );
52
53 // Destructor
54 virtual ~output_test_stream();
55
56 //! Checks if the stream is empty
57 //!
58 //!@param[in] flush_stream if true, flushes the stream after the call
59 virtual assertion_result is_empty( bool flush_stream = true );
60
61 //! Checks the length of the stream
62 //!
63 //!@param[in] length target length
64 //!@param[in] flush_stream if true, flushes the stream after the call. Set to false to call
65 //! additional checks on the same content.
66 virtual assertion_result check_length( std::size_t length, bool flush_stream = true );
67
68 //! Checks the content of the stream against a string
69 //!
70 //!@param[in] arg_ the target stream
71 //!@param[in] flush_stream if true, flushes the stream after the call.
72 virtual assertion_result is_equal( const_string arg_, bool flush_stream = true );
73
74 //! Checks the content of the stream against a pattern file
75 //!
76 //!@param[in] flush_stream if true, flushes/resets the stream after the call.
77 virtual assertion_result match_pattern( bool flush_stream = true );
78
79 //! Flushes the stream
80 void flush();
81
82protected:
83
84 //! Returns the string representation of the stream
85 //!
86 //! May be overriden in order to mutate the string before the matching operations.
87 virtual std::string get_stream_string_representation() const;
88
89private:
90 // helper functions
91
92 //! Length of the stream
93 std::size_t length();
94
95 //! Synching the stream into an internal string representation
96 virtual void sync();
97
98 struct Impl;
99 Impl* m_pimpl;
100};
101
102} // namespace test_tools
103} // namespace boost
104
105#include <boost/test/detail/enable_warnings.hpp>
106
107#endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER