diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp index 3c253ac157c15..be502a782a970 100644 --- a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp @@ -49,8 +49,7 @@ int main(int, char**) path p = fs::u8path(In3, In3End); assert(p == In1); } -#if TEST_STD_VER > 17 && defined(__cpp_char8_t) && defined(_LIBCPP_VERSION) && \ - !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) && defined(_LIBCPP_VERSION) && !defined(TEST_HAS_NO_LOCALIZATION) const char8_t* u8In1 = u8"abcd/efg"; const std::u8string u8In2(u8In1); const auto u8In3 = u8In2.begin(); diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp index 4cc64b0638de2..15c2793d7dae6 100644 --- a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp @@ -33,10 +33,12 @@ #include #include -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include -# include -# include +#include "test_macros.h" + +#ifndef TEST_HAS_NO_LOCALIZATION +# include +# include +# include #endif #ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY @@ -199,14 +201,14 @@ static_assert(testIOIterator>, std:: static_assert(testIOIterator>, std::output_iterator_tag>()); static_assert(testConstWithoutConcept, int, std::input_iterator_tag>()); -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if !defined(TEST_HAS_NO_LOCALIZATION) static_assert(testWithoutConcept, char, long long, char, char*, std::input_iterator_tag>()); static_assert(testWithoutConcept, int, std::ptrdiff_t, int&&, int*, std::random_access_iterator_tag>()); static_assert(testIOIterator, std::output_iterator_tag>()); static_assert(testIOIterator, std::output_iterator_tag>()); static_assert(testConstWithoutConcept()); static_assert(testConstWithoutConcept()); -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +#endif // !TEST_HAS_NO_LOCALIZATION #ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY static_assert(testWithoutConcept{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::hex, 20'000).ptr; test_termination_condition(STR(".20000La}"), value, std::basic_string{buffer.begin(), end}); @@ -137,7 +137,7 @@ void test_hex_upper_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000A}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::hex, 20'000).ptr; std::transform(buffer.begin(), end, buffer.begin(), [](char c) { return std::toupper(c); }); test_termination_condition(STR(".20000LA}"), value, std::basic_string{buffer.begin(), end}); @@ -177,7 +177,7 @@ void test_scientific_lower_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000e}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::scientific, 20'000).ptr; test_termination_condition(STR(".20000Le}"), value, std::basic_string{buffer.begin(), end}); @@ -217,7 +217,7 @@ void test_scientific_upper_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000E}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::scientific, 20'000).ptr; std::transform(buffer.begin(), end, buffer.begin(), [](char c) { return std::toupper(c); }); test_termination_condition(STR(".20000LE}"), value, std::basic_string{buffer.begin(), end}); @@ -257,7 +257,7 @@ void test_fixed_lower_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000f}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::fixed, 20'000).ptr; test_termination_condition(STR(".20000Lf}"), value, std::basic_string{buffer.begin(), end}); @@ -297,7 +297,7 @@ void test_fixed_upper_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000F}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::fixed, 20'000).ptr; std::transform(buffer.begin(), end, buffer.begin(), [](char c) { return std::toupper(c); }); test_termination_condition(STR(".20000LF}"), value, std::basic_string{buffer.begin(), end}); @@ -337,7 +337,7 @@ void test_general_lower_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000g}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::general, 20'000).ptr; test_termination_condition(STR(".20000Lg}"), value, std::basic_string{buffer.begin(), end}); @@ -377,7 +377,7 @@ void test_general_upper_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000G}"), value, std::basic_string{buffer.begin(), buffer.end()}); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION end = std::to_chars(buffer.begin(), buffer.end(), value, std::chars_format::general, 20'000).ptr; std::transform(buffer.begin(), end, buffer.begin(), [](char c) { return std::toupper(c); }); test_termination_condition(STR(".20000LG}"), value, std::basic_string{buffer.begin(), end}); diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp index 522a583f349cb..fcddf832df2c9 100644 --- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp @@ -33,9 +33,6 @@ #include #include #include -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include -#endif #include #include #include @@ -51,6 +48,10 @@ #include "test_macros.h" +#ifndef TEST_HAS_NO_LOCALIZATION +# include +#endif + // Validate default template argument. static_assert(std::same_as, std::formatter>); @@ -213,7 +214,7 @@ void test_P1636() { assert_formatter_is_disabled(); #endif assert_formatter_is_disabled, CharT>(); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION assert_formatter_is_disabled, CharT>(); #endif #ifndef _LIBCPP_HAS_NO_THREADS diff --git a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp index bbd43f7b7c526..5fbdbdd32aaff 100644 --- a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp @@ -24,18 +24,19 @@ #include #include -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include -#endif #include #include "test_macros.h" #include "format_tests.h" +#ifndef TEST_HAS_NO_LOCALIZATION +# include +#endif + auto test = [](std::basic_string_view expected, std::basic_string_view fmt, const Args&... args) { std::basic_string out = std::format(fmt, args...); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION if constexpr (std::same_as) if (out != expected) std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out @@ -49,14 +50,14 @@ auto test_exception = [](std::string_view what, std: #ifndef TEST_HAS_NO_EXCEPTIONS try { std::format(fmt, args...); -# ifndef _LIBCPP_HAS_NO_LOCALIZATION +# ifndef TEST_HAS_NO_LOCALIZATION if constexpr (std::same_as) std::cerr << "\nFormat string " << fmt << "\nDidn't throw an exception.\n"; # endif assert(false); } catch (const std::format_error& e) { -# if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) if constexpr (std::same_as) +# if defined(_LIBCPP_VERSION) && !defined(TEST_HAS_NO_LOCALIZATION) if (e.what() != what) std::cerr << "\nFormat string " << fmt << "\nExpected exception " << what << "\nActual exception " << e.what() << '\n'; diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index f65d0e13d15f1..c3794ab4685dd 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -376,6 +376,10 @@ inline void DoNotOptimize(Tp const& value) { # define TEST_HAS_NO_UNICODE_CHARS #endif +#if defined(_LIBCPP_HAS_NO_LOCALIZATION) +# define TEST_HAS_NO_LOCALIZATION +#endif + #if defined(__GNUC__) #pragma GCC diagnostic pop #endif