Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <string> |
| 10 | |
Marshall Clow | 25a7ba4 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 11 | // bool empty() const noexcept; |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 12 | |
| 13 | #include <string> |
| 14 | #include <cassert> |
| 15 | |
Marshall Clow | 25a7ba4 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 16 | #include "test_macros.h" |
Marshall Clow | e34f6f6 | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 17 | #include "min_allocator.h" |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 18 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | template <class S> |
| 20 | void |
| 21 | test(const S& s) |
| 22 | { |
Marshall Clow | 25a7ba4 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 23 | ASSERT_NOEXCEPT(s.empty()); |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | assert(s.empty() == (s.size() == 0)); |
| 25 | } |
| 26 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame^] | 27 | int main(int, char**) |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 28 | { |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 29 | { |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | typedef std::string S; |
| 31 | test(S()); |
| 32 | test(S("123")); |
| 33 | test(S("12345678901234567890123456789012345678901234567890")); |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 34 | } |
Eric Fiselier | f2f2a63 | 2016-06-14 21:31:42 +0000 | [diff] [blame] | 35 | #if TEST_STD_VER >= 11 |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 36 | { |
| 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 Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame^] | 43 | |
| 44 | return 0; |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | } |