blob: 348ded349d58ad1d7b104629e0436f1fbce9eb03 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
3// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// iterator erase(const_iterator p);
13
14#include <string>
15#include <cassert>
16
17template <class S>
18void
19test(S s, typename S::difference_type pos, S expected)
20{
21 typename S::const_iterator p = s.begin() + pos;
22 typename S::iterator i = s.erase(p);
23 assert(s.__invariants());
24 assert(s == expected);
25 assert(i - s.begin() == pos);
26}
27
28int main()
29{
30 typedef std::string S;
31 test(S("abcde"), 0, S("bcde"));
32 test(S("abcde"), 1, S("acde"));
33 test(S("abcde"), 2, S("abde"));
34 test(S("abcde"), 4, S("abcd"));
35 test(S("abcdefghij"), 0, S("bcdefghij"));
36 test(S("abcdefghij"), 1, S("acdefghij"));
37 test(S("abcdefghij"), 5, S("abcdeghij"));
38 test(S("abcdefghij"), 9, S("abcdefghi"));
39 test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
40 test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
41 test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
42 test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
43}