test7.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test7.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. "test127"
  23. , L("foobar")
  24. , regex_type(as_xpr(L("foo")) >> /*This is a comment[*/ L("bar"))
  25. , backrefs(L("foobar"), nilbr)
  26. )
  27. , xpr_test_case
  28. (
  29. "test128"
  30. , L("foobar")
  31. , regex_type(bos >> L("foobar") >> eos)
  32. , backrefs(L("foobar"), nilbr)
  33. )
  34. , xpr_test_case
  35. (
  36. "test129"
  37. , L("foobar")
  38. , regex_type(bos >> L('f') >> *as_xpr(L('o')))
  39. , backrefs(L("foo"), nilbr)
  40. )
  41. , xpr_test_case
  42. (
  43. "test129.1"
  44. , L("foobar")
  45. , regex_type(bos >> L('f') >> *as_xpr(L('\157')))
  46. , backrefs(L("foo"), nilbr)
  47. )
  48. , xpr_test_case
  49. (
  50. "test130"
  51. , L("foo bar")
  52. , regex_type(bos >> L("foo bar") >> eos)
  53. , backrefs(L("foo bar"), nilbr)
  54. )
  55. , xpr_test_case
  56. (
  57. "test131"
  58. , L("foo bar")
  59. , regex_type(bos >> L("foo") >> set[L(' ')] >> L("bar") >> eos)
  60. , backrefs(L("foo bar"), nilbr)
  61. )
  62. , xpr_test_case
  63. (
  64. "test132"
  65. , L("foo bar")
  66. , regex_type(bos >> (L("foo") >> set[L(' ')] >> L("bar")) >> eos /*This is a comment*/)
  67. , backrefs(L("foo bar"), nilbr)
  68. )
  69. , xpr_test_case
  70. (
  71. "test133"
  72. , L("foo bar")
  73. , regex_type(bos >> L("foo") >> set[L(' ')] >> L("bar") /*This is a comment*/)
  74. , backrefs(L("foo bar"), nilbr)
  75. )
  76. , xpr_test_case
  77. (
  78. "test134"
  79. , L("foo bar#Thisisnotacomment")
  80. , regex_type(bos >> L("foo") >> set[L(' ')] >> L("bar#Thisisnotacomment"))
  81. , backrefs(L("foo bar#Thisisnotacomment"), nilbr)
  82. )
  83. , xpr_test_case
  84. (
  85. "test135"
  86. , L("f oo b ar")
  87. , regex_type(bos >> L("f oo b ar"))
  88. , backrefs(L("f oo b ar"), nilbr)
  89. )
  90. , xpr_test_case
  91. (
  92. "test137"
  93. , L("a--")
  94. , regex_type(bos >> *(s1= optional(L('a'))) >> eos)
  95. , no_match
  96. )
  97. , xpr_test_case
  98. (
  99. "test138"
  100. , L("a--")
  101. , regex_type(bos >> -*(s1= optional(L('a'))) >> eos)
  102. , no_match
  103. )
  104. , xpr_test_case
  105. (
  106. "test139"
  107. , L("bc")
  108. , regex_type(bos >> repeat<2>(s1= optional(L('b'))) >> L("bc") >> eos)
  109. , backrefs(L("bc"), L(""), nilbr)
  110. )
  111. , xpr_test_case
  112. (
  113. "test140"
  114. , L("bbc")
  115. , regex_type(bos >> repeat<2>(s1= optional(L('b'))) >> L("bc") >> eos)
  116. , backrefs(L("bbc"), L(""), nilbr)
  117. )
  118. };
  119. return boost::make_iterator_range(test_cases);
  120. }