]>
Commit | Line | Data |
---|---|---|
aa118a03 | 1 | // Copyright (C) 2007-2014 Free Software Foundation, Inc. |
c5f416ab BK |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
c5f416ab BK |
7 | // any later version. |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
c5f416ab BK |
17 | |
18 | #include <string> | |
19 | #include <locale> | |
c5f416ab BK |
20 | #include <testsuite_hooks.h> |
21 | ||
22 | // Based on Langer Kreft "Standard C++ IOStreams and Locales" p 316-318 | |
23 | // PR libstdc++/30127 | |
24 | // PR libstdc++/34449 | |
25 | int main() | |
26 | { | |
27 | bool test __attribute__((unused)) = true; | |
28 | ||
29 | using std::locale; | |
30 | using std::has_facet; | |
31 | using std::use_facet; | |
32 | typedef std::ctype<char> base_facet; | |
33 | typedef std::ctype_byname<char> derived_facet; | |
34 | ||
35 | locale loc_c = locale::classic(); | |
36 | locale loc_base = loc_c; | |
8619bc82 | 37 | locale loc_derived(loc_c, new derived_facet("C")); |
c5f416ab | 38 | |
c5f416ab BK |
39 | // Standard base facet. |
40 | VERIFY( has_facet<base_facet>(loc_c) ); | |
41 | VERIFY( has_facet<base_facet>(loc_base) ); | |
42 | VERIFY( has_facet<base_facet>(loc_derived) ); | |
43 | ||
44 | // Standard derived facet. | |
45 | VERIFY( !has_facet<derived_facet>(loc_c) ); | |
46 | VERIFY( !has_facet<derived_facet>(loc_base) ); | |
47 | VERIFY( has_facet<derived_facet>(loc_derived) ); | |
48 | ||
49 | ||
50 | // 1 | |
51 | try | |
52 | { | |
53 | if (has_facet<derived_facet>(loc_base)) | |
54 | { | |
55 | use_facet<derived_facet>(loc_base).widen('k'); | |
56 | VERIFY( true ); | |
57 | } | |
58 | } | |
59 | catch (...) | |
60 | { | |
61 | // Expect no exception. | |
62 | VERIFY( true ); | |
63 | } | |
64 | ||
65 | // 2 | |
66 | try | |
67 | { | |
68 | if (has_facet<base_facet>(loc_derived)) | |
69 | use_facet<base_facet>(loc_derived).widen('k'); | |
70 | else | |
71 | VERIFY( true ); | |
72 | } | |
73 | catch (...) | |
74 | { | |
75 | // Expect no exception. | |
76 | VERIFY( true ); | |
77 | } | |
78 | ||
79 | return 0; | |
80 | } |