Initial commit

This commit is contained in:
Yervant7
2024-01-16 19:28:29 -03:00
commit 8c0524dc0f
9054 changed files with 1081727 additions and 0 deletions
@@ -0,0 +1,77 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: !stdlib=libc++ && (c++11 || c++14)
// <string_view>
// Test that hash specializations for <string_view> require "char_traits<_CharT>" not just any "_Trait".
#include <string_view>
#include <string> // for 'mbstate_t'
#include "test_macros.h"
template <class _CharT>
struct trait // copied from <__string>
{
typedef _CharT char_type;
typedef int int_type;
typedef std::streamoff off_type;
typedef std::streampos pos_type;
typedef std::mbstate_t state_type;
static inline void assign(char_type& __c1, const char_type& __c2) {
__c1 = __c2;
}
static inline bool eq(char_type __c1, char_type __c2) { return __c1 == __c2; }
static inline bool lt(char_type __c1, char_type __c2) { return __c1 < __c2; }
static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
static size_t length(const char_type* __s);
static const char_type* find(const char_type* __s, size_t __n,
const char_type& __a);
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
static char_type* assign(char_type* __s, size_t __n, char_type __a);
static inline int_type not_eof(int_type __c) {
return eq_int_type(__c, eof()) ? ~eof() : __c;
}
static inline char_type to_char_type(int_type __c) { return char_type(__c); }
static inline int_type to_int_type(char_type __c) { return int_type(__c); }
static inline bool eq_int_type(int_type __c1, int_type __c2) {
return __c1 == __c2;
}
static inline int_type eof() { return int_type(EOF); }
};
template <class CharT>
void test() {
typedef std::basic_string_view<CharT, trait<CharT> > strv_t;
std::hash<strv_t>
h; // expected-error-re 4 {{{{call to implicitly-deleted default constructor of 'std::hash<strv_t>'|implicit instantiation of undefined template}} {{.+}}}}}}
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
// expected-error-re@-2 {{{{call to implicitly-deleted default constructor of 'std::hash<strv_t>'|implicit instantiation of undefined template}} {{.+}}}}}}
#endif
(void)h;
}
int main(int, char**) {
test<char>();
test<wchar_t>();
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
test<char8_t>();
#endif
test<char16_t>();
test<char32_t>();
return 0;
}
@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: !stdlib=libc++ && (c++11 || c++14)
// <string_view>
// Test that <string_view> provides all of the arithmetic, enum, and pointer
// hash specializations.
#include <string_view>
#include "poisoned_hash_helper.h"
#include "test_macros.h"
int main(int, char**) {
test_library_hash_specializations_available();
{
test_hash_enabled_for_type<std::string_view>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_hash_enabled_for_type<std::wstring_view>();
#endif
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
test_hash_enabled_for_type<std::u8string_view>();
#endif
test_hash_enabled_for_type<std::u16string_view>();
test_hash_enabled_for_type<std::u32string_view>();
}
return 0;
}
@@ -0,0 +1,74 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)
// <functional>
// template <class T>
// struct hash
// {
// size_t operator()(T val) const;
// };
// Not very portable
#include <string_view>
#include <string>
#include <cassert>
#include <type_traits>
#include "test_macros.h"
using std::string_view;
template <class SV>
void
test()
{
typedef std::hash<SV> H;
#if TEST_STD_VER <= 14
static_assert((std::is_same<typename H::argument_type, SV>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
#endif
typedef typename SV::value_type char_type;
typedef std::basic_string<char_type> String;
typedef std::hash<String> 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<char_type>('0' + i);
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(int, char**)
{
test<std::string_view>();
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
test<std::u8string_view>();
#endif
test<std::u16string_view>();
test<std::u32string_view>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test<std::wstring_view>();
#endif
return 0;
}