1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // Test that <string> provides all of the arithmetic, enum, and pointer
14 // hash specializations.
18 #include "constexpr_char_traits.h"
19 #include "poisoned_hash_helper.h"
20 #include "test_allocator.h"
21 #include "test_macros.h"
28 struct std::char_traits
<MyChar
> {
29 using char_type
= MyChar
;
30 using int_type
= std::char_traits
<char>::int_type
;
31 using off_type
= std::char_traits
<char>::off_type
;
32 using pos_type
= std::char_traits
<char>::pos_type
;
33 using state_type
= std::char_traits
<char>::state_type
;
35 static void assign(char_type
&, const char_type
&);
36 static bool eq(char_type
, char_type
);
37 static bool lt(char_type
, char_type
);
39 static int compare(const char_type
*, const char_type
*, std::size_t);
40 static std::size_t length(const char_type
*);
41 static const char_type
* find(const char_type
*, std::size_t, const char_type
&);
42 static char_type
* move(char_type
*, const char_type
*, std::size_t);
43 static char_type
* copy(char_type
*, const char_type
*, std::size_t);
44 static char_type
* assign(char_type
*, std::size_t, char_type
);
46 static int_type
not_eof(int_type
);
47 static char_type
to_char_type(int_type
);
48 static int_type
to_int_type(char_type
);
49 static bool eq_int_type(int_type
, int_type
);
50 static int_type
eof();
53 int main(int, char**) {
54 test_library_hash_specializations_available();
56 test_hash_enabled
<std::string
>();
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
58 test_hash_enabled
<std::wstring
>();
60 #ifndef TEST_HAS_NO_CHAR8_T
61 test_hash_enabled
<std::u8string
>();
63 test_hash_enabled
<std::u16string
>();
64 test_hash_enabled
<std::u32string
>();
65 test_hash_enabled
<std::basic_string
<char, std::char_traits
<char>, test_allocator
<char>>>();
66 test_hash_disabled
<std::basic_string
<MyChar
, std::char_traits
<MyChar
>, std::allocator
<MyChar
>>>();
67 test_hash_disabled
<std::basic_string
<char, constexpr_char_traits
<char>, std::allocator
<char>>>();