Marshall Clow | 053d81c | 2016-07-21 05:31:24 +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 |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | |
| 10 | // <string_view> |
| 11 | |
| 12 | // constexpr basic_string_view () noexcept; |
| 13 | |
| 14 | #include <string_view> |
| 15 | #include <cassert> |
| 16 | |
Stephan T. Lavavej | 0f901c7 | 2016-11-04 20:26:59 +0000 | [diff] [blame] | 17 | #include "test_macros.h" |
| 18 | |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 19 | template<typename T> |
| 20 | void test () { |
Stephan T. Lavavej | 0f901c7 | 2016-11-04 20:26:59 +0000 | [diff] [blame] | 21 | #if TEST_STD_VER > 11 |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 22 | { |
Marshall Clow | ac2b3e3 | 2017-10-24 16:30:06 +0000 | [diff] [blame] | 23 | ASSERT_NOEXCEPT(T()); |
| 24 | |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 25 | constexpr T sv1; |
| 26 | static_assert ( sv1.size() == 0, "" ); |
| 27 | static_assert ( sv1.empty(), ""); |
| 28 | } |
| 29 | #endif |
| 30 | |
| 31 | { |
| 32 | T sv1; |
| 33 | assert ( sv1.size() == 0 ); |
| 34 | assert ( sv1.empty()); |
| 35 | } |
| 36 | } |
| 37 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 38 | int main(int, char**) { |
Marshall Clow | 7dad0bd | 2018-12-11 04:35:44 +0000 | [diff] [blame] | 39 | test<std::string_view> (); |
| 40 | test<std::u16string_view> (); |
| 41 | #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L |
| 42 | test<std::u8string_view> (); |
| 43 | #endif |
| 44 | test<std::u32string_view> (); |
| 45 | test<std::wstring_view> (); |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 46 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 47 | |
| 48 | return 0; |
Marshall Clow | 053d81c | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 49 | } |