test_functions.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2009: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. /*-----------------------------------------------------------------------------+
  9. Auxiliary functions to reduce redundancies in test case code.
  10. +-----------------------------------------------------------------------------*/
  11. #ifndef BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003
  12. #define BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003
  13. #include <boost/icl/detail/notate.hpp>
  14. #include <boost/icl/type_traits/interval_type_default.hpp>
  15. #include <boost/icl/discrete_interval.hpp>
  16. #include <boost/icl/type_traits/identity_element.hpp>
  17. #include <boost/icl/functors.hpp>
  18. #include "portability.hpp"
  19. namespace boost{namespace icl
  20. {
  21. template <class T, class U, class Trt,
  22. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  23. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap,
  24. #else
  25. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap,
  26. #endif
  27. class SequenceT
  28. >
  29. void itl_map_copy(const SequenceT& segments,
  30. ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& destination)
  31. {
  32. ICL_const_FORALL(typename SequenceT, segment_, segments)
  33. destination.insert(*segment_);
  34. }
  35. template <class T, class U, class Trt,
  36. #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
  37. ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap,
  38. #else
  39. ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap,
  40. #endif
  41. class SequenceT
  42. >
  43. void test_interval_map_copy_via_inserter(const SequenceT& segments,
  44. ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& std_copied_map)
  45. {
  46. // The second parameter (std_copied_map) could be omitted and is only held as a
  47. // local variable. It is there to help gcc-3.4.4 resolving the function template type.
  48. typedef IntervalMap<T,U,Trt> IntervalMapT;
  49. IntervalMapT looped_copied_map;
  50. std_copied_map.clear();
  51. itl_map_copy(segments, looped_copied_map);
  52. std::copy(segments.begin(), segments.end(), std::inserter(std_copied_map, std_copied_map.end()));
  53. BOOST_CHECK_EQUAL( looped_copied_map, std_copied_map );
  54. }
  55. }} // namespace icl boost
  56. #endif // BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003