]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc
1 // { dg-require-namedlocale "de_DE.ISO8859-15" }
3 // 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2020 Free Software Foundation, Inc.
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)
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.
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/>.
22 // 22.2.4.2 Template class collate_byname
26 #include <testsuite_hooks.h>
31 typedef std::collate
<char>::string_type string_type
;
34 locale loc_c
= locale::classic();
36 locale loc_de
= locale(ISO_8859(15,de_DE
));
39 locale
loc_byname(locale::classic(), new collate_byname
<char>(ISO_8859(15,de_DE
)));
40 str
= loc_byname
.name();
42 VERIFY( loc_de
!= loc_byname
);
44 // cache the collate facets
45 const collate
<char>& coll_de
= use_facet
<collate
<char> >(loc_de
);
47 // Check German "de_DE.ISO8859-15" locale.
52 const char* strlit3
= "Äuglein Augment"; // "C" == "Augment Äuglein"
53 const char* strlit4
= "Base baß Baß Bast"; // "C" == "Base baß Baß Bast"
55 int size3
= strlen(strlit3
) - 1;
56 i1
= coll_de
.compare(strlit3
, strlit3
+ size3
, strlit3
, strlit3
+ 7);
58 i1
= coll_de
.compare(strlit3
, strlit3
+ 7, strlit3
, strlit3
+ size3
);
60 i1
= coll_de
.compare(strlit3
, strlit3
+ 7, strlit3
, strlit3
+ 7);
63 i1
= coll_de
.compare(strlit3
, strlit3
+ 6, strlit3
+ 8, strlit3
+ 14);
66 int size4
= strlen(strlit4
) - 1;
67 i2
= coll_de
.compare(strlit4
, strlit4
+ size4
, strlit4
, strlit4
+ 13);
69 i2
= coll_de
.compare(strlit4
, strlit4
+ 13, strlit4
, strlit4
+ size4
);
71 i2
= coll_de
.compare(strlit4
, strlit4
+ size4
, strlit4
, strlit4
+ size4
);
74 l1
= coll_de
.hash(strlit3
, strlit3
+ size3
);
75 l2
= coll_de
.hash(strlit3
, strlit3
+ size3
- 1);
77 l1
= coll_de
.hash(strlit3
, strlit3
+ size3
);
78 l2
= coll_de
.hash(strlit4
, strlit4
+ size4
);
81 string str3
= coll_de
.transform(strlit3
, strlit3
+ size3
);
82 string str4
= coll_de
.transform(strlit4
, strlit4
+ size4
);
83 i1
= str3
.compare(str4
);
84 i2
= coll_de
.compare(strlit3
, strlit3
+ size3
, strlit4
, strlit4
+ size4
);
86 VERIFY ( i1
* i2
> 0 );
89 // Check byname locale
94 size4
= strlen(strlit3
) - 1;
95 i3
= coll_de
.compare(strlit3
, strlit3
+ size4
, strlit3
, strlit3
+ 7);
97 i3
= coll_de
.compare(strlit3
, strlit3
+ 7, strlit3
, strlit3
+ size4
);
99 i3
= coll_de
.compare(strlit3
, strlit3
+ 7, strlit3
, strlit3
+ 7);
102 i3
= coll_de
.compare(strlit3
, strlit3
+ 6, strlit3
+ 8, strlit3
+ 14);
105 size4
= strlen(strlit4
) - 1;
106 i4
= coll_de
.compare(strlit4
, strlit4
+ size4
, strlit4
, strlit4
+ 13);
108 i4
= coll_de
.compare(strlit4
, strlit4
+ 13, strlit4
, strlit4
+ size4
);
110 i4
= coll_de
.compare(strlit4
, strlit4
+ size4
, strlit4
, strlit4
+ size4
);
113 l3
= coll_de
.hash(strlit3
, strlit3
+ size4
);
114 l4
= coll_de
.hash(strlit3
, strlit3
+ size4
- 1);
116 l3
= coll_de
.hash(strlit3
, strlit3
+ size4
);
117 l4
= coll_de
.hash(strlit4
, strlit4
+ size4
);
120 string str5
= coll_de
.transform(strlit3
, strlit3
+ size3
);
121 string str6
= coll_de
.transform(strlit4
, strlit4
+ size4
);
122 i3
= str5
.compare(str6
);
123 i4
= coll_de
.compare(strlit3
, strlit3
+ size4
, strlit4
, strlit4
+ size4
);
125 VERIFY ( i3
* i4
> 0 );
127 // Verify byname == de
128 VERIFY ( str5
== str3
);
129 VERIFY ( str6
== str4
);