test_bimap_unordered.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  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. // VC++ 8.0 warns on usage of certain Standard Library and API functions that
  9. // can be cause buffer overruns or other possible security issues if misused.
  10. // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
  11. // But the wording of the warning is misleading and unsettling, there are no
  12. // portable alternative functions, and VC++ 8.0's own libraries use the
  13. // functions in question. So turn off the warnings.
  14. #define _CRT_SECURE_NO_DEPRECATE
  15. #define _SCL_SECURE_NO_DEPRECATE
  16. #include <boost/config.hpp>
  17. #define BOOST_BIMAP_DISABLE_SERIALIZATION
  18. // Boost.Test
  19. #include <boost/test/minimal.hpp>
  20. // std
  21. #include <set>
  22. #include <map>
  23. #include <string>
  24. #include <functional>
  25. // Set type specifications
  26. #include <boost/bimap/unordered_set_of.hpp>
  27. #include <boost/bimap/unordered_multiset_of.hpp>
  28. // bimap container
  29. #include <boost/bimap/bimap.hpp>
  30. #include <libs/bimap/test/test_bimap.hpp>
  31. struct left_tag {};
  32. struct right_tag {};
  33. void test_bimap()
  34. {
  35. using namespace boost::bimaps;
  36. typedef std::map<char,std::string> left_data_type;
  37. left_data_type left_data;
  38. left_data.insert( left_data_type::value_type('a',"a") );
  39. left_data.insert( left_data_type::value_type('b',"b") );
  40. left_data.insert( left_data_type::value_type('c',"c") );
  41. left_data.insert( left_data_type::value_type('d',"e") );
  42. typedef std::map<std::string,char> right_data_type;
  43. right_data_type right_data;
  44. right_data.insert( right_data_type::value_type("a",'a') );
  45. right_data.insert( right_data_type::value_type("b",'b') );
  46. right_data.insert( right_data_type::value_type("c",'c') );
  47. right_data.insert( right_data_type::value_type("d",'e') );
  48. //--------------------------------------------------------------------
  49. {
  50. typedef bimap<
  51. unordered_set_of<char>, unordered_multiset_of<std::string>
  52. > bm_type;
  53. std::set< bm_type::value_type > data;
  54. data.insert( bm_type::value_type('a',"a") );
  55. data.insert( bm_type::value_type('b',"b") );
  56. data.insert( bm_type::value_type('c',"c") );
  57. data.insert( bm_type::value_type('d',"d") );
  58. bm_type bm;
  59. test_unordered_set_unordered_multiset_bimap(
  60. bm,data,left_data,right_data
  61. );
  62. }
  63. //--------------------------------------------------------------------
  64. //--------------------------------------------------------------------
  65. {
  66. typedef bimap<
  67. unordered_set_of< tagged< char , left_tag > >,
  68. unordered_multiset_of< tagged< std::string, right_tag > >
  69. > bm_type;
  70. std::set< bm_type::value_type > data;
  71. data.insert( bm_type::value_type('a',"a") );
  72. data.insert( bm_type::value_type('b',"b") );
  73. data.insert( bm_type::value_type('c',"c") );
  74. data.insert( bm_type::value_type('d',"d") );
  75. bm_type bm;
  76. test_unordered_set_unordered_multiset_bimap(
  77. bm,data,left_data,right_data
  78. );
  79. test_tagged_bimap<left_tag,right_tag>(bm,data);
  80. }
  81. //--------------------------------------------------------------------
  82. //--------------------------------------------------------------------
  83. {
  84. typedef bimap
  85. <
  86. set_of< char, std::greater<char> >,
  87. unordered_multiset_of<std::string>,
  88. unordered_set_of_relation<>
  89. > bm_type;
  90. std::set< bm_type::value_type > data;
  91. data.insert( bm_type::value_type('a',"a") );
  92. data.insert( bm_type::value_type('b',"b") );
  93. data.insert( bm_type::value_type('c',"c") );
  94. data.insert( bm_type::value_type('d',"d") );
  95. bm_type bm;
  96. test_basic_bimap(bm,data,left_data,right_data);
  97. test_associative_container(bm,data);
  98. test_simple_unordered_associative_container(bm,data);
  99. }
  100. //--------------------------------------------------------------------
  101. //--------------------------------------------------------------------
  102. {
  103. typedef bimap
  104. <
  105. unordered_multiset_of< char >,
  106. unordered_multiset_of< std::string >,
  107. unordered_multiset_of_relation<>
  108. > bm_type;
  109. std::set< bm_type::value_type > data;
  110. data.insert( bm_type::value_type('a',"a") );
  111. data.insert( bm_type::value_type('b',"b") );
  112. data.insert( bm_type::value_type('c',"c") );
  113. data.insert( bm_type::value_type('d',"d") );
  114. bm_type bm;
  115. test_basic_bimap(bm,data,left_data,right_data);
  116. test_associative_container(bm,data);
  117. test_simple_unordered_associative_container(bm,data);
  118. }
  119. //--------------------------------------------------------------------
  120. }
  121. int test_main( int, char* [] )
  122. {
  123. test_bimap();
  124. return 0;
  125. }