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

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