test10.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test10.hpp
  3. //
  4. // Copyright 2008 Eric Niebler. Distributed under the Boost
  5. // Software License, Version 1.0. (See accompanying file
  6. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #include "./test.hpp"
  8. ///////////////////////////////////////////////////////////////////////////////
  9. // get_test_cases
  10. //
  11. template<typename BidiIterT>
  12. boost::iterator_range<xpr_test_case<BidiIterT> const *> get_test_cases()
  13. {
  14. typedef typename boost::iterator_value<BidiIterT>::type char_type;
  15. typedef xpr_test_case<BidiIterT> xpr_test_case;
  16. typedef basic_regex<BidiIterT> regex_type;
  17. static char_type const *nilbr = 0;
  18. static xpr_test_case const test_cases[] =
  19. {
  20. xpr_test_case
  21. (
  22. "test16"
  23. , L("foobarboo")
  24. , regex_type(L('b') >> +_ >> L("ar") >> eos)
  25. , no_match
  26. )
  27. , xpr_test_case
  28. (
  29. "test17"
  30. , L("foobarboo")
  31. , regex_type(L('b') >> +_ >> L('o') >> eos)
  32. , backrefs(L("barboo"), nilbr)
  33. )
  34. , xpr_test_case
  35. (
  36. "test18"
  37. , L("foobarboo")
  38. , regex_type(L('b') >> +_ >> L("oo") >> eos)
  39. , backrefs(L("barboo"), nilbr)
  40. )
  41. , xpr_test_case
  42. (
  43. "test19"
  44. , L("+1234.56789F")
  45. , regex_type(bos >> (s1= !(set=L('-'),L('+')) >> +range(L('0'),L('9'))
  46. >> !(s2= L('.') >> *range(L('0'),L('9'))))
  47. >> (s3= (set=L('C'),L('F'))) >> eos)
  48. , backrefs(L("+1234.56789F"), L("+1234.56789"), L(".56789"), L("F"), nilbr)
  49. )
  50. , xpr_test_case
  51. (
  52. "test20"
  53. , L("+1234.56789")
  54. , regex_type( !(s1= as_xpr(L('+'))|L('-')) >> (s2= +range(L('0'),L('9')) >> !as_xpr(L('.')) >> *range(L('0'),L('9')) |
  55. L('.') >> +range(L('0'),L('9'))) >> !(s3= (set=L('e'),L('E')) >> !(s4= as_xpr(L('+'))|L('-')) >> +range(L('0'),L('9'))))
  56. , backrefs(L("+1234.56789"), L("+"), L("1234.56789"), L(""), L(""), nilbr)
  57. )
  58. };
  59. return boost::make_iterator_range(test_cases);
  60. }