Test for stringize macro and use of variadic in stringize macro.

This commit is contained in:
Edward Diener
2018-10-16 16:37:10 -04:00
parent b5c081bf7a
commit 0e335df79e
6 changed files with 79 additions and 0 deletions

View File

@ -28,6 +28,10 @@
# define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_I(text) # define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_I(text)
# endif # endif
# #
#if BOOST_PP_VARIADICS
# define BOOST_PP_STRINGIZE_I(...) #__VA_ARGS__
#else
# define BOOST_PP_STRINGIZE_I(text) #text # define BOOST_PP_STRINGIZE_I(text) #text
#endif
# #
# endif # endif

View File

@ -23,7 +23,11 @@
# define BOOST_PP_WSTRINGIZE_OO(par) BOOST_PP_WSTRINGIZE_I ## par # define BOOST_PP_WSTRINGIZE_OO(par) BOOST_PP_WSTRINGIZE_I ## par
# endif # endif
# #
#if BOOST_PP_VARIADICS
# define BOOST_PP_WSTRINGIZE_I(...) BOOST_PP_WSTRINGIZE_II(#__VA_ARGS__)
#else
# define BOOST_PP_WSTRINGIZE_I(text) BOOST_PP_WSTRINGIZE_II(#text) # define BOOST_PP_WSTRINGIZE_I(text) BOOST_PP_WSTRINGIZE_II(#text)
#endif
# define BOOST_PP_WSTRINGIZE_II(str) L ## str # define BOOST_PP_WSTRINGIZE_II(str) L ## str
# #
# endif # endif

View File

@ -48,6 +48,7 @@ alias preprocessor
[ compile selection.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ] [ compile selection.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
[ compile seq.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ] [ compile seq.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
[ compile slot.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ] [ compile slot.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
[ compile stringize.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
[ compile tuple.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ] [ compile tuple.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
[ compile variadic.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ] [ compile variadic.cpp : <toolset>gcc:<cxxflags>-std=c++0x <toolset>clang-linux:<cxxflags>-std=c++0x ]
; ;
@ -67,6 +68,7 @@ alias preprocessor_nvm
[ compile selection.cpp : <define>BOOST_PP_VARIADICS=0 : selection_nvm ] [ compile selection.cpp : <define>BOOST_PP_VARIADICS=0 : selection_nvm ]
[ compile seq.cpp : <define>BOOST_PP_VARIADICS=0 : seq_nvm ] [ compile seq.cpp : <define>BOOST_PP_VARIADICS=0 : seq_nvm ]
[ compile slot.cpp : <define>BOOST_PP_VARIADICS=0 : slot_nvm ] [ compile slot.cpp : <define>BOOST_PP_VARIADICS=0 : slot_nvm ]
[ compile stringize.cpp : <define>BOOST_PP_VARIADICS=0 : stringize_nvm ]
[ compile tuple.cpp : <define>BOOST_PP_VARIADICS=0 : tuple_nvm ] [ compile tuple.cpp : <define>BOOST_PP_VARIADICS=0 : tuple_nvm ]
; ;
@ -120,6 +122,10 @@ alias preprocessor_c
: <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99 : <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99
: slot_c : slot_c
] ]
[ compile stringize.c
: <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99
: stringize_c
]
[ compile tuple.c [ compile tuple.c
: <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99 : <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99
: tuple_c : tuple_c
@ -187,6 +193,11 @@ alias preprocessor_c_nvm
<toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99 <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99
: slot_c_nvm : slot_c_nvm
] ]
[ compile stringize.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99
: stringize_c_nvm
]
[ compile tuple.c [ compile tuple.c
: <define>BOOST_PP_VARIADICS=0 : <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99 <toolset>gcc:<cflags>-std=c99 <toolset>clang-linux:<cflags>-std=c99

12
test/stringize.c Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2018.
# * 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 for most recent version. */
#
# include <libs/preprocessor/test/stringize.cxx>

12
test/stringize.cpp Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2018.
# * 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 for most recent version. */
#
# include <libs/preprocessor/test/stringize.cxx>

36
test/stringize.cxx Normal file
View File

@ -0,0 +1,36 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2018.
# * 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 for most recent version. */
#
# include <boost/preprocessor/stringize.hpp>
# include <boost/preprocessor/wstringize.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
# include <libs/preprocessor/test/test.h>
#define VDATA 1,2,3,4
#define NDATA
#define DATA data
#define FDATA(x) BOOST_PP_INC(x)
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
BEGIN sizeof(BOOST_PP_STRINGIZE(NDATA)) / sizeof(char) == 1 END
BEGIN sizeof(BOOST_PP_WSTRINGIZE(NDATA)) / sizeof(wchar_t) == 1 END
#endif
BEGIN sizeof(BOOST_PP_STRINGIZE(DATA)) / sizeof(char) == 5 END
BEGIN sizeof(BOOST_PP_STRINGIZE(FDATA(1))) / sizeof(char) == 2 END
BEGIN sizeof(BOOST_PP_STRINGIZE(FDATA(9))) / sizeof(char) == 3 END
BEGIN sizeof(BOOST_PP_WSTRINGIZE(DATA)) / sizeof(wchar_t) == 5 END
BEGIN sizeof(BOOST_PP_WSTRINGIZE(FDATA(1))) / sizeof(wchar_t) == 2 END
BEGIN sizeof(BOOST_PP_WSTRINGIZE(FDATA(9))) / sizeof(wchar_t) == 3 END
#if BOOST_PP_VARIADICS
BEGIN sizeof(BOOST_PP_STRINGIZE(VDATA)) / sizeof(char) == 8 END
BEGIN sizeof(BOOST_PP_WSTRINGIZE(VDATA)) / sizeof(wchar_t) == 8 END
#endif