[/
- / Copyright (c) 2003 Boost.Test contributors
+ / Copyright (c) 2003 Boost.Test contributors
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
[section:output_stream_testing Output streams testing tool]
-How would you perform correctness test for ``operator<< ( std::ostream &, ... )`` operations?
+How would you perform correctness test for ``operator<< ( std::ostream &, ... )`` operations?
You can print into the standard output stream and manually check that it is matching your expectations.
Unfortunately, this is not really acceptable for the regression testing and doesn't serve a long term purpose of a
-unit test.
+unit test.
You can use `std::stringstream` and compare resulting output buffer with the
expected pattern string, but you are required to perform several additional operations with every check you do. So it
-becomes tedious very fast.
+becomes tedious very fast.
-The class [classref boost::test_tools::output_test_stream] is designed to automate these tasks for you. This is a simple,
+The class [classref boost::test_tools::output_test_stream] is designed to automate these tasks for you. This is a simple,
but powerful tool for testing standard `std::ostream` based output operation. The class `output_test_stream`
complies to `std::ostream` interface so it can be used in place of any
`std::ostream` parameter. It provides several test methods to validate output content,
-including test for match to expected output content or test for expected output length. Flushing, synchronizing,
+including test for match to expected output content or test for expected output length. Flushing, synchronizing,
string comparison and error message generation is automated by the tool implementation.
All `output_test_stream` validation member functions by default flush the stream once the check is performed.
If you want to perform several checks with the same output, specify parameter `flush_stream`
-with value `false` [footnote This parameter is supported on all comparison methods, see the class
-[classref boost::test_tools::output_test_stream documentation.] ].
+with value `false` [footnote This parameter is supported on all comparison methods, see the class
+[classref boost::test_tools::output_test_stream documentation.] ].
In some cases manual generation of expected output is either too time consuming or is impossible at all because
of sheer volume. A possible way to address that issue is to split the test in two steps:
may be used to either generate a new pattern file, or to check against an existing pattern.
[h3:usages Usage]
-There are two ways to employ the class `output_test_stream`:
+There are two ways to employ the class `output_test_stream`:
# explicit output checks and
# pattern file matching
identify possible source of failure.]
[h4 Pattern file matching]
-The ['pattern file] is a companion file containing the patterns that the stream should match. Your testing will look
+The ['pattern file] is a companion file containing the patterns that the stream should match. Your testing will look
like a series of output operators followed by match pattern checks repeated several times.
-In the example below, the file `pattern_file` contains the patterns that should match.
+In the example below, the file `pattern_file` contains the patterns that should match.
[pre
i=2
File: test.cpp Line:XXX