blob: 47827db7f75c1714d27b138a241300374d768057 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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
Howard Hinnant3e519522010-05-11 19:42:16 +00006//
7//===----------------------------------------------------------------------===//
8
9// <string>
10
Marshall Clow25a7ba42017-11-15 20:02:27 +000011// bool empty() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +000012
13#include <string>
14#include <cassert>
15
Marshall Clow25a7ba42017-11-15 20:02:27 +000016#include "test_macros.h"
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(const S& s)
22{
Marshall Clow25a7ba42017-11-15 20:02:27 +000023 ASSERT_NOEXCEPT(s.empty());
Howard Hinnant3e519522010-05-11 19:42:16 +000024 assert(s.empty() == (s.size() == 0));
25}
26
JF Bastien2df59c52019-02-04 20:31:13 +000027int main(int, char**)
Howard Hinnant3e519522010-05-11 19:42:16 +000028{
Howard Hinnanteec72182013-06-28 16:59:19 +000029 {
Howard Hinnant3e519522010-05-11 19:42:16 +000030 typedef std::string S;
31 test(S());
32 test(S("123"));
33 test(S("12345678901234567890123456789012345678901234567890"));
Howard Hinnanteec72182013-06-28 16:59:19 +000034 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000035#if TEST_STD_VER >= 11
Howard Hinnanteec72182013-06-28 16:59:19 +000036 {
37 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
38 test(S());
39 test(S("123"));
40 test(S("12345678901234567890123456789012345678901234567890"));
41 }
42#endif
JF Bastien2df59c52019-02-04 20:31:13 +000043
44 return 0;
Howard Hinnant3e519522010-05-11 19:42:16 +000045}