blob: e0254c0460e4fa67567cb8bd952a83f739df80f9 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// void clear();
13
14#include <string>
15#include <cassert>
16
Marshall Clowe34f6f62013-11-26 20:58:02 +000017#include "min_allocator.h"
Howard Hinnanteec72182013-06-28 16:59:19 +000018
Howard Hinnant3e519522010-05-11 19:42:16 +000019template <class S>
20void
21test(S s)
22{
23 s.clear();
24 assert(s.size() == 0);
25}
26
27int main()
28{
Howard Hinnanteec72182013-06-28 16:59:19 +000029 {
Howard Hinnant3e519522010-05-11 19:42:16 +000030 typedef std::string S;
31 S s;
32 test(s);
33
34 s.assign(10, 'a');
35 s.erase(5);
36 test(s);
37
38 s.assign(100, 'a');
39 s.erase(50);
40 test(s);
Howard Hinnanteec72182013-06-28 16:59:19 +000041 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000042#if TEST_STD_VER >= 11
Howard Hinnanteec72182013-06-28 16:59:19 +000043 {
44 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
45 S s;
46 test(s);
47
48 s.assign(10, 'a');
49 s.erase(5);
50 test(s);
51
52 s.assign(100, 'a');
53 s.erase(50);
54 test(s);
55 }
56#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000057}