1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <locale>
11 
12 // template <class charT> class collate_byname
13 
14 // long hash(const charT* low, const charT* high) const;
15 
16 //   This test is not portable
17 
18 #include <locale>
19 #include <string>
20 #include <cassert>
21 
22 #include "platform_support.h" // locale name macros
23 
main()24 int main()
25 {
26     std::locale l(LOCALE_en_US_UTF_8);
27     {
28         std::string x1("1234");
29         std::string x2("12345");
30         const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
31         assert(f.hash(x1.data(), x1.data() + x1.size())
32             != f.hash(x2.data(), x2.data() + x2.size()));
33     }
34     {
35         std::wstring x1(L"1234");
36         std::wstring x2(L"12345");
37         const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
38         assert(f.hash(x1.data(), x1.data() + x1.size())
39             != f.hash(x2.data(), x2.data() + x2.size()));
40     }
41 }
42