|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81107 - in trunk/boost/test: data utils
From: gennadiy.rozental_at_[hidden]
Date: 2012-10-29 16:21:16
Author: rogeeff
Date: 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
New Revision: 81107
URL: http://svn.boost.org/trac/boost/changeset/81107
Log:
improve data test case interface to support case without param name
Added:
trunk/boost/test/utils/pp_variadic.hpp (contents, props changed)
Text files modified:
trunk/boost/test/data/test_case.hpp | 18 +++++++++++++++---
trunk/boost/test/utils/algorithm.hpp | 1 +
trunk/boost/test/utils/nullstream.hpp | 2 ++
trunk/boost/test/utils/rtti.hpp | 1 +
trunk/boost/test/utils/trivial_singleton.hpp | 2 ++
5 files changed, 21 insertions(+), 3 deletions(-)
Modified: trunk/boost/test/data/test_case.hpp
==============================================================================
--- trunk/boost/test/data/test_case.hpp (original)
+++ trunk/boost/test/data/test_case.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -19,6 +19,8 @@
#include <boost/test/data/config.hpp>
#include <boost/test/data/dataset.hpp>
+#include <boost/test/utils/pp_variadic.hpp>
+
// Boost
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
@@ -30,6 +32,7 @@
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/enum.hpp>
+#include <boost/preprocessor/control/iif.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -114,8 +117,7 @@
/**/
#define BOOST_DATA_TEST_CASE_IMPL( arity, test_name, dataset, params ) \
-struct test_name \
-{ \
+struct test_name { \
template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \
static void test_method( BOOST_DATA_TEST_CASE_PARAMS( params ) ) \
{ \
@@ -137,11 +139,21 @@
void test_name::_impl( BOOST_DATA_TEST_CASE_PARAMS( params ) ) \
/**/
-#define BOOST_DATA_TEST_CASE( test_name, dataset, ... ) \
+#define BOOST_DATA_TEST_CASE_WITH_PARAMS( test_name, dataset, ... ) \
BOOST_DATA_TEST_CASE_IMPL( BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), \
test_name, dataset, \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) ) \
/**/
+#define BOOST_DATA_TEST_CASE_NO_PARAMS( test_name, dataset, ... ) \
+ BOOST_DATA_TEST_CASE_WITH_PARAMS( test_name, dataset, sample ) \
+/**/
+
+#define BOOST_DATA_TEST_CASE( test_name, dataset, ... ) \
+ BOOST_PP_IIF(BOOST_TEST_PP_NON_EMPTY(__VA_ARGS__), \
+ BOOST_DATA_TEST_CASE_WITH_PARAMS, \
+ BOOST_DATA_TEST_CASE_NO_PARAMS ) \
+ (test_name, dataset, __VA_ARGS__) \
+/**/
} // namespace data
} // namespace unit_test
Modified: trunk/boost/test/utils/algorithm.hpp
==============================================================================
--- trunk/boost/test/utils/algorithm.hpp (original)
+++ trunk/boost/test/utils/algorithm.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -15,6 +15,7 @@
#ifndef BOOST_ALGORITHM_HPP_062304GER
#define BOOST_ALGORITHM_HPP_062304GER
+// STL
#include <utility>
#include <algorithm> // std::find
#include <functional> // std::bind1st
Modified: trunk/boost/test/utils/nullstream.hpp
==============================================================================
--- trunk/boost/test/utils/nullstream.hpp (original)
+++ trunk/boost/test/utils/nullstream.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -16,10 +16,12 @@
#ifndef BOOST_NULLSTREAM_HPP_071894GER
#define BOOST_NULLSTREAM_HPP_071894GER
+// STL
#include <ostream> // for std::basic_ostream
#include <streambuf> // for std::basic_streambuf
#include <string> // for std::char_traits
+// Boost
#include <boost/utility/base_from_member.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
Added: trunk/boost/test/utils/pp_variadic.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/utils/pp_variadic.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -0,0 +1,53 @@
+// (C) Copyright Gennadiy Rozental 2005-2012.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 81012 $
+//
+// Description : simple helpers for creating cusom output manipulators
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PP_VARIADIC_HPP_102412GER
+#define BOOST_TEST_PP_VARIADIC_HPP_102412GER
+
+// Boost
+#include <boost/config.hpp>
+#include <boost/preprocessor/arithmetic/mul.hpp>
+#include <boost/preprocessor/arithmetic/sub.hpp>
+#include <boost/preprocessor/punctuation/comma.hpp>
+#include <boost/preprocessor/variadic/size.hpp>
+#include <boost/preprocessor/logical/bool.hpp>
+
+#include <boost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace boost {
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** BOOST_TEST_PP_VARIADIC_SIZE ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_PP_VARIADIC_SIZE(...) BOOST_PP_SUB( BOOST_PP_MUL( BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 2 ), \
+ BOOST_PP_VARIADIC_SIZE( BOOST_PP_COMMA __VA_ARGS__ () ) ) \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_TEST_PP_NON_EMPTY ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_PP_NON_EMPTY(...) BOOST_PP_BOOL(BOOST_TEST_PP_VARIADIC_SIZE(__VA_ARGS__))
+
+} // namespace unit_test
+} // namespace boost
+
+
+#include <boost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PP_VARIADIC_HPP_102412GER
Modified: trunk/boost/test/utils/rtti.hpp
==============================================================================
--- trunk/boost/test/utils/rtti.hpp (original)
+++ trunk/boost/test/utils/rtti.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -15,6 +15,7 @@
#ifndef BOOST_TEST_RTTI_HPP_062604GER
#define BOOST_TEST_RTTI_HPP_062604GER
+// C Runtime
#include <cstddef>
namespace boost {
Modified: trunk/boost/test/utils/trivial_singleton.hpp
==============================================================================
--- trunk/boost/test/utils/trivial_singleton.hpp (original)
+++ trunk/boost/test/utils/trivial_singleton.hpp 2012-10-29 16:21:14 EDT (Mon, 29 Oct 2012)
@@ -15,9 +15,11 @@
#ifndef BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
#define BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
+// Boost.Test
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
+// Boost
#include <boost/noncopyable.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk