Boost logo

Boost Users :

From: Oliver Schoenborn (oliver.schoenborn_at_[hidden])
Date: 2005-04-06 12:23:13


I like the auto test feature of Boost.test because it's quick and simple to
use. Unfortunately, when BOOST_AUTO_TEST_MAIN is #define'd, the auto suite
name is hardcoded. Changing auto_unit_test.hpp so user can, *if desired*,
change it, can be done with following patch:
 

$ diff -u ~/downloads/boost_1_32_0/boost/test/auto_unit_test.hpp
/c/Boost/inclu
de/boost-1_32/boost/test/auto_unit_test.hpp
--- boost_1_32_0/boost/test/auto_unit_test.hpp Mon Jul 19 09:12:40 2004
+++ /c/Boost/include/boost-1_32/boost/test/auto_unit_test.hpp Wed Apr 6
12:46:07 2005
@@ -19,6 +19,10 @@
 // Boost.Test
 #include <boost/test/unit_test.hpp>
 
+#ifndef BOOST_AUTO_TEST_SUITE_NAME
+#define BOOST_AUTO_TEST_SUITE_NAME "Auto Unit Test"
+#endif
+
 //
**************************************************************************
//
 // ************** auto_unit_test_registrar
************** //
 //
**************************************************************************
//
@@ -27,10 +31,17 @@
 namespace unit_test {
 namespace ut_detail {
 
+inline const char*
+suiteName(const char* name = NULL)
+{
+ return name ? name : BOOST_AUTO_TEST_SUITE_NAME;
+}
+
 inline boost::unit_test::test_suite*
 auto_unit_test_suite()
 {
- static boost::unit_test::test_suite* inst = BOOST_TEST_SUITE( "Auto
Unit Test" );
+ static boost::unit_test::test_suite* inst
+ = BOOST_TEST_SUITE( suiteName(BOOST_AUTO_TEST_MAIN) );
 
     return inst;
 }

This allows you to do any of:
 
1) Like current (default suite name is "Auto Unit Test"):

#define BOOST_AUTO_TEST_MAIN

2) Change from default suite name to what you want:

#define BOOST_AUTO_TEST_MAIN "Your suite name"

3) Same, but doesn't "overload" the BOOST_AUTO_TEST_MAIN:

#define BOOST_AUTO_TEST_MAIN
#define BOOST_AUTO_TEST_SUITE_NAME "Your suite name"
 

This enhancement maintains backward compatibility but allows automated test
suites to be distinguishable.
 
 
Oliver
 



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