conversion.hpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*=============================================================================
  2. Copyright (c) 2016 Lee Clagett
  3. Use modification and distribution are subject to the Boost Software
  4. License, Version 1.0. (See accompanyintg file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ==============================================================================*/
  7. #include <boost/config.hpp>
  8. #include <boost/detail/lightweight_test.hpp>
  9. #include <boost/fusion/adapted/boost_tuple.hpp>
  10. #include <boost/fusion/adapted/std_pair.hpp>
  11. #if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
  12. && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  13. # include <boost/fusion/adapted/std_tuple.hpp>
  14. #endif
  15. #include <boost/fusion/container/deque.hpp>
  16. #include <boost/fusion/container/list.hpp>
  17. #include <boost/fusion/tuple.hpp>
  18. #include <boost/fusion/container/vector.hpp>
  19. #include "fixture.hpp"
  20. template <template <typename> class Scenario>
  21. void test()
  22. {
  23. using namespace test_detail;
  24. // Note the trunction conversion tests from each containter
  25. // ... bug or feature?
  26. BOOST_TEST((
  27. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  28. boost::fusion::push_back(FUSION_SEQUENCE<int>(300), 400)
  29. )
  30. ));
  31. BOOST_TEST((
  32. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  33. boost::fusion::push_back(FUSION_SEQUENCE<int>(200), 400)
  34. , FUSION_SEQUENCE<convertible>(200)
  35. )
  36. ));
  37. BOOST_TEST((run<Scenario<FUSION_SEQUENCE<> > >(boost::fusion::vector<>())));
  38. BOOST_TEST((
  39. run< Scenario< FUSION_SEQUENCE<> > >(
  40. boost::fusion::vector<int>(100), boost::fusion::vector<>()
  41. )
  42. ));
  43. BOOST_TEST((
  44. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  45. boost::fusion::vector<int>(110)
  46. )
  47. ));
  48. BOOST_TEST((
  49. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  50. boost::fusion::vector<int, int>(200, 100)
  51. , boost::fusion::vector<convertible>(200)
  52. )
  53. ));
  54. BOOST_TEST((
  55. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  56. boost::fusion::vector<int, int>(200, 400)
  57. )
  58. ));
  59. BOOST_TEST((
  60. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  61. boost::fusion::vector<int, int, int>(500, 400, 100)
  62. , boost::fusion::vector<convertible, int>(500, 400)
  63. )
  64. ));
  65. BOOST_TEST((
  66. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  67. boost::fusion::push_back(
  68. boost::fusion::vector<int>(500), 400
  69. )
  70. )
  71. ));
  72. BOOST_TEST((
  73. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  74. boost::fusion::push_back(
  75. boost::fusion::vector<int, int>(500, 400), 100
  76. )
  77. , boost::fusion::vector<convertible, int>(500, 400)
  78. )
  79. ));
  80. BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::deque<>())));
  81. BOOST_TEST((
  82. run< Scenario< FUSION_SEQUENCE<> > >(
  83. boost::fusion::deque<int>(100), boost::fusion::deque<>()
  84. )
  85. ));
  86. BOOST_TEST((
  87. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  88. boost::fusion::deque<int>(500)
  89. )
  90. ));
  91. BOOST_TEST((
  92. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  93. boost::fusion::deque<int, int>(500, 100)
  94. , boost::fusion::deque<convertible>(500)
  95. )
  96. ));
  97. BOOST_TEST((
  98. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  99. boost::fusion::deque<int, int>(500, 400)
  100. )
  101. ));
  102. BOOST_TEST((
  103. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  104. boost::fusion::deque<int, int, int>(500, 400, 100)
  105. , boost::fusion::deque<convertible, int>(500, 400)
  106. )
  107. ));
  108. BOOST_TEST((
  109. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  110. boost::fusion::push_back(
  111. boost::fusion::deque<int>(500), 400
  112. )
  113. )
  114. ));
  115. BOOST_TEST((
  116. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  117. boost::fusion::push_back(
  118. boost::fusion::deque<int, int>(500, 400), 100
  119. )
  120. , boost::fusion::deque<convertible, int>(500, 400)
  121. )
  122. ));
  123. BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::fusion::list<>())));
  124. BOOST_TEST((
  125. run< Scenario< FUSION_SEQUENCE<> > >(
  126. boost::fusion::list<int>(100), boost::fusion::list<>()
  127. )
  128. ));
  129. BOOST_TEST((
  130. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  131. boost::fusion::list<int>(500)
  132. )
  133. ));
  134. BOOST_TEST((
  135. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  136. boost::fusion::list<int, int>(500, 100)
  137. , boost::fusion::list<convertible>(500)
  138. )
  139. ));
  140. BOOST_TEST((
  141. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  142. boost::fusion::list<int, int>(500, 400)
  143. )
  144. ));
  145. BOOST_TEST((
  146. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  147. boost::fusion::list<int, int, int>(500, 400, 100)
  148. , boost::fusion::list<convertible, int>(500, 400)
  149. )
  150. ));
  151. BOOST_TEST((
  152. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  153. boost::fusion::push_back(
  154. boost::fusion::list<int>(500), 400
  155. )
  156. )
  157. ));
  158. BOOST_TEST((
  159. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  160. boost::fusion::push_back(
  161. boost::fusion::list<int, int>(500, 400), 100
  162. )
  163. , boost::fusion::list<convertible, int>(500, 400)
  164. )
  165. ));
  166. BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::tuple<>())));
  167. BOOST_TEST((
  168. run< Scenario< FUSION_SEQUENCE<> > >(
  169. boost::fusion::tuple<int>(100), boost::fusion::tuple<>()
  170. )
  171. ));
  172. BOOST_TEST((
  173. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  174. boost::fusion::tuple<int>(500)
  175. )
  176. ));
  177. BOOST_TEST((
  178. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  179. boost::fusion::tuple<int, int>(500, 100)
  180. , boost::fusion::tuple<convertible>(500)
  181. )
  182. ));
  183. BOOST_TEST((
  184. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  185. boost::fusion::tuple<int, int>(500, 400)
  186. )
  187. ));
  188. BOOST_TEST((
  189. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  190. boost::fusion::tuple<int, int, int>(500, 400, 100)
  191. , boost::fusion::tuple<convertible, int>(500, 400)
  192. )
  193. ));
  194. BOOST_TEST((
  195. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  196. boost::fusion::push_back(
  197. boost::fusion::tuple<int>(500), 400
  198. )
  199. )
  200. ));
  201. BOOST_TEST((
  202. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  203. boost::fusion::push_back(
  204. boost::fusion::tuple<int, int>(500, 400), 100
  205. )
  206. , boost::fusion::tuple<convertible, int>(500, 400)
  207. )
  208. ));
  209. BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::tuple<>())));
  210. BOOST_TEST((
  211. run< Scenario< FUSION_SEQUENCE<> > >(
  212. boost::tuple<int>(100), boost::tuple<>()
  213. )
  214. ));
  215. BOOST_TEST((
  216. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  217. boost::tuple<int>(500)
  218. )
  219. ));
  220. BOOST_TEST((
  221. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  222. boost::tuple<int, int>(500, 100)
  223. , boost::tuple<convertible>(500)
  224. )
  225. ));
  226. BOOST_TEST((
  227. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  228. boost::tuple<int, int>(500, 400)
  229. )
  230. ));
  231. BOOST_TEST((
  232. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  233. boost::tuple<int, int, int>(500, 400, 100)
  234. , boost::tuple<convertible, int>(500, 400)
  235. )
  236. ));
  237. BOOST_TEST((
  238. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  239. boost::fusion::push_back(boost::tuple<int>(500), 400)
  240. )
  241. ));
  242. BOOST_TEST((
  243. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  244. boost::fusion::push_back(
  245. boost::tuple<int, int>(500, 400), 100
  246. )
  247. , boost::tuple<convertible, int>(500, 400)
  248. )
  249. ));
  250. #if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
  251. && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  252. BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(std::tuple<>())));
  253. BOOST_TEST((
  254. run<Scenario<FUSION_SEQUENCE<> > >(std::tuple<int>(100), std::tuple<>())
  255. ));
  256. BOOST_TEST((
  257. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  258. std::tuple<int>(500)
  259. )
  260. ));
  261. BOOST_TEST((
  262. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  263. std::tuple<int, int>(500, 100)
  264. , std::tuple<convertible>(500)
  265. )
  266. ));
  267. BOOST_TEST((
  268. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  269. std::tuple<int, int>(500, 400)
  270. )
  271. ));
  272. BOOST_TEST((
  273. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  274. std::tuple<int, int, int>(500, 400, 100)
  275. , std::tuple<convertible, int>(500, 400)
  276. )
  277. ));
  278. BOOST_TEST((
  279. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  280. boost::fusion::push_back(std::tuple<int>(500), 400)
  281. )
  282. ));
  283. BOOST_TEST((
  284. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  285. boost::fusion::push_back(
  286. std::tuple<int, int>(500, 400), 100
  287. )
  288. , std::tuple<convertible, int>(500, 400)
  289. )
  290. ));
  291. #endif
  292. BOOST_TEST((
  293. run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
  294. std::pair<int, int>(500, 400)
  295. )
  296. ));
  297. BOOST_TEST((
  298. run< Scenario< FUSION_SEQUENCE<> > >(
  299. std::pair<int, int>(500, 400)
  300. , boost::fusion::vector<>()
  301. )
  302. ));
  303. BOOST_TEST((
  304. run< Scenario< FUSION_SEQUENCE<convertible> > >(
  305. std::pair<int, int>(500, 400)
  306. , boost::fusion::vector<convertible>(500)
  307. )
  308. ));
  309. }