//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // REQUIRES: locale.en_US.UTF-8 // This test relies on P0482 being fixed, which isn't in // older Apple dylibs // // XFAIL: with_system_cxx_lib=macosx10.15 // XFAIL: with_system_cxx_lib=macosx10.14 // XFAIL: with_system_cxx_lib=macosx10.13 // XFAIL: with_system_cxx_lib=macosx10.12 // XFAIL: with_system_cxx_lib=macosx10.11 // XFAIL: with_system_cxx_lib=macosx10.10 // XFAIL: with_system_cxx_lib=macosx10.9 // This test runs in C++20, but we have deprecated codecvt in C++20. // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS // // locale() throw(); #include #include #include "test_macros.h" #include "platform_support.h" // locale name macros #include "count_new.h" void check(const std::locale& loc) { assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); #if TEST_STD_VER > 17 assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); #endif assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); } int main(int, char**) { int ok; { std::locale loc; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(loc.name() == "C"); assert(globalMemCounter.checkOutstandingNewEq(0)); check(loc); assert(globalMemCounter.checkOutstandingNewEq(0)); assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc); ok = globalMemCounter.outstanding_new; std::locale loc2; assert(globalMemCounter.checkOutstandingNewEq(ok)); check(loc2); assert(globalMemCounter.checkOutstandingNewEq(ok)); assert(loc2 == std::locale(LOCALE_en_US_UTF_8)); assert(globalMemCounter.checkOutstandingNewEq(ok)); } assert(globalMemCounter.checkOutstandingNewEq(ok)); return 0; }