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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [22_locale/] [collate/] [compare/] [wchar_t/] [3.cc] - Blame information for rev 424

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-namedlocale "" }
2
 
3
// 2003-02-24 Petur Runolfsson <peturr02@ru.is>
4
 
5
// Copyright (C) 2003, 2005, 2009 Free Software Foundation
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
 
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
// 22.2.4.1.1 collate members
23
 
24
#include <locale>
25
#include <testsuite_hooks.h>
26
 
27
// Test handling of strings containing nul characters
28
void test03()
29
{
30
  using namespace std;
31
  typedef std::collate<wchar_t>::string_type string_type;
32
 
33
  bool test __attribute__((unused)) = true;
34
 
35
  // basic construction
36
  locale loc_c = locale::classic();
37
  locale loc_de = locale("de_DE");
38
  VERIFY( loc_c != loc_de );
39
 
40
  // cache the collate facets
41
  const collate<wchar_t>& coll_c = use_facet<collate<wchar_t> >(loc_c);
42
  const collate<wchar_t>& coll_de = use_facet<collate<wchar_t> >(loc_de);
43
 
44
  // int compare(const charT*, const charT*, const charT*, const charT*) const
45
  const wchar_t* strlit1 = L"a\0a\0";
46
  const wchar_t* strlit2 = L"a\0b\0";
47
  const wchar_t* strlit3 = L"a\0\xc4\0";
48
  const wchar_t* strlit4 = L"a\0B\0";
49
  const wchar_t* strlit5 = L"aa\0";
50
  const wchar_t* strlit6 = L"b\0a\0";
51
 
52
  int i;
53
  i = coll_c.compare(strlit1, strlit1 + 3, strlit2, strlit2 + 3);
54
  VERIFY( i == -1 );
55
 
56
  i = coll_de.compare(strlit1, strlit1 + 3, strlit2, strlit2 + 3);
57
  VERIFY( i == -1 );
58
 
59
  i = coll_c.compare(strlit3, strlit3 + 3, strlit4, strlit4 + 3);
60
  VERIFY( i == 1 );
61
 
62
  i = coll_de.compare(strlit3, strlit3 + 3, strlit4, strlit4 + 3);
63
  VERIFY( i == -1 );
64
 
65
  i = coll_c.compare(strlit1, strlit1 + 3, strlit1, strlit1 + 4);
66
  VERIFY( i == -1 );
67
 
68
  i = coll_de.compare(strlit3, strlit3 + 4, strlit3, strlit3 + 3);
69
  VERIFY( i == 1 );
70
 
71
  i = coll_c.compare(strlit1, strlit1 + 4, strlit4, strlit4 + 1);
72
  VERIFY( i == 1 );
73
 
74
  i = coll_de.compare(strlit3, strlit3 + 3, strlit3, strlit3 + 3);
75
  VERIFY( i == 0 );
76
 
77
  i = coll_c.compare(strlit1, strlit1 + 2, strlit1, strlit1 + 4);
78
  VERIFY( i == -1 );
79
 
80
  i = coll_de.compare(strlit1, strlit1 + 3, strlit5, strlit5 + 3);
81
  VERIFY( i == -1 );
82
 
83
  i = coll_c.compare(strlit6, strlit6 + 3, strlit1, strlit1 + 3);
84
  VERIFY( i == 1 );
85
}
86
 
87
int main()
88
{
89
  test03();
90
  return 0;
91
}

powered by: WebSVN 2.1.0

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