default.pass.cpp
2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//===----------------------------------------------------------------------===//
//
// 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
// <locale>
// locale() throw();
#include <locale>
#include <cassert>
#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<std::collate<char> >(loc));
assert(std::has_facet<std::collate<wchar_t> >(loc));
assert(std::has_facet<std::ctype<char> >(loc));
assert(std::has_facet<std::ctype<wchar_t> >(loc));
assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
assert((std::has_facet<std::moneypunct<char> >(loc)));
assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
assert((std::has_facet<std::money_get<char> >(loc)));
assert((std::has_facet<std::money_get<wchar_t> >(loc)));
assert((std::has_facet<std::money_put<char> >(loc)));
assert((std::has_facet<std::money_put<wchar_t> >(loc)));
assert((std::has_facet<std::numpunct<char> >(loc)));
assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
assert((std::has_facet<std::num_get<char> >(loc)));
assert((std::has_facet<std::num_get<wchar_t> >(loc)));
assert((std::has_facet<std::num_put<char> >(loc)));
assert((std::has_facet<std::num_put<wchar_t> >(loc)));
assert((std::has_facet<std::time_get<char> >(loc)));
assert((std::has_facet<std::time_get<wchar_t> >(loc)));
assert((std::has_facet<std::time_put<char> >(loc)));
assert((std::has_facet<std::time_put<wchar_t> >(loc)));
assert((std::has_facet<std::messages<char> >(loc)));
assert((std::has_facet<std::messages<wchar_t> >(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;
}