test_bimap_property_map.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // std
  18. #include <set>
  19. #include <map>
  20. #include <cstddef>
  21. #include <cassert>
  22. #include <algorithm>
  23. // Boost.Test
  24. #include <boost/test/minimal.hpp>
  25. // Boost.Bimap
  26. #include <boost/bimap/set_of.hpp>
  27. #include <boost/bimap/property_map/set_support.hpp>
  28. #include <boost/bimap/unordered_set_of.hpp>
  29. #include <boost/bimap/property_map/unordered_set_support.hpp>
  30. #include <boost/bimap/bimap.hpp>
  31. template <class Map>
  32. void test_readable_property_map(
  33. Map m,
  34. typename boost::property_traits<Map>:: key_type const & key,
  35. typename boost::property_traits<Map>::value_type const & value
  36. )
  37. {
  38. // TODO Add STATIC_ASSERT(
  39. // boost::property_traits<Map>::category is readable )
  40. BOOST_CHECK( get(m,key) == value );
  41. //BOOST_CHECK( m[key] == value );
  42. }
  43. void test_bimap_property_map()
  44. {
  45. using namespace boost::bimaps;
  46. typedef bimap< set_of<int>, unordered_set_of<double> > bm;
  47. bm b;
  48. b.insert( bm::value_type(1,0.1) );
  49. b.insert( bm::value_type(2,0.2) );
  50. b.insert( bm::value_type(3,0.3) );
  51. test_readable_property_map(b.left , 1,0.1);
  52. test_readable_property_map(b.right,0.1, 1);
  53. }
  54. int test_main( int, char* [] )
  55. {
  56. test_bimap_property_map();
  57. return 0;
  58. }