$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Beman Dawes (beman_at_[hidden])
Date: 2000-12-03 20:48:17
At 12:13 PM 12/1/2000 -0600, Ed Brey wrote:
 >From: "Beman Dawes" <beman_at_[hidden]>
 >> A preliminary Test Tools Library has been uploaded at
 >> http://www.egroups.com/files/boost/test_tools/
 >
 >I think it's a great way to get the boost regression test started.  I 
also
 >think that it should be a library that is designed to be used by boost
 >users
 >for their own non-boost code, as well as being used by boost library
 >developers to test other library code.  I know I'm planning on using it 
at
 >my work to as a way to kickstart a more formalized unit-level regression
 >testing process.
I've used an earlier version some years now, it really is quite handy.  But 
thanks for the encouragement; I needed someone else to look at it and 
confirm that it looks useful.
 >Looking at the implementation, I see one major problem: If there are
 >multiple translation units that include test_tools.hpp,
 >boost::report_non_fatal_error and boost::report_fatal_error will be
 >multiply
 >defined.  To solve the problem, I'd recommend moving the implementation 
of
 >those functions to test_main.hpp.
Done.
 >>  I also would rename test_main.hpp to
 >test_main.cpp, to make it obvious that it should only be included in from 
a
 >single translation unit (or not #included at all, but rather linked in 
from
 >the boost library (.a, .lib, or .dll).
I'll have to think about that.  Packaging the whole implementation in the 
header has some advantages.
 >I also have a semi-nit: The long list of catches for classes deriving 
from
 >std::exception, could be replaced by:
 >  catch ( const std::exception & ex )
 >    { std::cout << typeid(ex).name() << ": " << ex.what() << std::endl; }
Yes, that long list is a bit ugly, but at least the output is quite 
clear.  Also, as others pointed out, using typeid(ex).name() has problems 
on some compilers.
 >And finally some fundamentally nitty nits:
 >1. test_main.hpp(66): xmain -> test_main
Fixed.  A holdover from a earlier name.
 >2. test_main.hpp(75): ex.c_str() -> ex
Fixed.  Had to #include <string> as a result.
 >3. test_main.hpp(69): boost::test_tools_exception& -> const
 >boost::test_tools_exception&
Well, I certainly was inconsistent!  Two catches used const, the rest 
didn't.  The rules for catching const &'s are a bit different from 
function  arguments (ISO 15.3 paragraphs 18 & 19) so const apparently isn't 
required, but const doesn't hurt anything either so I added it to all.  (I 
skimmed the appropriate sections of C++ Programming Language, Special 
Edition, and More Effective C++, and neither is very clear as to whether 
const ref or just plain ref is preferred.)
A nit about your nitty nits:-)
The name of the header is main.hpp, following the logic that that's the 
name of the supplied function.  Your "test_main" might be a bit clearer, 
but since we can't change the name of main(), I'll leave the name alone.
 >And then a question: In order to better support existing test apps that
 >return a value to indicate an error (as opposed to using the BOOST_TEST
 >macros or exceptions), would it be useful to have main print out the 
value
 >of "result"?
It already does:
{ std::cout << "\n**** error; test_main returned: " << result << ...
                                                        ^^^^^^
Or am I misunderstanding your question?
Thanks for the comments.  I've updated the files in the vault.
--Beman