@@ -3169,6 +3169,44 @@ static void preprocess_files()
31693169 }
31703170}
31713171
3172+ static void safe_api ()
3173+ {
3174+ // this test is to make sure the safe APIs are compiling
3175+ #if defined(__cpp_lib_string_view) || defined(__cpp_lib_span)
3176+ std::vector<std::string> filenames;
3177+ # if defined(__cpp_lib_string_view)
3178+ {
3179+ const char input[] = " code" ;
3180+ const std::string_view sv = input;
3181+ // std::string_view can be implicitly converted into a std::span
3182+ simplecpp::TokenList (sv,filenames," " );
3183+ }
3184+ # endif
3185+ # ifdef __cpp_lib_span
3186+ {
3187+ char input[] = " code" ;
3188+ const std::span sp = input;
3189+ simplecpp::TokenList (sp,filenames," " );
3190+ }
3191+ {
3192+ const char input[] = " code" ;
3193+ const std::span sp = input;
3194+ simplecpp::TokenList (sp,filenames," " );
3195+ }
3196+ {
3197+ unsigned char input[] = " code" ;
3198+ const std::span sp = input;
3199+ simplecpp::TokenList (sp,filenames," " );
3200+ }
3201+ {
3202+ const unsigned char input[] = " code" ;
3203+ const std::span sp = input;
3204+ simplecpp::TokenList (sp,filenames," " );
3205+ }
3206+ # endif
3207+ #endif
3208+ }
3209+
31723210static void fuzz_crash ()
31733211{
31743212 {
@@ -3435,6 +3473,8 @@ int main(int argc, char **argv)
34353473
34363474 TEST_CASE (preprocess_files);
34373475
3476+ TEST_CASE (safe_api);
3477+
34383478 TEST_CASE (fuzz_crash);
34393479
34403480 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
0 commit comments