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 negative_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 
27 class Fnf
28     : public std::moneypunct_byname<char, false>
29 {
30 public:
Fnf(const std::string & nm,std::size_t refs=0)31     explicit Fnf(const std::string& nm, std::size_t refs = 0)
32         : std::moneypunct_byname<char, false>(nm, refs) {}
33 };
34 
35 class Fnt
36     : public std::moneypunct_byname<char, true>
37 {
38 public:
Fnt(const std::string & nm,std::size_t refs=0)39     explicit Fnt(const std::string& nm, std::size_t refs = 0)
40         : std::moneypunct_byname<char, true>(nm, refs) {}
41 };
42 
43 class Fwf
44     : public std::moneypunct_byname<wchar_t, false>
45 {
46 public:
Fwf(const std::string & nm,std::size_t refs=0)47     explicit Fwf(const std::string& nm, std::size_t refs = 0)
48         : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
49 };
50 
51 class Fwt
52     : public std::moneypunct_byname<wchar_t, true>
53 {
54 public:
Fwt(const std::string & nm,std::size_t refs=0)55     explicit Fwt(const std::string& nm, std::size_t refs = 0)
56         : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
57 };
58 
main(int,char **)59 int main(int, char**)
60 {
61     {
62         Fnf f("C", 1);
63         assert(f.negative_sign() == std::string());
64     }
65     {
66         Fnt f("C", 1);
67         assert(f.negative_sign() == std::string());
68     }
69     {
70         Fwf f("C", 1);
71         assert(f.negative_sign() == std::wstring());
72     }
73     {
74         Fwt f("C", 1);
75         assert(f.negative_sign() == std::wstring());
76     }
77 
78     {
79         Fnf f(LOCALE_en_US_UTF_8, 1);
80         assert(f.negative_sign() == "-");
81     }
82     {
83         Fnt f(LOCALE_en_US_UTF_8, 1);
84         assert(f.negative_sign() == "-");
85     }
86     {
87         Fwf f(LOCALE_en_US_UTF_8, 1);
88         assert(f.negative_sign() == L"-");
89     }
90     {
91         Fwt f(LOCALE_en_US_UTF_8, 1);
92         assert(f.negative_sign() == L"-");
93     }
94 
95     {
96         Fnf f(LOCALE_fr_FR_UTF_8, 1);
97         assert(f.negative_sign() == "-");
98     }
99     {
100         Fnt f(LOCALE_fr_FR_UTF_8, 1);
101         assert(f.negative_sign() == "-");
102     }
103     {
104         Fwf f(LOCALE_fr_FR_UTF_8, 1);
105         assert(f.negative_sign() == L"-");
106     }
107     {
108         Fwt f(LOCALE_fr_FR_UTF_8, 1);
109         assert(f.negative_sign() == L"-");
110     }
111 
112     {
113         Fnf f(LOCALE_ru_RU_UTF_8, 1);
114         assert(f.negative_sign() == "-");
115     }
116     {
117         Fnt f(LOCALE_ru_RU_UTF_8, 1);
118         assert(f.negative_sign() == "-");
119     }
120     {
121         Fwf f(LOCALE_ru_RU_UTF_8, 1);
122         assert(f.negative_sign() == L"-");
123     }
124     {
125         Fwt f(LOCALE_ru_RU_UTF_8, 1);
126         assert(f.negative_sign() == L"-");
127     }
128 
129     {
130         Fnf f(LOCALE_zh_CN_UTF_8, 1);
131         assert(f.negative_sign() == "-");
132     }
133     {
134         Fnt f(LOCALE_zh_CN_UTF_8, 1);
135         assert(f.negative_sign() == "-");
136     }
137     {
138         Fwf f(LOCALE_zh_CN_UTF_8, 1);
139         assert(f.negative_sign() == L"-");
140     }
141     {
142         Fwt f(LOCALE_zh_CN_UTF_8, 1);
143         assert(f.negative_sign() == L"-");
144     }
145 
146   return 0;
147 }
148