diff options
author | Mark de Wever <koraq@xs4all.nl> | 2022-02-02 19:28:05 +0100 |
---|---|---|
committer | Mark de Wever <koraq@xs4all.nl> | 2022-02-10 17:44:37 +0100 |
commit | fedbd264e39ba36022f208c4612da472cae0953f (patch) | |
tree | 77f3202f5bcda40f1546b65510e9ebd73e66e872 | |
parent | 662799c8511d345da000fd35e5591ac93a0b88e5 (diff) | |
download | llvm-fedbd264e39ba36022f208c4612da472cae0953f.zip llvm-fedbd264e39ba36022f208c4612da472cae0953f.tar.gz llvm-fedbd264e39ba36022f208c4612da472cae0953f.tar.bz2 |
[libc++][nfc] Add TEST_HAS_NO_LOCALIZATION.
This avoids using an libc++ internal macro in our tests.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D119352
7 files changed, 35 insertions, 28 deletions
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 3c253ac..be502a7 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 4cc64b0..15c2793 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 <unordered_set> #include <vector> -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include <regex> -# include <ostream> -# include <istream> +#include "test_macros.h" + +#ifndef TEST_HAS_NO_LOCALIZATION +# include <regex> +# include <ostream> +# include <istream> #endif #ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY @@ -199,14 +201,14 @@ static_assert(testIOIterator<std::front_insert_iterator<std::vector<int>>, std:: static_assert(testIOIterator<std::insert_iterator<std::vector<int>>, std::output_iterator_tag>()); static_assert(testConstWithoutConcept<std::istream_iterator<int, char>, int, std::input_iterator_tag>()); -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if !defined(TEST_HAS_NO_LOCALIZATION) static_assert(testWithoutConcept<std::istreambuf_iterator<char>, char, long long, char, char*, std::input_iterator_tag>()); static_assert(testWithoutConcept<std::move_iterator<int*>, int, std::ptrdiff_t, int&&, int*, std::random_access_iterator_tag>()); static_assert(testIOIterator<std::ostream_iterator<int, char>, std::output_iterator_tag>()); static_assert(testIOIterator<std::ostreambuf_iterator<int, char>, std::output_iterator_tag>()); static_assert(testConstWithoutConcept<std::cregex_iterator, std::cmatch, std::forward_iterator_tag>()); static_assert(testConstWithoutConcept<std::cregex_token_iterator, std::csub_match, std::forward_iterator_tag>()); -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +#endif // !TEST_HAS_NO_LOCALIZATION #ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY static_assert(testWithoutConcept<std::filesystem::directory_iterator, std::filesystem::directory_entry, std::ptrdiff_t, diff --git a/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp index a0edd38..049672f 100644 --- a/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp @@ -72,12 +72,12 @@ void test() { assert(output.size() == 1); assert(output.front() == CharT('a')); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION assert(context.locale() == std::locale()); #endif } -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION std::locale en_US{LOCALE_en_US_UTF_8}; std::locale fr_FR{LOCALE_fr_FR_UTF_8}; { diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp index 0e8e95d..1934471 100644 --- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp @@ -97,7 +97,7 @@ void test_hex_lower_case_precision(ArithmeticT value) { buffer[size] = '0'; } test_termination_condition(STR("025000.20000a}"), value, std::basic_string<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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<CharT>{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 522a583..fcddf83 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 <map> #include <optional> #include <queue> -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include <regex> -#endif #include <set> #include <stack> #include <span> @@ -51,6 +48,10 @@ #include "test_macros.h" +#ifndef TEST_HAS_NO_LOCALIZATION +# include <regex> +#endif + // Validate default template argument. static_assert(std::same_as<std::formatter<int>, std::formatter<int, char>>); @@ -213,7 +214,7 @@ void test_P1636() { assert_formatter_is_disabled<std::filesystem::path, CharT>(); #endif assert_formatter_is_disabled<std::shared_ptr<int>, CharT>(); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION assert_formatter_is_disabled<std::sub_match<CharT*>, 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 bbd43f7..5fbdbdd 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 <format> #include <cassert> -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include <iostream> -#endif #include <vector> #include "test_macros.h" #include "format_tests.h" +#ifndef TEST_HAS_NO_LOCALIZATION +# include <iostream> +#endif + auto test = []<class CharT, class... Args>(std::basic_string_view<CharT> expected, std::basic_string_view<CharT> fmt, const Args&... args) { std::basic_string<CharT> out = std::format(fmt, args...); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +#ifndef TEST_HAS_NO_LOCALIZATION if constexpr (std::same_as<CharT, char>) if (out != expected) std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out @@ -49,14 +50,14 @@ auto test_exception = []<class CharT, class... Args>(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<CharT, char>) 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<CharT, char>) +# 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 f65d0e1..c3794ab 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 |