test5.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test5.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. "test82"
  23. , L("abba1234abba")
  24. , regex_type(+_d)
  25. , backrefs(L("1234"), nilbr)
  26. )
  27. , xpr_test_case
  28. (
  29. "test83"
  30. , L("1234abba1234")
  31. , regex_type(+~_d)
  32. , backrefs(L("abba"), nilbr)
  33. )
  34. , xpr_test_case
  35. (
  36. "test84"
  37. , L("abba1234abba")
  38. , regex_type(+set[_d])
  39. , backrefs(L("1234"), nilbr)
  40. )
  41. , xpr_test_case
  42. (
  43. "test85"
  44. , L("1234abba1234")
  45. , regex_type(+set[~_d])
  46. , backrefs(L("abba"), nilbr)
  47. )
  48. , xpr_test_case
  49. (
  50. "test86"
  51. , L("abba1234abba")
  52. , regex_type(+~set[~_d])
  53. , backrefs(L("1234"), nilbr)
  54. )
  55. , xpr_test_case
  56. (
  57. "test87"
  58. , L("1234abba1234")
  59. , regex_type(+~set[_d])
  60. , backrefs(L("abba"), nilbr)
  61. )
  62. , xpr_test_case
  63. (
  64. "test88"
  65. , L("1234abba1234")
  66. , regex_type(+set[~_w | ~_d])
  67. , backrefs(L("abba"), nilbr)
  68. )
  69. , xpr_test_case
  70. (
  71. "test89"
  72. , L("1234(.;)abba")
  73. , regex_type(+~set[_w | _d])
  74. , backrefs(L("(.;)"), nilbr)
  75. )
  76. , xpr_test_case
  77. (
  78. "test90"
  79. , L("(boo[bar]baz)")
  80. , regex_type((s1= L('(') >> (s2= nil) | L('[') >> (s3= nil)) >> -*_ >> (s4= L(')') >> s2 | L(']') >> s3))
  81. , backrefs(L("(boo[bar]baz)"), L("("), L(""), L(""), L(")"), nilbr)
  82. )
  83. , xpr_test_case
  84. (
  85. "test91"
  86. , L("[boo(bar)baz]")
  87. , regex_type((s1= L('(') >> (s2= nil) | L('[') >> (s3= nil)) >> -*_ >> (s4= L(')') >> s2 | L(']') >> s3))
  88. , backrefs(L("[boo(bar)baz]"), L("["), L(""), L(""), L("]"), nilbr)
  89. )
  90. , xpr_test_case
  91. (
  92. "test91"
  93. , L("[boo[bar]baz]")
  94. , regex_type((s1= L('(') >> (s2= nil) | L('[') >> (s3= nil)) >> -*_ >> (s4= L(')') >> s2 | L(']') >> s3))
  95. , backrefs(L("[boo[bar]"), L("["), L(""), L(""), L("]"), nilbr)
  96. )
  97. , xpr_test_case
  98. (
  99. "test92"
  100. , L("foobarfoo")
  101. , regex_type(after(L("foo")) >> L("bar"))
  102. , backrefs(L("bar"), nilbr)
  103. )
  104. , xpr_test_case
  105. (
  106. "test93"
  107. , L("foobarfoo")
  108. , regex_type(after(s1= L('f') >> _ >> L('o')) >> L("bar"))
  109. , backrefs(L("bar"), L("foo"), nilbr)
  110. )
  111. , xpr_test_case
  112. (
  113. "test94"
  114. , L("foOoo")
  115. , regex_type(icase(after(s1= L("fo")) >> L('o')))
  116. , backrefs(L("O"), L("fo"), nilbr)
  117. )
  118. , xpr_test_case
  119. (
  120. "test95"
  121. , L("fOooo")
  122. , regex_type(icase(~after(s1= L("fo")) >> L('o')))
  123. , backrefs(L("O"), L(""), nilbr)
  124. )
  125. , xpr_test_case
  126. (
  127. "test96"
  128. , L("12foo12")
  129. , regex_type(+alpha)
  130. , backrefs(L("foo"), nilbr)
  131. )
  132. , xpr_test_case
  133. (
  134. "test97"
  135. , L(";12foo12;")
  136. , regex_type(+set[alpha | digit])
  137. , backrefs(L("12foo12"), nilbr)
  138. )
  139. , xpr_test_case
  140. (
  141. "test98"
  142. , L("aaaa")
  143. , regex_type(after(s1= nil) >> L('a'))
  144. , backrefs(L("a"), L(""), nilbr)
  145. )
  146. , xpr_test_case
  147. (
  148. "test99"
  149. , L("ABCabc123foo")
  150. , regex_type(after(s1= L("abc") >> repeat<3>(_d)) >> L("foo"))
  151. , backrefs(L("foo"), L("abc123"), nilbr)
  152. )
  153. };
  154. return boost::make_iterator_range(test_cases);
  155. }