output_test_stream.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // (C) Copyright Gennadiy Rozental 2001-2008.
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 49312 $
  10. //
  11. // Description : output_test_stream class definition
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
  14. #define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
  15. // Boost.Test
  16. #include <boost/test/detail/global_typedef.hpp>
  17. #include <boost/test/utils/wrap_stringstream.hpp>
  18. #include <boost/test/predicate_result.hpp>
  19. // STL
  20. #include <cstddef> // for std::size_t
  21. #include <boost/test/detail/suppress_warnings.hpp>
  22. //____________________________________________________________________________//
  23. // ************************************************************************** //
  24. // ************** output_test_stream ************** //
  25. // ************************************************************************** //
  26. // class to be used to simplify testing of ostream-based output operations
  27. namespace boost {
  28. namespace test_tools {
  29. class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream {
  30. typedef unit_test::const_string const_string;
  31. typedef predicate_result result_type;
  32. public:
  33. // Constructor
  34. explicit output_test_stream( const_string pattern_file_name = const_string(),
  35. bool match_or_save = true,
  36. bool text_or_binary = true );
  37. // Destructor
  38. ~output_test_stream();
  39. // checking function
  40. result_type is_empty( bool flush_stream = true );
  41. result_type check_length( std::size_t length, bool flush_stream = true );
  42. result_type is_equal( const_string arg_, bool flush_stream = true );
  43. result_type match_pattern( bool flush_stream = true );
  44. // explicit flush
  45. void flush();
  46. private:
  47. // helper functions
  48. std::size_t length();
  49. void sync();
  50. struct Impl;
  51. Impl* m_pimpl;
  52. };
  53. } // namespace test_tools
  54. } // namespace boost
  55. //____________________________________________________________________________//
  56. #include <boost/test/detail/enable_warnings.hpp>
  57. #endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER