test4.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test4.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. // for testing recursive static regexes
  18. //regex_type parens = L('(') >> *( keep( +~(set=L('('),L(')')) ) | self ) >> L(')');
  19. regex_type parens;
  20. parens = L('(') >> *( keep( +~(set=L('('),L(')')) ) | by_ref(parens) ) >> L(')');
  21. static char_type const *nilbr = 0;
  22. static xpr_test_case const test_cases[] =
  23. {
  24. xpr_test_case
  25. (
  26. "test61"
  27. , L("this is sublist(now(is(the(time),for(all),good(men))to(come)))ok?")
  28. , regex_type(_b >> L("sublist") >> parens)
  29. , backrefs(L("sublist(now(is(the(time),for(all),good(men))to(come)))"), nilbr)
  30. )
  31. , xpr_test_case
  32. (
  33. "test62"
  34. , L("this is sublist(now(is(the(time),for(all),good(men))to(come))ok?")
  35. , regex_type(_b >> L("sublist") >> parens)
  36. , no_match
  37. )
  38. , xpr_test_case
  39. (
  40. "test63"
  41. , L("foobar")
  42. , regex_type(bos >> L("baz") | L("bar"))
  43. , backrefs(L("bar"), nilbr)
  44. )
  45. , xpr_test_case
  46. (
  47. "test69"
  48. , L("FooBarfoobar")
  49. , regex_type(icase(*_ >> L("foo")))
  50. , backrefs(L("FooBarfoo"), nilbr)
  51. )
  52. , xpr_test_case
  53. (
  54. "test70"
  55. , L("FooBarfoobar")
  56. , regex_type(icase(*_ >> L("boo")))
  57. , no_match
  58. )
  59. , xpr_test_case
  60. (
  61. "test71"
  62. , L("FooBarfoobar")
  63. , regex_type(icase(*_ >> L("boo") | L("bar")))
  64. , backrefs(L("Bar"), nilbr)
  65. )
  66. , xpr_test_case
  67. (
  68. "test72"
  69. , L("FooBarfoobar")
  70. , regex_type(icase(L("bar")))
  71. , backrefs(L("Bar"), nilbr)
  72. )
  73. , xpr_test_case
  74. (
  75. "test75"
  76. , L("fooooo")
  77. , regex_type(L('f') >> repeat<1,repeat_max>(L('o')))
  78. , backrefs(L("fooooo"), nilbr)
  79. )
  80. , xpr_test_case
  81. (
  82. "test78"
  83. , L("This (has) parens")
  84. , regex_type(L("This ") >> (s1= L("(has)")) >> L(' ') >> (s2= L("parens")))
  85. , backrefs(L("This (has) parens"), L("(has)"), L("parens"), nilbr)
  86. )
  87. , xpr_test_case
  88. (
  89. "test79"
  90. , L("This (has) parens")
  91. , regex_type(as_xpr(L("This (has) parens")))
  92. , backrefs(L("This (has) parens"), nilbr)
  93. )
  94. , xpr_test_case
  95. (
  96. "test80"
  97. , L("This (has) parens")
  98. , regex_type(as_xpr(L("This (has) parens")))
  99. , backrefs(L("This (has) parens"), nilbr)
  100. )
  101. };
  102. return boost::make_iterator_range(test_cases);
  103. }