1 // 2003-02-24 Petur Runolfsson <peturr02@ru.is>
3 // Copyright (C) 2003 Free Software Foundation
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)
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,
21 // 22.2.4.1.1 collate members
24 #include <testsuite_hooks.h>
26 // Test handling of strings containing nul characters
30 typedef std::collate<char>::string_type string_type;
35 locale loc_c = locale::classic();
36 locale loc_de = __gnu_cxx_test::try_named_locale("de_DE");
37 VERIFY( loc_c != loc_de );
39 // cache the collate facets
40 const collate<char>& coll_c = use_facet<collate<char> >(loc_c);
41 const collate<char>& coll_de = use_facet<collate<char> >(loc_de);
43 // int compare(const charT*, const charT*, const charT*, const charT*) const
44 const char* strlit1 = "a\0a\0";
45 const char* strlit2 = "a\0b\0";
46 const char* strlit3 = "a\0\xc4\0";
47 const char* strlit4 = "a\0B\0";
48 const char* strlit5 = "aa\0";
49 const char* strlit6 = "b\0a\0";
52 i = coll_c.compare(strlit1, strlit1 + 3, strlit2, strlit2 + 3);
55 i = coll_de.compare(strlit1, strlit1 + 3, strlit2, strlit2 + 3);
58 i = coll_c.compare(strlit3, strlit3 + 3, strlit4, strlit4 + 3);
61 i = coll_de.compare(strlit3, strlit3 + 3, strlit4, strlit4 + 3);
64 i = coll_c.compare(strlit1, strlit1 + 3, strlit1, strlit1 + 4);
67 i = coll_de.compare(strlit3, strlit3 + 4, strlit3, strlit3 + 3);
70 i = coll_c.compare(strlit1, strlit1 + 4, strlit4, strlit4 + 1);
73 i = coll_de.compare(strlit3, strlit3 + 3, strlit3, strlit3 + 3);
76 i = coll_c.compare(strlit1, strlit1 + 2, strlit1, strlit1 + 4);
79 i = coll_de.compare(strlit1, strlit1 + 3, strlit5, strlit5 + 3);
82 i = coll_c.compare(strlit6, strlit6 + 3, strlit1, strlit1 + 3);