ptr_size.pass.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // basic_regex(const charT* p, size_t len);
  11. #include <regex>
  12. #include <cassert>
  13. template <class CharT>
  14. void
  15. test(const CharT* p, std::size_t len, unsigned mc)
  16. {
  17. std::basic_regex<CharT> r(p, len);
  18. assert(r.flags() == std::regex_constants::ECMAScript);
  19. assert(r.mark_count() == mc);
  20. }
  21. int main(int, char**)
  22. {
  23. test("\\(a\\)", 5, 0);
  24. test("\\(a[bc]\\)", 9, 0);
  25. test("\\(a\\([bc]\\)\\)", 13, 0);
  26. test("(a([bc]))", 9, 2);
  27. test("(\0)(b)(c)(d)", 12, 4);
  28. test("(\0)(b)(c)(d)", 9, 3);
  29. test("(\0)(b)(c)(d)", 3, 1);
  30. test("(\0)(b)(c)(d)", 0, 0);
  31. return 0;
  32. }