output_test_stream.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Class output_test_stream</title>
  5. <link rel="stylesheet" href="../../boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../../index.html" title="Boost.Test">
  8. <link rel="up" href="../../header/boost/test/tools/output_test_stream_hpp.html" title="Header &lt;boost/test/tools/output_test_stream.hpp&gt;">
  9. <link rel="prev" href="../../header/boost/test/tools/output_test_stream_hpp.html" title="Header &lt;boost/test/tools/output_test_stream.hpp&gt;">
  10. <link rel="next" href="../../header/boost/test/tree/observer_hpp.html" title="Header &lt;boost/test/tree/observer.hpp&gt;">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="../../header/boost/test/tools/output_test_stream_hpp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tools/output_test_stream_hpp.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../header/boost/test/tree/observer_hpp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="refentry">
  26. <a name="boost.test_tools.output_test_stream"></a><div class="titlepage"></div>
  27. <div class="refnamediv">
  28. <h2><span class="refentrytitle">Class output_test_stream</span></h2>
  29. <p>boost::test_tools::output_test_stream &#8212; Class to be used to simplify testing of ostream-based output operations. </p>
  30. </div>
  31. <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
  32. <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../header/boost/test/tools/output_test_stream_hpp.html" title="Header &lt;boost/test/tools/output_test_stream.hpp&gt;">boost/test/tools/output_test_stream.hpp</a>&gt;
  33. </span>
  34. <span class="keyword">class</span> <a class="link" href="output_test_stream.html" title="Class output_test_stream">output_test_stream</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">wrapped_stream</span> <span class="special">{</span>
  35. <span class="keyword">public</span><span class="special">:</span>
  36. <span class="comment">// <a class="link" href="output_test_stream.html#boost.test_tools.output_test_streamconstruct-copy-destruct">construct/copy/destruct</a></span>
  37. <span class="keyword">explicit</span> <a class="link" href="output_test_stream.html#idm46279113082448-bb"><span class="identifier">output_test_stream</span></a><span class="special">(</span><span class="identifier">const_string</span> <span class="special">=</span> <span class="identifier">const_string</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">,</span>
  38. <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span>
  39. <a class="link" href="output_test_stream.html#idm46279113076704-bb"><span class="special">~</span><span class="identifier">output_test_stream</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  40. <span class="comment">// <a class="link" href="output_test_stream.html#idm46279113100192-bb">public member functions</a></span>
  41. <span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a class="link" href="output_test_stream.html#idm46279113099632-bb"><span class="identifier">is_empty</span></a><span class="special">(</span><span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span>
  42. <span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a class="link" href="output_test_stream.html#idm46279113096240-bb"><span class="identifier">check_length</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span>
  43. <span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a class="link" href="output_test_stream.html#idm46279113091680-bb"><span class="identifier">is_equal</span></a><span class="special">(</span><span class="identifier">const_string</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span>
  44. <span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a class="link" href="output_test_stream.html#idm46279113087168-bb"><span class="identifier">match_pattern</span></a><span class="special">(</span><span class="keyword">bool</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span>
  45. <span class="keyword">void</span> <a class="link" href="output_test_stream.html#idm46279113083744-bb"><span class="identifier">flush</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  46. <span class="comment">// <a class="link" href="output_test_stream.html#idm46279113076416-bb">protected member functions</a></span>
  47. <span class="keyword">virtual</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="output_test_stream.html#idm46279113075840-bb"><span class="identifier">get_stream_string_representation</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  48. <span class="comment">// <a class="link" href="output_test_stream.html#idm46279113073472-bb">private member functions</a></span>
  49. <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <a class="link" href="output_test_stream.html#idm46279113072896-bb"><span class="identifier">length</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  50. <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="output_test_stream.html#idm46279113071760-bb"><span class="identifier">sync</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  51. <span class="special">}</span><span class="special">;</span></pre></div>
  52. <div class="refsect1">
  53. <a name="idm45313886628048"></a><h2>Description</h2>
  54. <div class="refsect2">
  55. <a name="idm45313886627632"></a><h3>
  56. <a name="boost.test_tools.output_test_streamconstruct-copy-destruct"></a><code class="computeroutput">output_test_stream</code>
  57. public
  58. construct/copy/destruct</h3>
  59. <div class="orderedlist"><ol class="orderedlist" type="1">
  60. <li class="listitem">
  61. <pre class="literallayout"><span class="keyword">explicit</span> <a name="idm46279113082448-bb"></a><span class="identifier">output_test_stream</span><span class="special">(</span><span class="identifier">const_string</span> pattern_file_name <span class="special">=</span> <span class="identifier">const_string</span><span class="special">(</span><span class="special">)</span><span class="special">,</span>
  62. <span class="keyword">bool</span> match_or_save <span class="special">=</span> <span class="keyword">true</span><span class="special">,</span>
  63. <span class="keyword">bool</span> text_or_binary <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre>Constructor. <p>
  64. </p>
  65. <div class="variablelist"><table border="0" class="variablelist compact">
  66. <colgroup>
  67. <col align="left" valign="top">
  68. <col>
  69. </colgroup>
  70. <tbody><tr>
  71. <td><p><span class="term">Parameters:</span></p></td>
  72. <td><div class="variablelist"><table border="0" class="variablelist compact">
  73. <colgroup>
  74. <col align="left" valign="top">
  75. <col>
  76. </colgroup>
  77. <tbody>
  78. <tr>
  79. <td><p><span class="term"><code class="computeroutput">match_or_save</code></span></p></td>
  80. <td><p>if true, the pattern file will be read, otherwise it will be written </p></td>
  81. </tr>
  82. <tr>
  83. <td><p><span class="term"><code class="computeroutput">pattern_file_name</code></span></p></td>
  84. <td><p>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) </p></td>
  85. </tr>
  86. <tr>
  87. <td><p><span class="term"><code class="computeroutput">text_or_binary</code></span></p></td>
  88. <td><p>if false, opens the stream in binary mode. Otherwise the stream is opened with default flags and the carriage returns are ignored. </p></td>
  89. </tr>
  90. </tbody>
  91. </table></div></td>
  92. </tr></tbody>
  93. </table></div>
  94. </li>
  95. <li class="listitem"><pre class="literallayout"><a name="idm46279113076704-bb"></a><span class="special">~</span><span class="identifier">output_test_stream</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
  96. </ol></div>
  97. </div>
  98. <div class="refsect2">
  99. <a name="idm45313886602672"></a><h3>
  100. <a name="idm46279113100192-bb"></a><code class="computeroutput">output_test_stream</code> public member functions</h3>
  101. <div class="orderedlist"><ol class="orderedlist" type="1">
  102. <li class="listitem">
  103. <pre class="literallayout"><span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a name="idm46279113099632-bb"></a><span class="identifier">is_empty</span><span class="special">(</span><span class="keyword">bool</span> flush_stream <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre>Checks if the stream is empty. <p>
  104. </p>
  105. <div class="variablelist"><table border="0" class="variablelist compact">
  106. <colgroup>
  107. <col align="left" valign="top">
  108. <col>
  109. </colgroup>
  110. <tbody><tr>
  111. <td><p><span class="term">Parameters:</span></p></td>
  112. <td><div class="variablelist"><table border="0" class="variablelist compact">
  113. <colgroup>
  114. <col align="left" valign="top">
  115. <col>
  116. </colgroup>
  117. <tbody><tr>
  118. <td><p><span class="term"><code class="computeroutput">flush_stream</code></span></p></td>
  119. <td><p>if true, flushes the stream after the call </p></td>
  120. </tr></tbody>
  121. </table></div></td>
  122. </tr></tbody>
  123. </table></div>
  124. </li>
  125. <li class="listitem">
  126. <pre class="literallayout"><span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a>
  127. <a name="idm46279113096240-bb"></a><span class="identifier">check_length</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> length<span class="special">,</span> <span class="keyword">bool</span> flush_stream <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre>Checks the length of the stream. <p>
  128. </p>
  129. <div class="variablelist"><table border="0" class="variablelist compact">
  130. <colgroup>
  131. <col align="left" valign="top">
  132. <col>
  133. </colgroup>
  134. <tbody><tr>
  135. <td><p><span class="term">Parameters:</span></p></td>
  136. <td><div class="variablelist"><table border="0" class="variablelist compact">
  137. <colgroup>
  138. <col align="left" valign="top">
  139. <col>
  140. </colgroup>
  141. <tbody>
  142. <tr>
  143. <td><p><span class="term"><code class="computeroutput">flush_stream</code></span></p></td>
  144. <td><p>if true, flushes the stream after the call. Set to false to call additional checks on the same content. </p></td>
  145. </tr>
  146. <tr>
  147. <td><p><span class="term"><code class="computeroutput">length</code></span></p></td>
  148. <td><p>target length </p></td>
  149. </tr>
  150. </tbody>
  151. </table></div></td>
  152. </tr></tbody>
  153. </table></div>
  154. </li>
  155. <li class="listitem">
  156. <pre class="literallayout"><span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a name="idm46279113091680-bb"></a><span class="identifier">is_equal</span><span class="special">(</span><span class="identifier">const_string</span> arg_<span class="special">,</span> <span class="keyword">bool</span> flush_stream <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre>Checks the content of the stream against a string. <p>
  157. </p>
  158. <div class="variablelist"><table border="0" class="variablelist compact">
  159. <colgroup>
  160. <col align="left" valign="top">
  161. <col>
  162. </colgroup>
  163. <tbody><tr>
  164. <td><p><span class="term">Parameters:</span></p></td>
  165. <td><div class="variablelist"><table border="0" class="variablelist compact">
  166. <colgroup>
  167. <col align="left" valign="top">
  168. <col>
  169. </colgroup>
  170. <tbody>
  171. <tr>
  172. <td><p><span class="term"><code class="computeroutput">arg_</code></span></p></td>
  173. <td><p>the target stream </p></td>
  174. </tr>
  175. <tr>
  176. <td><p><span class="term"><code class="computeroutput">flush_stream</code></span></p></td>
  177. <td><p>if true, flushes the stream after the call. </p></td>
  178. </tr>
  179. </tbody>
  180. </table></div></td>
  181. </tr></tbody>
  182. </table></div>
  183. </li>
  184. <li class="listitem">
  185. <pre class="literallayout"><span class="keyword">virtual</span> <a class="link" href="assertion_result.html" title="Class assertion_result">assertion_result</a> <a name="idm46279113087168-bb"></a><span class="identifier">match_pattern</span><span class="special">(</span><span class="keyword">bool</span> flush_stream <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre>Checks the content of the stream against a pattern file. <p>
  186. </p>
  187. <div class="variablelist"><table border="0" class="variablelist compact">
  188. <colgroup>
  189. <col align="left" valign="top">
  190. <col>
  191. </colgroup>
  192. <tbody><tr>
  193. <td><p><span class="term">Parameters:</span></p></td>
  194. <td><div class="variablelist"><table border="0" class="variablelist compact">
  195. <colgroup>
  196. <col align="left" valign="top">
  197. <col>
  198. </colgroup>
  199. <tbody><tr>
  200. <td><p><span class="term"><code class="computeroutput">flush_stream</code></span></p></td>
  201. <td><p>if true, flushes/resets the stream after the call. </p></td>
  202. </tr></tbody>
  203. </table></div></td>
  204. </tr></tbody>
  205. </table></div>
  206. </li>
  207. <li class="listitem">
  208. <pre class="literallayout"><span class="keyword">void</span> <a name="idm46279113083744-bb"></a><span class="identifier">flush</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Flushes the stream. </li>
  209. </ol></div>
  210. </div>
  211. <div class="refsect2">
  212. <a name="idm45313886547664"></a><h3>
  213. <a name="idm46279113076416-bb"></a><code class="computeroutput">output_test_stream</code> protected member functions</h3>
  214. <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
  215. <pre class="literallayout"><span class="keyword">virtual</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="idm46279113075840-bb"></a><span class="identifier">get_stream_string_representation</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the string representation of the stream. <p>May be overriden in order to mutate the string before the matching operations. </p>
  216. </li></ol></div>
  217. </div>
  218. <div class="refsect2">
  219. <a name="idm45313886538128"></a><h3>
  220. <a name="idm46279113073472-bb"></a><code class="computeroutput">output_test_stream</code> private member functions</h3>
  221. <div class="orderedlist"><ol class="orderedlist" type="1">
  222. <li class="listitem">
  223. <pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <a name="idm46279113072896-bb"></a><span class="identifier">length</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Length of the stream. </li>
  224. <li class="listitem">
  225. <pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <a name="idm46279113071760-bb"></a><span class="identifier">sync</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Synching the stream into an internal string representation. </li>
  226. </ol></div>
  227. </div>
  228. </div>
  229. </div>
  230. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  231. <td align="left"></td>
  232. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  233. contributors<p>
  234. Distributed under the Boost Software License, Version 1.0. (See accompanying
  235. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  236. </p>
  237. </div></td>
  238. </tr></table>
  239. <hr>
  240. <div class="spirit-nav">
  241. <a accesskey="p" href="../../header/boost/test/tools/output_test_stream_hpp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tools/output_test_stream_hpp.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../header/boost/test/tree/observer_hpp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  242. </div>
  243. </body>
  244. </html>