test_overloads.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. *
  3. * Copyright (c) 2004
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. #include "test.hpp"
  12. #define BOOST_REGEX_TEST(x)\
  13. if(!(x)){ BOOST_REGEX_TEST_ERROR("Error in: " BOOST_STRINGIZE(x), char); }
  14. void test_overloads()
  15. {
  16. test_info<char>::set_typename("sub_match operators");
  17. // test all the available overloads with *one* simple
  18. // expression, doing all these tests with all the test
  19. // cases would just take to long...
  20. boost::regex e("abc");
  21. std::string s("abc");
  22. const std::string& cs = s;
  23. boost::smatch sm;
  24. boost::cmatch cm;
  25. // regex_match:
  26. BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), sm, e))
  27. BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), sm, e, boost::regex_constants::match_default))
  28. BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), e))
  29. BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), e, boost::regex_constants::match_default))
  30. BOOST_REGEX_TEST(boost::regex_match(s.c_str(), cm, e))
  31. BOOST_REGEX_TEST(boost::regex_match(s.c_str(), cm, e, boost::regex_constants::match_default))
  32. BOOST_REGEX_TEST(boost::regex_match(s.c_str(), e))
  33. BOOST_REGEX_TEST(boost::regex_match(s.c_str(), e, boost::regex_constants::match_default))
  34. BOOST_REGEX_TEST(boost::regex_match(s, sm, e))
  35. BOOST_REGEX_TEST(boost::regex_match(s, sm, e, boost::regex_constants::match_default))
  36. BOOST_REGEX_TEST(boost::regex_match(s, e))
  37. BOOST_REGEX_TEST(boost::regex_match(s, e, boost::regex_constants::match_default))
  38. // regex_search:
  39. BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), sm, e))
  40. BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), sm, e, boost::regex_constants::match_default))
  41. BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), e))
  42. BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), e, boost::regex_constants::match_default))
  43. BOOST_REGEX_TEST(boost::regex_search(s.c_str(), cm, e))
  44. BOOST_REGEX_TEST(boost::regex_search(s.c_str(), cm, e, boost::regex_constants::match_default))
  45. BOOST_REGEX_TEST(boost::regex_search(s.c_str(), e))
  46. BOOST_REGEX_TEST(boost::regex_search(s.c_str(), e, boost::regex_constants::match_default))
  47. BOOST_REGEX_TEST(boost::regex_search(s, sm, e))
  48. BOOST_REGEX_TEST(boost::regex_search(s, sm, e, boost::regex_constants::match_default))
  49. BOOST_REGEX_TEST(boost::regex_search(s, e))
  50. BOOST_REGEX_TEST(boost::regex_search(s, e, boost::regex_constants::match_default))
  51. }