test_bimap_unconstrained.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // Boost.Test
  18. #include <boost/test/minimal.hpp>
  19. // Boost.Bimap
  20. #include <boost/bimap/support/lambda.hpp>
  21. #include <boost/bimap/bimap.hpp>
  22. void test_bimap_unconstrained()
  23. {
  24. using namespace boost::bimaps;
  25. {
  26. typedef bimap<int,double,unconstrained_set_of_relation> bm;
  27. bm b;
  28. b.left.insert( bm::left_value_type(2,34.4) );
  29. b.right.insert( bm::right_value_type(2.2,3) );
  30. }
  31. {
  32. typedef bimap<int,unconstrained_set_of<double> > bm;
  33. bm b;
  34. b.insert( bm::value_type(2,34.4) );
  35. BOOST_CHECK( b.size() == 1 );
  36. }
  37. {
  38. typedef bimap<unconstrained_set_of<int>, double > bm;
  39. bm b;
  40. b.right[2.4] = 34;
  41. BOOST_CHECK( b.right.size() == 1 );
  42. }
  43. {
  44. typedef bimap<unconstrained_set_of<int>, double, right_based > bm;
  45. bm b;
  46. b.right[2.4] = 34;
  47. BOOST_CHECK( b.right.size() == 1 );
  48. }
  49. {
  50. typedef bimap
  51. <
  52. int,
  53. unconstrained_set_of<double>,
  54. unconstrained_set_of_relation
  55. > bm;
  56. bm b;
  57. b.left[2] = 34.4;
  58. BOOST_CHECK( b.left.size() == 1 );
  59. }
  60. {
  61. typedef bimap
  62. <
  63. unconstrained_set_of<int>,
  64. double,
  65. unconstrained_set_of_relation
  66. > bm;
  67. bm b;
  68. b.right[2.4] = 34;
  69. BOOST_CHECK( b.right.size() == 1 );
  70. }
  71. {
  72. typedef bimap
  73. <
  74. unconstrained_set_of<int>,
  75. unconstrained_set_of<double>,
  76. set_of_relation<>
  77. > bm;
  78. bm b;
  79. b.insert( bm::value_type(1,2.3) );
  80. BOOST_CHECK( b.size() == 1 );
  81. }
  82. }
  83. int test_main( int, char* [] )
  84. {
  85. test_bimap_unconstrained();
  86. return 0;
  87. }