2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / collate / transform / char / 3.cc
blobdab1f081b0dae73de549cdb432a80a901bf5fa1d
1 // 2003-02-24 Petur Runolfsson <peturr02@ru.is>
3 // Copyright (C) 2003 Free Software Foundation
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // 22.2.4.1.1 collate members
23 #include <locale>
24 #include <testsuite_hooks.h>
26 void test03()
28 using namespace std;
29 typedef std::collate<char>::string_type string_type;
31 bool test __attribute__((unused)) = true;
33 // basic construction
34 locale loc_c = locale::classic();
35 locale loc_de = __gnu_test::try_named_locale("de_DE");
36 VERIFY( loc_c != loc_de );
38 // cache the collate facets
39 const collate<char>& coll_c = use_facet<collate<char> >(loc_c);
40 const collate<char>& coll_de = use_facet<collate<char> >(loc_de);
42 const char* strlit1 = "a\0a\0";
43 const char* strlit2 = "a\0b\0";
44 const char* strlit3 = "a\0\xc4\0";
45 const char* strlit4 = "a\0B\0";
46 const char* strlit5 = "aa\0";
47 const char* strlit6 = "b\0a\0";
49 int i;
50 string_type str1;
51 string_type str2;
53 str1 = coll_c.transform(strlit1, strlit1 + 3);
54 str2 = coll_c.transform(strlit2, strlit2 + 3);
55 i = str1.compare(str2);
56 VERIFY( i < 0 );
58 str1 = coll_de.transform(strlit1, strlit1 + 3);
59 str2 = coll_de.transform(strlit2, strlit2 + 3);
60 i = str1.compare(str2);
61 VERIFY( i < 0 );
63 str1 = coll_c.transform(strlit3, strlit3 + 3);
64 str2 = coll_c.transform(strlit4, strlit4 + 3);
65 i = str1.compare(str2);
66 VERIFY( i > 0 );
68 str1 = coll_de.transform(strlit3, strlit3 + 3);
69 str2 = coll_de.transform(strlit4, strlit4 + 3);
70 i = str1.compare(str2);
71 VERIFY( i < 0 );
73 str1 = coll_c.transform(strlit1, strlit1 + 1);
74 str2 = coll_c.transform(strlit5, strlit5 + 1);
75 i = str1.compare(str2);
76 VERIFY( i == 0 );
78 str1 = coll_de.transform(strlit6, strlit6 + 3);
79 str2 = coll_de.transform(strlit1, strlit1 + 3);
80 i = str1.compare(str2);
81 VERIFY( i > 0 );
83 str1 = coll_c.transform(strlit1, strlit1 + 3);
84 str2 = coll_c.transform(strlit5, strlit5 + 3);
85 i = str1.compare(str2);
86 VERIFY( i < 0 );
89 int main()
91 test03();
92 return 0;