test1.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // test1.h
  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. "test1"
  23. , L("foobarboo")
  24. , regex_type(as_xpr(L("foo")))
  25. , backrefs(L("foo"), nilbr)
  26. )
  27. , xpr_test_case
  28. (
  29. "test2"
  30. , L("foobarboo")
  31. , regex_type(as_xpr(L("bar")))
  32. , backrefs(L("bar"), nilbr)
  33. )
  34. , xpr_test_case
  35. (
  36. "test3"
  37. , L("foobarboo")
  38. , regex_type(as_xpr(L("bat")))
  39. , no_match
  40. )
  41. , xpr_test_case
  42. (
  43. "test4"
  44. , L("foobarboo")
  45. , regex_type(L('b') >> *_ >> L("ar"))
  46. , backrefs(L("bar"), nilbr)
  47. )
  48. , xpr_test_case
  49. (
  50. "test5"
  51. , L("foobarboo")
  52. , regex_type(L('b') >> *_ >> L('r'))
  53. , backrefs(L("bar"), nilbr)
  54. )
  55. , xpr_test_case
  56. (
  57. "test6"
  58. , L("foobarboo")
  59. , regex_type(L('b') >> *_ >> L('b'))
  60. , backrefs(L("barb"), nilbr)
  61. )
  62. , xpr_test_case
  63. (
  64. "test7"
  65. , L("foobarboo")
  66. , regex_type(L('b') >> *_ >> L('o'))
  67. , backrefs(L("barboo"), nilbr)
  68. )
  69. , xpr_test_case
  70. (
  71. "test8"
  72. , L("foobarboo")
  73. , regex_type(L('b') >> *_ >> L("oo"))
  74. , backrefs(L("barboo"), nilbr)
  75. )
  76. , xpr_test_case
  77. (
  78. "test9"
  79. , L("foobarboo")
  80. , regex_type(L('b') >> +_ >> L("ar"))
  81. , no_match
  82. )
  83. , xpr_test_case
  84. (
  85. "test10"
  86. , L("foobarboo")
  87. , regex_type(L('b') >> +_ >> L('r'))
  88. , backrefs(L("bar"), nilbr)
  89. )
  90. , xpr_test_case
  91. (
  92. "test11"
  93. , L("foobarboo")
  94. , regex_type(L('b') >> +_ >> L('b'))
  95. , backrefs(L("barb"), nilbr)
  96. )
  97. , xpr_test_case
  98. (
  99. "test12"
  100. , L("foobarboo")
  101. , regex_type(L('b') >> +_ >> L('o'))
  102. , backrefs(L("barboo"), nilbr)
  103. )
  104. , xpr_test_case
  105. (
  106. "test13"
  107. , L("foobarboo")
  108. , regex_type(L('b') >> +_ >> L("oo"))
  109. , backrefs(L("barboo"), nilbr)
  110. )
  111. , xpr_test_case
  112. (
  113. "test14"
  114. , L("foobarboo")
  115. , regex_type(bos >> L("foo"))
  116. , backrefs(L("foo"), nilbr)
  117. )
  118. , xpr_test_case
  119. (
  120. "test15"
  121. , L("foobarboo")
  122. , regex_type(bos >> L('b') >> *_ >> L("ar"))
  123. , no_match
  124. )
  125. , xpr_test_case
  126. (
  127. "test15.1"
  128. , L("fOo")
  129. , regex_type(!icase(L('f') >> *as_xpr(L('o'))))
  130. , backrefs(L("fOo"), nilbr)
  131. )
  132. };
  133. return boost::make_iterator_range(test_cases);
  134. }