blob: a61a410a444a9773185bdd993e80d98b20bd751d [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
Marshall Clow25a7ba42017-11-15 20:02:27 +000012// bool empty() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +000013
14#include <string>
15#include <cassert>
16
Marshall Clow25a7ba42017-11-15 20:02:27 +000017#include "test_macros.h"
Marshall Clowe34f6f62013-11-26 20:58:02 +000018#include "min_allocator.h"
Howard Hinnanteec72182013-06-28 16:59:19 +000019
Howard Hinnant3e519522010-05-11 19:42:16 +000020template <class S>
21void
22test(const S& s)
23{
Marshall Clow25a7ba42017-11-15 20:02:27 +000024 ASSERT_NOEXCEPT(s.empty());
Howard Hinnant3e519522010-05-11 19:42:16 +000025 assert(s.empty() == (s.size() == 0));
26}
27
28int main()
29{
Howard Hinnanteec72182013-06-28 16:59:19 +000030 {
Howard Hinnant3e519522010-05-11 19:42:16 +000031 typedef std::string S;
32 test(S());
33 test(S("123"));
34 test(S("12345678901234567890123456789012345678901234567890"));
Howard Hinnanteec72182013-06-28 16:59:19 +000035 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000036#if TEST_STD_VER >= 11
Howard Hinnanteec72182013-06-28 16:59:19 +000037 {
38 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
39 test(S());
40 test(S("123"));
41 test(S("12345678901234567890123456789012345678901234567890"));
42 }
43#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000044}