ticket_6715_iterator_range_equality.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Boost.Range library
  2. //
  3. // Copyright Neil Groves 2014. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. //
  9. // For more information, see http://www.boost.org/libs/range/
  10. //
  11. #include <boost/range/iterator_range_core.hpp>
  12. #include <boost/test/test_tools.hpp>
  13. #include <boost/test/unit_test.hpp>
  14. #include <string>
  15. namespace boost
  16. {
  17. namespace
  18. {
  19. class str_ref : public boost::iterator_range<const char*>
  20. {
  21. public:
  22. explicit str_ref(const std::string& str)
  23. : boost::iterator_range<const char*>(
  24. str.c_str(), str.c_str() + str.size())
  25. {
  26. }
  27. };
  28. void test_ticket_6715_iterator_range_equality()
  29. {
  30. std::string src("test");
  31. str_ref a(src);
  32. str_ref b(src);
  33. BOOST_CHECK(a == b);
  34. }
  35. }
  36. }
  37. boost::unit_test::test_suite*
  38. init_unit_test_suite(int argc, char* argv[])
  39. {
  40. boost::unit_test::test_suite* test
  41. = BOOST_TEST_SUITE(
  42. "RangeTestSuite.ticket_6715_iterator_range_equality");
  43. test->add(BOOST_TEST_CASE(
  44. &boost::test_ticket_6715_iterator_range_equality));
  45. return test;
  46. }