From 0dc0969cd0a732760f0aa79942a04e0eaef297c4 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:03:23 +0000 Subject: Vendor import of libc++ trunk r300422: https://llvm.org/svn/llvm-project/libcxx/trunk@300422 --- .../string.view.hash/enabled_hashes.pass.cpp | 31 ++++++++++++++++++++++ .../string.view.hash/string_view.pass.cpp | 30 ++++++++++++++------- 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp (limited to 'test/std/strings/string.view/string.view.hash') diff --git a/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp new file mode 100644 index 000000000000..2e9ebcb4c037 --- /dev/null +++ b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// Test that provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type(); + test_hash_enabled_for_type(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test_hash_enabled_for_type(); + test_hash_enabled_for_type(); +#endif + } +} diff --git a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp index 63099e2c8864..53c3d261d882 100644 --- a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp +++ b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp @@ -19,29 +19,41 @@ // Not very portable #include +#include #include #include +#include "test_macros.h" + using std::string_view; -template +template void test() { - typedef std::hash H; - static_assert((std::is_same::value), "" ); + typedef std::hash H; + static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); - H h; -// std::string g1 = "1234567890"; -// std::string g2 = "1234567891"; - typedef typename T::value_type char_type; + + typedef typename SV::value_type char_type; + typedef std::basic_string String; + typedef std::hash SH; + ASSERT_NOEXCEPT(H()(SV())); + char_type g1 [ 10 ]; char_type g2 [ 10 ]; for ( int i = 0; i < 10; ++i ) g1[i] = g2[9-i] = static_cast('0' + i); - T s1(g1, 10); - T s2(g2, 10); + H h; + SH sh; + SV s1(g1, 10); + String ss1(s1); + SV s2(g2, 10); + String ss2(s2); + assert(h(s1) == h(s1)); assert(h(s1) != h(s2)); + assert(sh(ss1) == h(s1)); + assert(sh(ss2) == h(s2)); } int main() -- cgit v1.3