sg_multiset_test.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2007-2013
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #include <boost/intrusive/sg_set.hpp>
  13. #include "itestvalue.hpp"
  14. #include "bptr_value.hpp"
  15. #include "smart_ptr.hpp"
  16. #include "bs_test_common.hpp"
  17. #include "generic_multiset_test.hpp"
  18. using namespace boost::intrusive;
  19. template < class ValueTraits, bool FloatingPoint, bool DefaultHolder, bool Map >
  20. struct rebinder
  21. {
  22. typedef tree_rebinder_common<ValueTraits, DefaultHolder, Map> common_t;
  23. typedef typename ValueContainer< typename ValueTraits::value_type >::type value_cont_type;
  24. template < class Option1 =void
  25. , class Option2 =void
  26. >
  27. struct container
  28. {
  29. typedef sg_multiset
  30. < typename common_t::value_type
  31. , value_traits<ValueTraits>
  32. , floating_point<FloatingPoint>
  33. , typename common_t::holder_opt
  34. , typename common_t::key_of_value_opt
  35. , Option1
  36. , Option2
  37. > type;
  38. BOOST_STATIC_ASSERT((key_type_tester<typename common_t::key_of_value_opt, type>::value));
  39. };
  40. };
  41. enum HookType
  42. {
  43. Base,
  44. Member,
  45. NonMember
  46. };
  47. template<class VoidPointer, bool FloatingPoint, bool DefaultHolder, bool Map, HookType Type>
  48. class test_main_template;
  49. template<class VoidPointer, bool FloatingPoint, bool DefaultHolder, bool Map>
  50. class test_main_template<VoidPointer, FloatingPoint, DefaultHolder, Map, Base>
  51. {
  52. public:
  53. static void execute()
  54. {
  55. typedef testvalue_traits< bs_hooks<VoidPointer> > testval_traits_t;
  56. //base
  57. typedef typename testval_traits_t::base_value_traits base_hook_t;
  58. test::test_generic_multiset
  59. < rebinder<base_hook_t, FloatingPoint, DefaultHolder, Map>
  60. >::test_all();
  61. }
  62. };
  63. template<class VoidPointer, bool FloatingPoint, bool DefaultHolder, bool Map>
  64. class test_main_template<VoidPointer, FloatingPoint, DefaultHolder, Map, Member>
  65. {
  66. public:
  67. static void execute()
  68. {
  69. typedef testvalue_traits< bs_hooks<VoidPointer> > testval_traits_t;
  70. //member
  71. typedef typename testval_traits_t::member_value_traits member_hook_t;
  72. test::test_generic_multiset
  73. < rebinder<member_hook_t, FloatingPoint, DefaultHolder, Map>
  74. >::test_all();
  75. }
  76. };
  77. template<class VoidPointer, bool FloatingPoint, bool DefaultHolder, bool Map>
  78. class test_main_template<VoidPointer, FloatingPoint, DefaultHolder, Map, NonMember>
  79. {
  80. public:
  81. static void execute()
  82. {
  83. typedef testvalue_traits< bs_hooks<VoidPointer> > testval_traits_t;
  84. //nonmember
  85. test::test_generic_multiset
  86. < rebinder<typename testval_traits_t::nonhook_value_traits, FloatingPoint, DefaultHolder, Map>
  87. >::test_all();
  88. }
  89. };
  90. template < bool FloatingPoint, bool Map >
  91. struct test_main_template_bptr
  92. {
  93. static void execute()
  94. {
  95. typedef BPtr_Value_Traits< Tree_BPtr_Node_Traits > value_traits;
  96. typedef bounded_allocator< BPtr_Value > allocator_type;
  97. bounded_allocator_scope<allocator_type> bounded_scope; (void)bounded_scope;
  98. test::test_generic_multiset
  99. < rebinder< value_traits, FloatingPoint, true, Map>
  100. >::test_all();
  101. }
  102. };
  103. int main()
  104. {
  105. //Combinations: VoidPointer x FloatingPoint x DefaultHolder x Map
  106. //Minimize them selecting different combinations for raw and smart pointers
  107. //Start with ('false', 'false', 'false') in sets and 'false', 'false', 'true' in multisets
  108. //void pointer
  109. test_main_template<void*, false, false, false, Base>::execute();
  110. //test_main_template<void*, false, false, true>::execute();
  111. test_main_template<void*, false, true, false, Member>::execute();
  112. //test_main_template<void*, false, true, true>::execute();
  113. test_main_template<void*, true, false, false, Base>::execute();
  114. //test_main_template<void*, true, false, true>::execute();
  115. test_main_template<void*, true, true, false, Member>::execute();
  116. test_main_template<void*, true, true, true, NonMember>::execute();
  117. //smart_ptr
  118. //test_main_template<smart_ptr<void>, false, false, false>::execute();
  119. test_main_template<smart_ptr<void>, false, false, true, Base>::execute();
  120. //test_main_template<smart_ptr<void>, false, true, false>::execute();
  121. test_main_template<smart_ptr<void>, false, true, true, Member>::execute();
  122. //test_main_template<smart_ptr<void>, true, false, false>::execute();
  123. test_main_template<smart_ptr<void>, true, false, true, NonMember>::execute();
  124. //test_main_template<smart_ptr<void>, true, true, false>::execute();
  125. //test_main_template<smart_ptr<void>, true, true, true>::execute();
  126. //bounded_ptr (bool FloatingPoint, bool Map)
  127. test_main_template_bptr< false, false >::execute();
  128. //test_main_template_bptr< false, true >::execute();
  129. //test_main_template_bptr< true, false >::execute();
  130. test_main_template_bptr< true, true >::execute();
  131. return boost::report_errors();
  132. }