parse_curly_brackets.pass.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <regex>
  9. // template <class BidirectionalIterator, class Allocator, class charT, class traits>
  10. // bool
  11. // regex_match(BidirectionalIterator first, BidirectionalIterator last,
  12. // match_results<BidirectionalIterator, Allocator>& m,
  13. // const basic_regex<charT, traits>& e,
  14. // regex_constants::match_flag_type flags = regex_constants::match_default);
  15. // https://bugs.llvm.org/show_bug.cgi?id=16135
  16. #include <string>
  17. #include <regex>
  18. #include <cassert>
  19. #include "test_macros.h"
  20. void
  21. test1()
  22. {
  23. std::string re("\\{a\\}");
  24. std::string target("{a}");
  25. std::regex regex(re);
  26. std::smatch smatch;
  27. assert((std::regex_match(target, smatch, regex)));
  28. }
  29. void
  30. test2()
  31. {
  32. std::string re("\\{a\\}");
  33. std::string target("{a}");
  34. std::regex regex(re, std::regex::extended);
  35. std::smatch smatch;
  36. assert((std::regex_match(target, smatch, regex)));
  37. }
  38. void
  39. test3()
  40. {
  41. std::string re("\\{a\\}");
  42. std::string target("{a}");
  43. std::regex regex(re, std::regex::awk);
  44. std::smatch smatch;
  45. assert((std::regex_match(target, smatch, regex)));
  46. }
  47. void
  48. test4()
  49. {
  50. std::string re("\\{a\\}");
  51. std::string target("{a}");
  52. std::regex regex(re, std::regex::egrep);
  53. std::smatch smatch;
  54. assert((std::regex_match(target, smatch, regex)));
  55. }
  56. int main(int, char**)
  57. {
  58. test1();
  59. test2();
  60. test3();
  61. test4();
  62. return 0;
  63. }