32 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// Prevent <ext/hash_set> from generating deprecated warnings for this test.10// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated11 12#include <cassert>13#include <ext/hash_map>14#include <string>15 16int main(int, char**) {17 char str[] = "test";18 assert(__gnu_cxx::hash<const char*>()("test") == std::hash<std::string>()("test"));19 assert(__gnu_cxx::hash<char*>()(str) == std::hash<std::string>()("test"));20 assert(__gnu_cxx::hash<char>()(42) == 42);21 assert(__gnu_cxx::hash<signed char>()(42) == 42);22 assert(__gnu_cxx::hash<unsigned char>()(42) == 42);23 assert(__gnu_cxx::hash<short>()(42) == 42);24 assert(__gnu_cxx::hash<unsigned short>()(42) == 42);25 assert(__gnu_cxx::hash<int>()(42) == 42);26 assert(__gnu_cxx::hash<unsigned int>()(42) == 42);27 assert(__gnu_cxx::hash<long>()(42) == 42);28 assert(__gnu_cxx::hash<unsigned long>()(42) == 42);29 30 return 0;31}32