|
||||
File indexing completed on 2025-01-18 09:52:41
0001 // (C) Copyright Gennadiy Rozental 2001. 0002 // Distributed under the Boost Software License, Version 1.0. 0003 // (See accompanying file LICENSE_1_0.txt or copy at 0004 // http://www.boost.org/LICENSE_1_0.txt) 0005 0006 // See http://www.boost.org/libs/test for the library home page. 0007 // 0008 /// @file 0009 /// @brief output_test_stream class definition 0010 // *************************************************************************** 0011 0012 #ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER 0013 #define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER 0014 0015 // Boost.Test 0016 #include <boost/test/detail/global_typedef.hpp> 0017 #include <boost/test/utils/wrap_stringstream.hpp> 0018 #include <boost/test/tools/assertion_result.hpp> 0019 0020 // STL 0021 #include <cstddef> // for std::size_t 0022 0023 #include <boost/test/detail/suppress_warnings.hpp> 0024 0025 //____________________________________________________________________________// 0026 0027 // ************************************************************************** // 0028 // ************** output_test_stream ************** // 0029 // ************************************************************************** // 0030 0031 0032 0033 namespace boost { 0034 namespace test_tools { 0035 0036 //! Class to be used to simplify testing of ostream-based output operations 0037 class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream { 0038 typedef unit_test::const_string const_string; 0039 public: 0040 //! Constructor 0041 //! 0042 //!@param[in] pattern_file_name indicates the name of the file for matching. If the 0043 //! string is empty, the standard input or output streams are used instead 0044 //! (depending on match_or_save) 0045 //!@param[in] match_or_save if true, the pattern file will be read, otherwise it will be 0046 //! written 0047 //!@param[in] text_or_binary if false, opens the stream in binary mode. Otherwise the stream 0048 //! is opened with default flags and the carriage returns are ignored. 0049 explicit output_test_stream( const_string pattern_file_name = const_string(), 0050 bool match_or_save = true, 0051 bool text_or_binary = true ); 0052 0053 // Destructor 0054 ~output_test_stream() BOOST_OVERRIDE; 0055 0056 //! Checks if the stream is empty 0057 //! 0058 //!@param[in] flush_stream if true, flushes the stream after the call 0059 virtual assertion_result is_empty( bool flush_stream = true ); 0060 0061 //! Checks the length of the stream 0062 //! 0063 //!@param[in] length target length 0064 //!@param[in] flush_stream if true, flushes the stream after the call. Set to false to call 0065 //! additional checks on the same content. 0066 virtual assertion_result check_length( std::size_t length, bool flush_stream = true ); 0067 0068 //! Checks the content of the stream against a string 0069 //! 0070 //!@param[in] arg_ the target stream 0071 //!@param[in] flush_stream if true, flushes the stream after the call. 0072 virtual assertion_result is_equal( const_string arg_, bool flush_stream = true ); 0073 0074 //! Checks the content of the stream against a pattern file 0075 //! 0076 //!@param[in] flush_stream if true, flushes/resets the stream after the call. 0077 virtual assertion_result match_pattern( bool flush_stream = true ); 0078 0079 //! Flushes the stream 0080 void flush(); 0081 0082 protected: 0083 0084 //! Returns the string representation of the stream 0085 //! 0086 //! May be overriden in order to mutate the string before the matching operations. 0087 virtual std::string get_stream_string_representation() const; 0088 0089 private: 0090 // helper functions 0091 0092 //! Length of the stream 0093 std::size_t length(); 0094 0095 //! Synching the stream into an internal string representation 0096 virtual void sync(); 0097 0098 struct Impl; 0099 Impl* m_pimpl; 0100 }; 0101 0102 } // namespace test_tools 0103 } // namespace boost 0104 0105 #include <boost/test/detail/enable_warnings.hpp> 0106 0107 #endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |