Boost logo

Boost Users :

Subject: [Boost-users] Is there any internal mechanics to add support for regular expression checks to output_test_stream? (UTF)
From: Pauli Nieminen (suokkos_at_[hidden])
Date: 2009-01-25 10:43:16


Hello!

So long description is that. I'm trying to write unit test for log
subsystem to my project. The logging sub system outputs timestamps
which would be easiest to match with regular expression in unit tests.
Of course I could disable the timestamp output for unit test but I
think there might be many others test cases where regular expression
would be the simplest solution.

I tried to search for existing solution but it seems like none has
been looking for this kind of support in unit test library.So my idea
for implementing the regular expression support in my project is
extending current output_test_stream class with my own code.

So example test case should look something like (of course using a
fixture in real code):

BOOST_AUTO_TEST_CASE ( stream_check )
{
output_test_stream stream;
log::logger log(stream);
log.log_entry(<level>, <component>) << "test log messange.";
boost::regex validator("\\d{8,8} \\d\\d:\\d\\d:\\d\\d <level>
<component>: test log message.");
BOOST_CHECK( stream.is_equal(validator) );
}

Pauli

PS. "Detailed specification of class output_test_stream is covered in
reference section. " (documentation/Output testing tool) Where is that
reference section for detailed specification? The best I could find is
the source code. :)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net