@@ -3125,6 +3125,44 @@ static void preprocess_files()
3125
3125
}
3126
3126
}
3127
3127
3128
+ static void safe_api ()
3129
+ {
3130
+ // this test is to make sure the safe APIs are compiling
3131
+ #if defined(__cpp_lib_string_view) || defined(__cpp_lib_span)
3132
+ std::vector<std::string> filenames;
3133
+ # if defined(__cpp_lib_string_view)
3134
+ {
3135
+ const char input[] = " code" ;
3136
+ const std::string_view sv = input;
3137
+ // std::string_view can be implicitly converted into a std::span
3138
+ simplecpp::TokenList (sv,filenames," " );
3139
+ }
3140
+ # endif
3141
+ # ifdef __cpp_lib_span
3142
+ {
3143
+ char input[] = " code" ;
3144
+ const std::span<char , 5 > sp = input;
3145
+ simplecpp::TokenList (sp,filenames," " );
3146
+ }
3147
+ {
3148
+ const char input[] = " code" ;
3149
+ const std::span<const char , 5 > sp = input;
3150
+ simplecpp::TokenList (sp,filenames," " );
3151
+ }
3152
+ {
3153
+ unsigned char input[] = " code" ;
3154
+ const std::span<unsigned char , 5 > sp = input;
3155
+ simplecpp::TokenList (sp,filenames," " );
3156
+ }
3157
+ {
3158
+ const unsigned char input[] = " code" ;
3159
+ const std::span<const unsigned char , 5 > sp = input;
3160
+ simplecpp::TokenList (sp,filenames," " );
3161
+ }
3162
+ # endif
3163
+ #endif
3164
+ }
3165
+
3128
3166
static void fuzz_crash ()
3129
3167
{
3130
3168
{
@@ -3390,6 +3428,8 @@ int main(int argc, char **argv)
3390
3428
3391
3429
TEST_CASE (preprocess_files);
3392
3430
3431
+ TEST_CASE (safe_api);
3432
+
3393
3433
TEST_CASE (fuzz_crash);
3394
3434
3395
3435
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
0 commit comments