OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [global_templates/] [1.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2000-09-11 Benjamin Kosnik <bkoz@redhat.com>
2
 
3
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
4
// Free Software Foundation
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 3, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING3.  If not see
19
// <http://www.gnu.org/licenses/>.
20
 
21
// 22.1.2 locale globals [lib.locale.global.templates]
22
 
23
#include <cwchar> // for mbstate_t
24
#include <locale>
25
#include <typeinfo>
26
#include <testsuite_hooks.h>
27
 
28
typedef std::codecvt<char, char, std::mbstate_t> ccodecvt;
29
 
30
class gnu_codecvt: public ccodecvt { };
31
 
32
void test01()
33
{
34
  using namespace std;
35
 
36
  bool test __attribute__((unused)) = true;
37
 
38
  // construct a locale object with the C facet
39
  const locale&         cloc = locale::classic();
40
  // sanity check the constructed locale has the normal facet
41
  VERIFY( has_facet<ccodecvt>(cloc) );
42
 
43
  // construct a locale object with the specialized facet.
44
  locale                loc(locale::classic(), new gnu_codecvt);
45
  // sanity check the constructed locale has the specialized facet.
46
  VERIFY( has_facet<gnu_codecvt>(loc) );
47
 
48
  try
49
    { const ccodecvt& cvt01 __attribute__((unused)) = use_facet<ccodecvt>(cloc); }
50
  catch(...)
51
    { VERIFY( false ); }
52
 
53
  try
54
    { const gnu_codecvt& cvt02 __attribute__((unused)) = use_facet<gnu_codecvt>(loc); }
55
  catch(...)
56
    { VERIFY( false ); }
57
 
58
  try
59
    { const ccodecvt& cvt03 __attribute__((unused)) = use_facet<gnu_codecvt>(cloc); }
60
  catch(bad_cast& obj)
61
    { VERIFY( true ); }
62
  catch(...)
63
    { VERIFY( false ); }
64
}
65
 
66
int main ()
67
{
68
  test01();
69
 
70
  return 0;
71
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.