test6.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test6.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. "test103"
  23. , L("a\nxb\n")
  24. , regex_type(~before(bol) >> L('x'))
  25. , no_match
  26. )
  27. , xpr_test_case
  28. (
  29. "test104"
  30. , L("a\nxb\n")
  31. , regex_type(~before(bos) >> L('x'))
  32. , backrefs(L("x"), nilbr)
  33. )
  34. , xpr_test_case
  35. (
  36. "test105"
  37. , L("a\nxb\n")
  38. , regex_type(~before(bos) >> L('x'))
  39. , backrefs(L("x"), nilbr)
  40. )
  41. , xpr_test_case
  42. (
  43. "test106"
  44. , L("(this)")
  45. , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos)
  46. , backrefs(L("(this)"), L(""), L(""), nilbr)
  47. )
  48. , xpr_test_case
  49. (
  50. "test107"
  51. , L("this")
  52. , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos)
  53. , backrefs(L("this"), L(""), L(""), nilbr)
  54. )
  55. , xpr_test_case
  56. (
  57. "test108"
  58. , L("this)")
  59. , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos)
  60. , no_match
  61. )
  62. , xpr_test_case
  63. (
  64. "test109"
  65. , L("(this")
  66. , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos)
  67. , no_match
  68. )
  69. , xpr_test_case
  70. (
  71. "test110"
  72. , L("abba123abba")
  73. , regex_type(+~alpha)
  74. , backrefs(L("123"), nilbr)
  75. )
  76. , xpr_test_case
  77. (
  78. "test111"
  79. , L("abba123abba")
  80. , regex_type(+set[alpha | ~alpha])
  81. , backrefs(L("abba123abba"), nilbr)
  82. )
  83. , xpr_test_case
  84. (
  85. "test112"
  86. , L("123abba123")
  87. , regex_type(+~set[~alpha])
  88. , backrefs(L("abba"), nilbr)
  89. )
  90. //, xpr_test_case
  91. // (
  92. // "test113"
  93. // , L("123abba123")
  94. // , regex_type(as_xpr(L("[[:alpha:]\\y]+")))
  95. // , backrefs(L("123abba123"), nilbr)
  96. // )
  97. , xpr_test_case
  98. (
  99. "test114"
  100. , L("abba123abba")
  101. , regex_type(+~set[~alnum | ~digit])
  102. , backrefs(L("123"), nilbr)
  103. )
  104. , xpr_test_case
  105. (
  106. "test115"
  107. , L("aaaaA")
  108. , regex_type(icase(bos >> repeat<4>(s1= L('a') >> !s1) >> eos))
  109. , backrefs(L("aaaaA"), L("A"), nilbr)
  110. )
  111. , xpr_test_case
  112. (
  113. "test116"
  114. , L("aaaaAa")
  115. , regex_type(icase(bos >> repeat<4>(s1= L('a') >> !s1) >> eos))
  116. , backrefs(L("aaaaAa"), L("Aa"), nilbr)
  117. )
  118. };
  119. return boost::make_iterator_range(test_cases);
  120. }