Recent changes to 32: Add optional line wrapping for TextTestProgressListenerhttp://sourceforge.net/p/cppunit/feature-requests/32/Recent changes to 32: Add optional line wrapping for TextTestProgressListenerenFri, 07 Nov 2003 17:00:52 -0000Add optional line wrapping for TextTestProgressListenerhttp://sourceforge.net/p/cppunit/feature-requests/32/<div class="markdown_content"><p>I have my build process in VC++ set up to run the tests <br />
as part of the build and have the output go to the <br />
output window. The VC++ output window has a <br />
horizontal scroll bar so long lines do not automatically <br />
wrap. If I use the TextTestProgressListener with a large <br />
number of tests the dots and failure indications are not <br />
all visible at once.</p>
<p>I want to be able to specify that the output from the <br />
TextTestProgressListener inserts line breaks every n <br />
characters. Currently I do that with this subclass of <br />
TextTestProgressListener:</p>
<p>class WrappedTextTestProgressListener : public <br />
CPPUNIT_NS::TextTestProgressListener<br />
{<br />
private:<br />
unsigned margin;<br />
unsigned column;</p>
<p>void incrementColumn()<br />
{<br />
if( ++column &amp;gt;= margin )<br />
{<br />
std::cerr &amp;lt;&amp;lt; std::endl;<br />
column = 0;<br />
}<br />
}</p>
<p>public:<br />
WrappedTextTestProgressListener( unsigned margin <br />
= ~0 )<br />
: margin( margin ), column( 0 )<br />
{<br />
}</p>
<p>void addFailure( const CPPUNIT_NS::TestFailure <br />
&amp;amp;failure )<br />
{<br />
TextTestProgressListener::addFailure( failure );<br />
incrementColumn();<br />
}</p>
<p>void startTest( CPPUNIT_NS::Test *test )<br />
{<br />
TextTestProgressListener::startTest( test );<br />
incrementColumn();<br />
}<br />
};</p>
<p>This functionality should probably be incorporated into <br />
TextTestProgressListener. Note that the line wrapping is <br />
optional. If you don't specify a margin you will not see a <br />
difference (unless you have enough test to overflow <br />
unsigned).</p>
<p>Another way to go is that I could create a special output <br />
stream wrapper that wraps an ostream to do the line <br />
wrapping. However that doesn't work in this case <br />
because TextTestProgressListener is hardcoded to use <br />
std::cerr. It should take the ostream as a parameter to <br />
the constructor with a specified default value of <br />
std::cerr.</p></div>Dale KingFri, 07 Nov 2003 17:00:52 -0000http://sourceforge.net658a7cf99adc3a9bb32d44d5d837c697de037b37