assign_iter_iter_flag.pass.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 InputIterator>
  11. // basic_regex&
  12. // assign(InputIterator first, InputIterator last,
  13. // flag_type f = regex_constants::ECMAScript);
  14. #include <regex>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "test_iterators.h"
  18. int main(int, char**)
  19. {
  20. typedef input_iterator<std::string::const_iterator> I;
  21. typedef forward_iterator<std::string::const_iterator> F;
  22. std::string s4("(a([bc]))");
  23. std::regex r2;
  24. r2.assign(I(s4.begin()), I(s4.end()));
  25. assert(r2.flags() == std::regex::ECMAScript);
  26. assert(r2.mark_count() == 2);
  27. r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
  28. assert(r2.flags() == std::regex::extended);
  29. assert(r2.mark_count() == 2);
  30. r2.assign(F(s4.begin()), F(s4.end()));
  31. assert(r2.flags() == std::regex::ECMAScript);
  32. assert(r2.mark_count() == 2);
  33. r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
  34. assert(r2.flags() == std::regex::extended);
  35. assert(r2.mark_count() == 2);
  36. return 0;
  37. }