tests/utils/auto_parameterized.hpp

Go to the documentation of this file.
00001 /* $Id: auto_parameterized.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Pauli Nieminen <paniemin@cc.hut.fi>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef TESTS_UTILS_AUTO_PARAMETERIZED_HPP_INCLUDED
00017 #define TESTS_UTILS_AUTO_PARAMETERIZED_HPP_INCLUDED
00018 
00019 #include <boost/test/unit_test_suite.hpp>
00020 #include <boost/test/parameterized_test.hpp>
00021 
00022 namespace test_utils {
00023 
00024 #ifndef BOOST_AUTO_TU_REGISTRAR
00025 #define BOOST_AUTO_TU_REGISTRAR BOOST_AUTO_TC_REGISTRAR
00026 #endif
00027 
00028 #define WESNOTH_PARAMETERIZED_TEST_CASE( test_name, type_name, values, param_name )   \
00029 struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE                  \
00030 { void test_method(const type_name&); };                                \
00031 \
00032 type_name* BOOST_JOIN(test_name, _begin) = &values[0];    \
00033 type_name* BOOST_JOIN(test_name, _end) = BOOST_JOIN(test_name, _begin) + (sizeof(values)/sizeof(values[0])); \
00034 static void BOOST_AUTO_TC_INVOKER( test_name )(const type_name& param_name ) \
00035 { \
00036     test_name t;                                                        \
00037     t.test_method(param_name);       \
00038 }                                                                       \
00039                                                                         \
00040 struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
00041                                                                         \
00042 BOOST_AUTO_TU_REGISTRAR( test_name )( \
00043         boost::unit_test::make_test_case(&BOOST_AUTO_TC_INVOKER( test_name ),      \
00044             BOOST_TEST_STRINGIZE( test_name ),\
00045             BOOST_JOIN(test_name, _begin), BOOST_JOIN(test_name, _end)));       \
00046                                                                        \
00047 void test_name::test_method(const type_name& param_name)                \
00048 /**/
00049 
00050 }
00051 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Wed May 23 2012 01:02:57 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs