|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65428 - sandbox/variadic_macro_data/libs/variadic_macro_data/test
From: eldiener_at_[hidden]
Date: 2010-09-15 15:28:01
Author: eldiener
Date: 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
New Revision: 65428
URL: http://svn.boost.org/trac/boost/changeset/65428
Log:
Original test files
Added:
sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestData.cpp (contents, props changed)
sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsArray.cpp (contents, props changed)
sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsList.cpp (contents, props changed)
sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsSequence.cpp (contents, props changed)
sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsTuple.cpp (contents, props changed)
Added: sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestData.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestData.cpp 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
@@ -0,0 +1,33 @@
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <boost/type_traits/is_same.hpp>
+
+int main()
+ {
+
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+
+ int aSize(VMD_DATA_SIZE(23,ll,678,456));
+
+ BOOST_TEST_EQ(aSize,4);
+
+ int anElement(VMD_DATA_ELEMENT(2,23,ll,678,456));
+
+ BOOST_TEST_EQ(anElement,678);
+
+ #define VMD_TEST_EXPAND(...) int,__VA_ARGS__
+
+ int numberOfTypes(VMD_DATA_SIZE(VMD_TEST_EXPAND(unsigned,long,short,unsigned long)));
+
+ BOOST_TEST_EQ(numberOfTypes,5);
+
+ typedef std::vector<VMD_DATA_ELEMENT(0,VMD_TEST_EXPAND(unsigned,long,short,unsigned long))>::value_type vtype;
+
+ BOOST_TEST((boost::is_same<vtype,int>::value));
+
+#endif
+
+ return boost::report_errors();
+
+ }
Added: sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsArray.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsArray.cpp 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
@@ -0,0 +1,49 @@
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/preprocessor/array/size.hpp>
+#include <boost/preprocessor/array/elem.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <vector>
+#include <boost/type_traits/is_same.hpp>
+
+int main()
+ {
+
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+
+ #define VMD_TEST_ARRAY_NUMBERS \
+ VMD_DATA_TO_PP_ARRAY(47,69,23,985,458,77,12457,89,99872) \
+ /**/
+
+ #define VMD_TEST_ARRAY_TYPES(...) \
+ VMD_DATA_TO_PP_ARRAY(int,__VA_ARGS__) \
+ /**/
+
+ int addedNumber(0);
+
+ #define VMD_TEST_ADD_TO_INT(z,n,data) \
+ if (BOOST_PP_ARRAY_SIZE(data) > n) \
+ { \
+ addedNumber += BOOST_PP_ARRAY_ELEM(n,data); \
+ } \
+ /**/
+
+ BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(VMD_TEST_ARRAY_NUMBERS),VMD_TEST_ADD_TO_INT,VMD_TEST_ARRAY_NUMBERS)
+
+ addedNumber += VMD_DATA_ELEMENT(5,VMD_PP_ARRAY_TO_DATA(VMD_TEST_ARRAY_NUMBERS));
+
+ BOOST_TEST_EQ(addedNumber,47+69+23+985+458+77+12457+89+99872+77);
+
+ int numberOfTypes(BOOST_PP_ARRAY_SIZE(VMD_TEST_ARRAY_TYPES(unsigned,long,short,unsigned long,double,float)));
+
+ BOOST_TEST_EQ(numberOfTypes,7);
+
+ typedef std::vector<BOOST_PP_ARRAY_ELEM(4,VMD_TEST_ARRAY_TYPES(unsigned,long,short,unsigned long,double,float))>::value_type vtype;
+
+ BOOST_TEST((boost::is_same<vtype,unsigned long>::value));
+
+#endif
+
+ return boost::report_errors();
+
+ }
Added: sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsList.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsList.cpp 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
@@ -0,0 +1,49 @@
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/preprocessor/list/at.hpp>
+#include <boost/preprocessor/list/size.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <vector>
+#include <boost/type_traits/is_same.hpp>
+
+int main()
+ {
+
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+
+ #define VMD_TEST_LIST_NUMBERS \
+ VMD_DATA_TO_PP_LIST(34,23467,12,9984,34,678,7890,1235678,3489,1,8965,345) \
+ /**/
+
+ #define VMD_TEST_LIST_TYPES(...) \
+ VMD_DATA_TO_PP_LIST(unsigned char,__VA_ARGS__) \
+ /**/
+
+ int addedNumber(0);
+
+ #define VMD_TEST_ADD_TO_INT(z,n,data) \
+ if (BOOST_PP_LIST_SIZE(data) > n) \
+ { \
+ addedNumber += BOOST_PP_LIST_AT(data,n); \
+ } \
+ /**/
+
+ BOOST_PP_REPEAT(BOOST_PP_LIST_SIZE(VMD_TEST_LIST_NUMBERS),VMD_TEST_ADD_TO_INT,VMD_TEST_LIST_NUMBERS)
+
+ addedNumber += VMD_DATA_ELEMENT(8,VMD_PP_LIST_TO_DATA(VMD_TEST_LIST_NUMBERS));
+
+ BOOST_TEST_EQ(addedNumber,34+23467+12+9984+34+678+7890+1235678+3489+1+8965+345+3489);
+
+ int numberOfTypes(BOOST_PP_LIST_SIZE(VMD_TEST_LIST_TYPES(unsigned short,unsigned,long,short,unsigned long,double,float,char)));
+
+ BOOST_TEST_EQ(numberOfTypes,9);
+
+ typedef std::vector<BOOST_PP_LIST_AT(VMD_TEST_LIST_TYPES(unsigned short,unsigned,long,short,unsigned long,double,float,char),3)>::value_type vtype;
+
+ BOOST_TEST((boost::is_same<vtype,long>::value));
+
+#endif
+
+ return boost::report_errors();
+
+ }
Added: sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsSequence.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsSequence.cpp 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
@@ -0,0 +1,49 @@
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <vector>
+#include <boost/type_traits/is_same.hpp>
+
+int main()
+ {
+
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+
+ #define VMD_TEST_SEQ_NUMBERS \
+ VMD_DATA_TO_PP_SEQ(4578,24,789436,78345,902,345,860,667433,56,727,47891) \
+ /**/
+
+ #define VMD_TEST_SEQ_TYPES(...) \
+ VMD_DATA_TO_PP_SEQ(bool,__VA_ARGS__) \
+ /**/
+
+ int addedNumber(0);
+
+ #define VMD_TEST_ADD_TO_INT(z,n,data) \
+ if (BOOST_PP_SEQ_SIZE(data) > n) \
+ { \
+ addedNumber += BOOST_PP_SEQ_ELEM(n,data); \
+ } \
+ /**/
+
+ BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(VMD_TEST_SEQ_NUMBERS),VMD_TEST_ADD_TO_INT,VMD_TEST_SEQ_NUMBERS)
+
+ addedNumber += VMD_DATA_ELEMENT(2,VMD_PP_SEQ_TO_DATA(VMD_TEST_SEQ_NUMBERS));
+
+ BOOST_TEST_EQ(addedNumber,4578+24+789436+78345+902+345+860+667433+56+727+47891+789436);
+
+ int numberOfTypes(BOOST_PP_SEQ_SIZE(VMD_TEST_SEQ_TYPES(long,short,unsigned long,double,float)));
+
+ BOOST_TEST_EQ(numberOfTypes,6);
+
+ typedef std::vector<BOOST_PP_SEQ_ELEM(5,VMD_TEST_SEQ_TYPES(long,short,unsigned long,double,float))>::value_type vtype;
+
+ BOOST_TEST((boost::is_same<vtype,float>::value));
+
+#endif
+
+ return boost::report_errors();
+
+ }
Added: sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsTuple.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/TestDataAsTuple.cpp 2010-09-15 15:27:47 EDT (Wed, 15 Sep 2010)
@@ -0,0 +1,64 @@
+#include <boost/variadic_macro_data/VariadicMacroData.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/preprocessor/list/size.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <vector>
+#include <boost/type_traits/is_same.hpp>
+
+int main()
+ {
+
+#if !defined(BOOST_NO_VARIADIC_MACROS)
+
+ #define VMD_TEST_TUPLE_NUMBERS \
+ VMD_DATA_TO_PP_TUPLE(23,45,147,6,7743,12,67,43,89045,82) \
+ /**/
+
+ #define VMD_TEST_TUPLE_NUMBERS2 \
+ VMD_DATA_TO_PP_TUPLE(23,45,147,6,7743) \
+ /**/
+
+ #define VMD_TEST_TUPLE_NUMBERS3 \
+ VMD_DATA_TO_PP_TUPLE(23,45,147,6,7743,12,67,43,89045,82,8743,11) \
+ /**/
+
+ #define VMD_TEST_TUPLE_TYPES(...) \
+ VMD_DATA_TO_PP_TUPLE(int,__VA_ARGS__) \
+ /**/
+
+ int addedNumber(0);
+
+ #define VMD_TEST_ADD_TO_INT(z,n,data) \
+ if (VMD_PP_TUPLE_SIZE(data) > n) \
+ { \
+ addedNumber += VMD_PP_TUPLE_ELEM(n,VMD_PP_TUPLE_REVERSE(data)); \
+ } \
+ /**/
+
+ VMD_PP_REPEAT_TUPLE(VMD_TEST_ADD_TO_INT,VMD_TEST_TUPLE_NUMBERS)
+
+ addedNumber += VMD_DATA_ELEMENT(5,VMD_PP_TUPLE_TO_DATA(VMD_TEST_TUPLE_NUMBERS));
+
+ BOOST_TEST_EQ(addedNumber,23+45+147+6+7743+12+67+43+89045+82+12);
+
+ int listSize(BOOST_PP_LIST_SIZE(VMD_PP_TUPLE_TO_LIST(VMD_TEST_TUPLE_NUMBERS2)));
+
+ BOOST_TEST_EQ(listSize,5);
+
+ int seqSize(BOOST_PP_SEQ_SIZE(VMD_PP_TUPLE_TO_SEQ(VMD_TEST_TUPLE_NUMBERS3)));
+
+ BOOST_TEST_EQ(seqSize,12);
+
+ int numberOfTypes(VMD_PP_TUPLE_SIZE(VMD_TEST_TUPLE_TYPES(unsigned,long,short,unsigned long,double,float)));
+
+ BOOST_TEST_EQ(numberOfTypes,7);
+
+ typedef std::vector<VMD_PP_TUPLE_ELEM(5,VMD_TEST_TUPLE_TYPES(unsigned,long,short,unsigned long,double,float))>::value_type vtype;
+
+ BOOST_TEST((boost::is_same<vtype,double>::value));
+
+#endif
+
+ return boost::report_errors();
+
+ }
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