1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: clang-modules-build 10 11 // Prevent <ext/hash_set> from generating deprecated warnings for this test. 12 // ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated 13 #include <assert.h> 14 #include <ext/hash_map> 15 #include <string> 16 17 #include "test_macros.h" 18 main(int,char **)19int main(int, char**) 20 { 21 char str[] = "test"; 22 assert(__gnu_cxx::hash<const char *>()("test") == 23 std::hash<std::string>()("test")); 24 assert(__gnu_cxx::hash<char *>()(str) == std::hash<std::string>()("test")); 25 assert(__gnu_cxx::hash<char>()(42) == 42); 26 assert(__gnu_cxx::hash<signed char>()(42) == 42); 27 assert(__gnu_cxx::hash<unsigned char>()(42) == 42); 28 assert(__gnu_cxx::hash<short>()(42) == 42); 29 assert(__gnu_cxx::hash<unsigned short>()(42) == 42); 30 assert(__gnu_cxx::hash<int>()(42) == 42); 31 assert(__gnu_cxx::hash<unsigned int>()(42) == 42); 32 assert(__gnu_cxx::hash<long>()(42) == 42); 33 assert(__gnu_cxx::hash<unsigned long>()(42) == 42); 34 35 return 0; 36 } 37