string.pass.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 charT, class traits = regex_traits<charT>> class basic_regex;
  10. // template <class ST, class SA>
  11. // basic_regex(const basic_string<charT, ST, SA>& s);
  12. #include <regex>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. template <class String>
  16. void
  17. test(const String& p, unsigned mc)
  18. {
  19. std::basic_regex<typename String::value_type> r(p);
  20. assert(r.flags() == std::regex_constants::ECMAScript);
  21. assert(r.mark_count() == mc);
  22. }
  23. int main(int, char**)
  24. {
  25. test(std::string("\\(a\\)"), 0);
  26. test(std::string("\\(a[bc]\\)"), 0);
  27. test(std::string("\\(a\\([bc]\\)\\)"), 0);
  28. test(std::string("(a([bc]))"), 2);
  29. return 0;
  30. }