ptr_size.pass.cpp 1.1 KB

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