1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// WARNING: This test was generated by generate_feature_test_macro_components.py
10// and should not be edited manually.
11
12// <string_view>
13
14// Test the feature test macros defined by <string_view>
15
16// clang-format off
17
18#include <string_view>
19#include "test_macros.h"
20
21#if TEST_STD_VER < 14
22
23# ifdef __cpp_lib_char8_t
24# error "__cpp_lib_char8_t should not be defined before c++20"
25# endif
26
27# ifdef __cpp_lib_constexpr_string_view
28# error "__cpp_lib_constexpr_string_view should not be defined before c++20"
29# endif
30
31# ifdef __cpp_lib_freestanding_string_view
32# error "__cpp_lib_freestanding_string_view should not be defined before c++26"
33# endif
34
35# ifdef __cpp_lib_starts_ends_with
36# error "__cpp_lib_starts_ends_with should not be defined before c++20"
37# endif
38
39# ifdef __cpp_lib_string_contains
40# error "__cpp_lib_string_contains should not be defined before c++23"
41# endif
42
43# ifdef __cpp_lib_string_view
44# error "__cpp_lib_string_view should not be defined before c++17"
45# endif
46
47#elif TEST_STD_VER == 14
48
49# ifdef __cpp_lib_char8_t
50# error "__cpp_lib_char8_t should not be defined before c++20"
51# endif
52
53# ifdef __cpp_lib_constexpr_string_view
54# error "__cpp_lib_constexpr_string_view should not be defined before c++20"
55# endif
56
57# ifdef __cpp_lib_freestanding_string_view
58# error "__cpp_lib_freestanding_string_view should not be defined before c++26"
59# endif
60
61# ifdef __cpp_lib_starts_ends_with
62# error "__cpp_lib_starts_ends_with should not be defined before c++20"
63# endif
64
65# ifdef __cpp_lib_string_contains
66# error "__cpp_lib_string_contains should not be defined before c++23"
67# endif
68
69# ifdef __cpp_lib_string_view
70# error "__cpp_lib_string_view should not be defined before c++17"
71# endif
72
73#elif TEST_STD_VER == 17
74
75# ifdef __cpp_lib_char8_t
76# error "__cpp_lib_char8_t should not be defined before c++20"
77# endif
78
79# ifdef __cpp_lib_constexpr_string_view
80# error "__cpp_lib_constexpr_string_view should not be defined before c++20"
81# endif
82
83# ifdef __cpp_lib_freestanding_string_view
84# error "__cpp_lib_freestanding_string_view should not be defined before c++26"
85# endif
86
87# ifdef __cpp_lib_starts_ends_with
88# error "__cpp_lib_starts_ends_with should not be defined before c++20"
89# endif
90
91# ifdef __cpp_lib_string_contains
92# error "__cpp_lib_string_contains should not be defined before c++23"
93# endif
94
95# ifndef __cpp_lib_string_view
96# error "__cpp_lib_string_view should be defined in c++17"
97# endif
98# if __cpp_lib_string_view != 201606L
99# error "__cpp_lib_string_view should have the value 201606L in c++17"
100# endif
101
102#elif TEST_STD_VER == 20
103
104# if defined(__cpp_char8_t)
105# ifndef __cpp_lib_char8_t
106# error "__cpp_lib_char8_t should be defined in c++20"
107# endif
108# if __cpp_lib_char8_t != 201907L
109# error "__cpp_lib_char8_t should have the value 201907L in c++20"
110# endif
111# else
112# ifdef __cpp_lib_char8_t
113# error "__cpp_lib_char8_t should not be defined when the requirement 'defined(__cpp_char8_t)' is not met!"
114# endif
115# endif
116
117# ifndef __cpp_lib_constexpr_string_view
118# error "__cpp_lib_constexpr_string_view should be defined in c++20"
119# endif
120# if __cpp_lib_constexpr_string_view != 201811L
121# error "__cpp_lib_constexpr_string_view should have the value 201811L in c++20"
122# endif
123
124# ifdef __cpp_lib_freestanding_string_view
125# error "__cpp_lib_freestanding_string_view should not be defined before c++26"
126# endif
127
128# ifndef __cpp_lib_starts_ends_with
129# error "__cpp_lib_starts_ends_with should be defined in c++20"
130# endif
131# if __cpp_lib_starts_ends_with != 201711L
132# error "__cpp_lib_starts_ends_with should have the value 201711L in c++20"
133# endif
134
135# ifdef __cpp_lib_string_contains
136# error "__cpp_lib_string_contains should not be defined before c++23"
137# endif
138
139# ifndef __cpp_lib_string_view
140# error "__cpp_lib_string_view should be defined in c++20"
141# endif
142# if __cpp_lib_string_view != 201803L
143# error "__cpp_lib_string_view should have the value 201803L in c++20"
144# endif
145
146#elif TEST_STD_VER == 23
147
148# if defined(__cpp_char8_t)
149# ifndef __cpp_lib_char8_t
150# error "__cpp_lib_char8_t should be defined in c++23"
151# endif
152# if __cpp_lib_char8_t != 201907L
153# error "__cpp_lib_char8_t should have the value 201907L in c++23"
154# endif
155# else
156# ifdef __cpp_lib_char8_t
157# error "__cpp_lib_char8_t should not be defined when the requirement 'defined(__cpp_char8_t)' is not met!"
158# endif
159# endif
160
161# ifndef __cpp_lib_constexpr_string_view
162# error "__cpp_lib_constexpr_string_view should be defined in c++23"
163# endif
164# if __cpp_lib_constexpr_string_view != 201811L
165# error "__cpp_lib_constexpr_string_view should have the value 201811L in c++23"
166# endif
167
168# ifdef __cpp_lib_freestanding_string_view
169# error "__cpp_lib_freestanding_string_view should not be defined before c++26"
170# endif
171
172# ifndef __cpp_lib_starts_ends_with
173# error "__cpp_lib_starts_ends_with should be defined in c++23"
174# endif
175# if __cpp_lib_starts_ends_with != 201711L
176# error "__cpp_lib_starts_ends_with should have the value 201711L in c++23"
177# endif
178
179# ifndef __cpp_lib_string_contains
180# error "__cpp_lib_string_contains should be defined in c++23"
181# endif
182# if __cpp_lib_string_contains != 202011L
183# error "__cpp_lib_string_contains should have the value 202011L in c++23"
184# endif
185
186# ifndef __cpp_lib_string_view
187# error "__cpp_lib_string_view should be defined in c++23"
188# endif
189# if __cpp_lib_string_view != 201803L
190# error "__cpp_lib_string_view should have the value 201803L in c++23"
191# endif
192
193#elif TEST_STD_VER > 23
194
195# if defined(__cpp_char8_t)
196# ifndef __cpp_lib_char8_t
197# error "__cpp_lib_char8_t should be defined in c++26"
198# endif
199# if __cpp_lib_char8_t != 201907L
200# error "__cpp_lib_char8_t should have the value 201907L in c++26"
201# endif
202# else
203# ifdef __cpp_lib_char8_t
204# error "__cpp_lib_char8_t should not be defined when the requirement 'defined(__cpp_char8_t)' is not met!"
205# endif
206# endif
207
208# ifndef __cpp_lib_constexpr_string_view
209# error "__cpp_lib_constexpr_string_view should be defined in c++26"
210# endif
211# if __cpp_lib_constexpr_string_view != 201811L
212# error "__cpp_lib_constexpr_string_view should have the value 201811L in c++26"
213# endif
214
215# if !defined(_LIBCPP_VERSION)
216# ifndef __cpp_lib_freestanding_string_view
217# error "__cpp_lib_freestanding_string_view should be defined in c++26"
218# endif
219# if __cpp_lib_freestanding_string_view != 202311L
220# error "__cpp_lib_freestanding_string_view should have the value 202311L in c++26"
221# endif
222# else
223# ifdef __cpp_lib_freestanding_string_view
224# error "__cpp_lib_freestanding_string_view should not be defined because it is unimplemented in libc++!"
225# endif
226# endif
227
228# ifndef __cpp_lib_starts_ends_with
229# error "__cpp_lib_starts_ends_with should be defined in c++26"
230# endif
231# if __cpp_lib_starts_ends_with != 201711L
232# error "__cpp_lib_starts_ends_with should have the value 201711L in c++26"
233# endif
234
235# ifndef __cpp_lib_string_contains
236# error "__cpp_lib_string_contains should be defined in c++26"
237# endif
238# if __cpp_lib_string_contains != 202011L
239# error "__cpp_lib_string_contains should have the value 202011L in c++26"
240# endif
241
242# ifndef __cpp_lib_string_view
243# error "__cpp_lib_string_view should be defined in c++26"
244# endif
245# if __cpp_lib_string_view != 202403L
246# error "__cpp_lib_string_view should have the value 202403L in c++26"
247# endif
248
249#endif // TEST_STD_VER > 23
250
251// clang-format on
252
253

source code of libcxx/test/std/language.support/support.limits/support.limits.general/string_view.version.compile.pass.cpp