lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Relaxing BOOST_TEST_THROW() message test to do substring match onl


From: Vadim Zeitlin
Subject: [lmi] Relaxing BOOST_TEST_THROW() message test to do substring match only
Date: Thu, 18 Feb 2016 02:37:32 +0100

 Hello,

 I'd like to propose relaxing the test of the message carried by the
expected exception in BOOST_TEST_THROW() to check that it appears in the
effectively thrown exception as a substring, instead of being exactly equal
to it.

 The reason for this proposal is that currently it's difficult and error
prone to exactly match the exception message, especially when it contains
some dynamic information (e.g. the line number and possibly the column in
the exceptions thrown by the code reading SOA files). Moreover, once you
manage to do it, you need to keep remembering to update the tests if the
exception message changes, even if very slightly.

 Because of this, it's very tempting to just use "" as the last argument of
BOOST_TEST_THROW(). However I've just discovered a second bug in the code
which I thought was covered by the test but which was still wrong because
it threw a wrong exception -- and didn't throw the expected one. So using
an empty string here is definitely a bad idea and the comment near the
macro definition even says as much.

 IMO checking for substring, instead of exact, match, would be a better
solution because it wouldn't really weaken the existing tests and would
make using "" much less appealing thus strengthening the future ones. And
as a nice side effect, this would also make the macro implementation
simpler as it wouldn't need to worry about "\n[file" part.

 What do you think?
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]