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 9 // <string> 10 11 // Add to iterator out of bounds. 12 13 // REQUIRES: has-unix-headers 14 // UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03 15 16 #include <string> 17 #include <cassert> 18 19 #include "check_assertion.h" 20 #include "min_allocator.h" 21 22 template <class C> test()23void test() { 24 C c(1, '\0'); 25 typename C::iterator i = c.begin(); 26 i += 1; 27 assert(i == c.end()); 28 i = c.begin(); 29 TEST_LIBCPP_ASSERT_FAILURE(i += 2, "Attempted to add/subtract an iterator outside its valid range"); 30 } 31 main(int,char **)32int main(int, char**) { 33 test<std::string>(); 34 test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >(); 35 36 return 0; 37 } 38