1201360Srdivacky// 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
2201360Srdivacky
3201360Srdivacky// Copyright (C) 2000, 2002, 2003, 2009 Free Software Foundation
4201360Srdivacky//
5201360Srdivacky// This file is part of the GNU ISO C++ Library.  This library is free
6201360Srdivacky// software; you can redistribute it and/or modify it under the
7201360Srdivacky// terms of the GNU General Public License as published by the
8201360Srdivacky// Free Software Foundation; either version 3, or (at your option)
9201360Srdivacky// any later version.
10201360Srdivacky
11201360Srdivacky// This library is distributed in the hope that it will be useful,
12201360Srdivacky// but WITHOUT ANY WARRANTY; without even the implied warranty of
13249423Sdim// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14201360Srdivacky// GNU General Public License for more details.
15201360Srdivacky
16201360Srdivacky// You should have received a copy of the GNU General Public License along
17239462Sdim// with this library; see the file COPYING3.  If not see
18201360Srdivacky// <http://www.gnu.org/licenses/>.
19201360Srdivacky
20201360Srdivacky// 22.1.1.5 locale static members [lib.locale.statics]
21201360Srdivacky
22201360Srdivacky#include <cwchar> // for mbstate_t
23201360Srdivacky#include <locale>
24201360Srdivacky#include <testsuite_hooks.h>
25201360Srdivacky
26201360Srdivackytypedef std::codecvt<char, char, std::mbstate_t> ccodecvt;
27201360Srdivackyclass gnu_codecvt: public ccodecvt { };
28201360Srdivacky
29201360Srdivackyvoid test01()
30201360Srdivacky{
31201360Srdivacky  using namespace std;
32201360Srdivacky  bool test __attribute__((unused)) = true;
33201360Srdivacky
34201360Srdivacky  string str1, str2;
35201360Srdivacky
36201360Srdivacky  // Construct a locale object with the C facet.
37201360Srdivacky  const locale loc01 = locale::classic();
38201360Srdivacky
39201360Srdivacky  // Construct a locale object with the specialized facet.
40  locale loc02(locale::classic(), new gnu_codecvt);
41  VERIFY ( loc01 != loc02 );
42  VERIFY ( !(loc01 == loc02) );
43
44  // classic
45  locale loc06("C");
46  VERIFY (loc06 == loc01);
47  str1 = loc06.name();
48  VERIFY( str1 == "C" );
49
50  // global
51  locale loc03;
52  VERIFY ( loc03 == loc01);
53  locale global_orig = locale::global(loc02);
54  locale loc05;
55  VERIFY (loc05 != loc03);
56  VERIFY (loc05 == loc02);
57
58  // Reset global settings.
59  locale::global(global_orig);
60}
61
62int main ()
63{
64  test01();
65  return 0;
66}
67