no_update_pos.pass.cpp 1.2 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 BidirectionalIterator, class Allocator, class charT, class traits>
  10. // bool
  11. // regex_search(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. #include <regex>
  16. #include <cassert>
  17. #include "test_macros.h"
  18. int main(int, char**)
  19. {
  20. // Iterating over /^a/ should yield one instance at the beginning
  21. // of the text.
  22. const char *text = "aaa\naa";
  23. std::regex re("^a");
  24. std::cregex_iterator it(text, text+6, re);
  25. std::cregex_iterator end = std::cregex_iterator();
  26. assert(it->str() == "a");
  27. assert(it->position(0) == 0);
  28. assert(it->length(0) == 1);
  29. ++it;
  30. assert(it == end);
  31. return 0;
  32. }