1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// REQUIRES: locale.en_US.UTF-8
10// REQUIRES: locale.fr_FR.UTF-8
11// REQUIRES: locale.ru_RU.UTF-8
12// REQUIRES: locale.zh_CN.UTF-8
13
14// <locale>
15
16// class moneypunct_byname<charT, International>
17
18// string_type positive_sign() const;
19
20#include <locale>
21#include <limits>
22#include <cassert>
23
24#include "test_macros.h"
25#include "platform_support.h" // locale name macros
26
27class Fnf
28 : public std::moneypunct_byname<char, false>
29{
30public:
31 explicit Fnf(const std::string& nm, std::size_t refs = 0)
32 : std::moneypunct_byname<char, false>(nm, refs) {}
33};
34
35class Fnt
36 : public std::moneypunct_byname<char, true>
37{
38public:
39 explicit Fnt(const std::string& nm, std::size_t refs = 0)
40 : std::moneypunct_byname<char, true>(nm, refs) {}
41};
42
43#ifndef TEST_HAS_NO_WIDE_CHARACTERS
44class Fwf
45 : public std::moneypunct_byname<wchar_t, false>
46{
47public:
48 explicit Fwf(const std::string& nm, std::size_t refs = 0)
49 : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
50};
51
52class Fwt
53 : public std::moneypunct_byname<wchar_t, true>
54{
55public:
56 explicit Fwt(const std::string& nm, std::size_t refs = 0)
57 : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
58};
59#endif // TEST_HAS_NO_WIDE_CHARACTERS
60
61int main(int, char**)
62{
63 {
64 Fnf f("C", 1);
65 assert(f.positive_sign() == std::string());
66 }
67 {
68 Fnt f("C", 1);
69 assert(f.positive_sign() == std::string());
70 }
71#ifndef TEST_HAS_NO_WIDE_CHARACTERS
72 {
73 Fwf f("C", 1);
74 assert(f.positive_sign() == std::wstring());
75 }
76 {
77 Fwt f("C", 1);
78 assert(f.positive_sign() == std::wstring());
79 }
80#endif
81
82 {
83 Fnf f(LOCALE_en_US_UTF_8, 1);
84 assert(f.positive_sign() == "");
85 }
86 {
87 Fnt f(LOCALE_en_US_UTF_8, 1);
88 assert(f.positive_sign() == "");
89 }
90#ifndef TEST_HAS_NO_WIDE_CHARACTERS
91 {
92 Fwf f(LOCALE_en_US_UTF_8, 1);
93 assert(f.positive_sign() == L"");
94 }
95 {
96 Fwt f(LOCALE_en_US_UTF_8, 1);
97 assert(f.positive_sign() == L"");
98 }
99#endif
100
101 {
102 Fnf f(LOCALE_fr_FR_UTF_8, 1);
103 assert(f.positive_sign() == "");
104 }
105 {
106 Fnt f(LOCALE_fr_FR_UTF_8, 1);
107 assert(f.positive_sign() == "");
108 }
109#ifndef TEST_HAS_NO_WIDE_CHARACTERS
110 {
111 Fwf f(LOCALE_fr_FR_UTF_8, 1);
112 assert(f.positive_sign() == L"");
113 }
114 {
115 Fwt f(LOCALE_fr_FR_UTF_8, 1);
116 assert(f.positive_sign() == L"");
117 }
118#endif
119
120 {
121 Fnf f(LOCALE_ru_RU_UTF_8, 1);
122 assert(f.positive_sign() == "");
123 }
124 {
125 Fnt f(LOCALE_ru_RU_UTF_8, 1);
126 assert(f.positive_sign() == "");
127 }
128#ifndef TEST_HAS_NO_WIDE_CHARACTERS
129 {
130 Fwf f(LOCALE_ru_RU_UTF_8, 1);
131 assert(f.positive_sign() == L"");
132 }
133 {
134 Fwt f(LOCALE_ru_RU_UTF_8, 1);
135 assert(f.positive_sign() == L"");
136 }
137#endif
138
139 {
140 Fnf f(LOCALE_zh_CN_UTF_8, 1);
141 assert(f.positive_sign() == "");
142 }
143 {
144 Fnt f(LOCALE_zh_CN_UTF_8, 1);
145 assert(f.positive_sign() == "");
146 }
147#ifndef TEST_HAS_NO_WIDE_CHARACTERS
148 {
149 Fwf f(LOCALE_zh_CN_UTF_8, 1);
150 assert(f.positive_sign() == L"");
151 }
152 {
153 Fwt f(LOCALE_zh_CN_UTF_8, 1);
154 assert(f.positive_sign() == L"");
155 }
156#endif
157
158 return 0;
159}
160

source code of libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp