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;
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 int main()
23 {
24     std::locale l = std::locale::classic();
25     {
26         std::string x1("1234");
27         std::string x2("12345");
28         const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
29         assert(f.hash(x1.data(), x1.data() + x1.size())
30             != f.hash(x2.data(), x2.data() + x2.size()));
31     }
32     {
33         std::wstring x1(L"1234");
34         std::wstring x2(L"12345");
35         const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
36         assert(f.hash(x1.data(), x1.data() + x1.size())
37             != f.hash(x2.data(), x2.data() + x2.size()));
38     }
39 }
40