From dbabdb5220c44e5938d404eefb84b5ed55667ea8 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Dec 02 2017 12:47:11 +0000 Subject: Vendor import of libc++ release_50 branch r319231: https://llvm.org/svn/llvm-project/libcxx/branches/release_50@319231 --- diff --git a/include/algorithm b/include/algorithm index 4542275..00db6d7 100644 --- a/include/algorithm +++ b/include/algorithm @@ -3013,6 +3013,7 @@ template _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { + const size_t _WRt = numeric_limits::digits; result_type _Sp = 0; for (size_t __k = 0; __k < __n0_; ++__k) { @@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { __u = __e_() - _Engine::min(); } while (__u >= __y0_); - if (__w0_ < _WDt) + if (__w0_ < _WRt) _Sp <<= __w0_; else _Sp = 0; @@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { __u = __e_() - _Engine::min(); } while (__u >= __y1_); - if (__w0_ < _WDt - 1) + if (__w0_ < _WRt - 1) _Sp <<= __w0_ + 1; else _Sp = 0; diff --git a/include/deque b/include/deque index f795b48..fee7561 100644 --- a/include/deque +++ b/include/deque @@ -1356,7 +1356,6 @@ public: iterator insert(const_iterator __p, initializer_list __il) {return insert(__p, __il.begin(), __il.end());} #endif // _LIBCPP_CXX03_LANG - iterator insert(const_iterator __p, const value_type& __v); iterator insert(const_iterator __p, size_type __n, const value_type& __v); template @@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l, !__is_forward_iterator<_InpIter>::value>::type*) { for (; __f != __l; ++__f) +#ifdef _LIBCPP_CXX03_LANG push_back(*__f); +#else + emplace_back(*__f); +#endif } template diff --git a/include/functional b/include/functional index 83a2e5a..f73c3ca 100644 --- a/include/functional +++ b/include/functional @@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> return reinterpret_cast<__base*>(p); } - template ::value && - __invokable<_Fp&, _ArgTypes...>::value> - struct __callable; + template , function>::value>, + __invokable<_Fp&, _ArgTypes...> + >::value> + struct __callable; template struct __callable<_Fp, true> { @@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> { static const bool value = false; }; + + template + using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type; public: typedef _Rp result_type; @@ -1622,9 +1627,7 @@ public: function(nullptr_t) _NOEXCEPT : __f_(0) {} function(const function&); function(function&&) _NOEXCEPT; - template::value && !is_same<_Fp, function>::value - >::type> + template> function(_Fp); #if _LIBCPP_STD_VER <= 14 @@ -1638,21 +1641,15 @@ public: function(allocator_arg_t, const _Alloc&, const function&); template function(allocator_arg_t, const _Alloc&, function&&); - template::value>::type> + template> function(allocator_arg_t, const _Alloc& __a, _Fp __f); #endif function& operator=(const function&); function& operator=(function&&) _NOEXCEPT; function& operator=(nullptr_t) _NOEXCEPT; - template - typename enable_if - < - __callable::type>::value && - !is_same::type, function>::value, - function& - >::type - operator=(_Fp&&); + template> + function& operator=(_Fp&&); ~function(); @@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT } template -template -typename enable_if -< - function<_Rp(_ArgTypes...)>::template __callable::type>::value && - !is_same::type, function<_Rp(_ArgTypes...)>>::value, - function<_Rp(_ArgTypes...)>& ->::type +template +function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) { function(_VSTD::forward<_Fp>(__f)).swap(*this); diff --git a/include/list b/include/list index 20a66c3..9c70fff 100644 --- a/include/list +++ b/include/list @@ -992,6 +992,15 @@ public: void push_front(const value_type& __x); void push_back(const value_type& __x); +#ifndef _LIBCPP_CXX03_LANG + template + _LIBCPP_INLINE_VISIBILITY + void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); } +#else + _LIBCPP_INLINE_VISIBILITY + void __emplace_back(value_type const& __arg) { push_back(__arg); } +#endif + iterator insert(const_iterator __p, const value_type& __x); iterator insert(const_iterator __p, size_type __n, const value_type& __x); template @@ -1189,7 +1198,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, __get_db()->__insert_c(this); #endif for (; __f != __l; ++__f) - push_back(*__f); + __emplace_back(*__f); } template @@ -1202,7 +1211,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a, __get_db()->__insert_c(this); #endif for (; __f != __l; ++__f) - push_back(*__f); + __emplace_back(*__f); } template diff --git a/include/string b/include/string index 610f19e..7775587 100644 --- a/include/string +++ b/include/string @@ -259,7 +259,7 @@ public: size_type find(value_type c, size_type pos = 0) const noexcept; size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; - size_type ffind(basic_string_view sv, size_type pos = 0) const noexcept; + size_type rfind(basic_string_view sv, size_type pos = npos) const noexcept; size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; size_type rfind(const value_type* s, size_type pos = npos) const noexcept; size_type rfind(value_type c, size_type pos = npos) const noexcept; @@ -271,7 +271,7 @@ public: size_type find_first_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; - size_type find_last_of(basic_string_view sv, size_type pos = 0) const noexcept; + size_type find_last_of(basic_string_view sv, size_type pos = npos) const noexcept; size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_of(value_type c, size_type pos = npos) const noexcept; @@ -283,7 +283,7 @@ public: size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; - size_type find_last_not_of(basic_string_view sv, size_type pos = 0) const noexcept; + size_type find_last_not_of(basic_string_view sv, size_type pos = npos) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; @@ -1147,7 +1147,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; @@ -1166,7 +1166,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; @@ -1186,7 +1186,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; diff --git a/include/type_traits b/include/type_traits index 9db4d66..6c111ab 100644 --- a/include/type_traits +++ b/include/type_traits @@ -4339,8 +4339,8 @@ struct __invokable_r using _Result = decltype( _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)); - static const bool value = - conditional< + using type = + typename conditional< !is_same<_Result, __nat>::value, typename conditional< is_void<_Ret>::value, @@ -4348,7 +4348,8 @@ struct __invokable_r is_convertible<_Result, _Ret> >::type, false_type - >::type::value; + >::type; + static const bool value = type::value; }; template diff --git a/include/vector b/include/vector index 6e9920a..b2f8f09 100644 --- a/include/vector +++ b/include/vector @@ -674,6 +674,17 @@ public: const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(this->__begin_);} +#ifdef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + void __emplace_back(const value_type& __x) { push_back(__x); } +#else + template + _LIBCPP_INLINE_VISIBILITY + void __emplace_back(_Arg&& __arg) { + emplace_back(_VSTD::forward<_Arg>(__arg)); + } +#endif + _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); #ifndef _LIBCPP_CXX03_LANG @@ -1128,7 +1139,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, __get_db()->__insert_c(this); #endif for (; __first != __last; ++__first) - push_back(*__first); + __emplace_back(*__first); } template @@ -1145,7 +1156,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c __get_db()->__insert_c(this); #endif for (; __first != __last; ++__first) - push_back(*__first); + __emplace_back(*__first); } template @@ -1365,7 +1376,7 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { clear(); for (; __first != __last; ++__first) - push_back(*__first); + __emplace_back(*__first); } template diff --git a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp index f060677..940d4e8 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp @@ -19,6 +19,9 @@ #include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#endif template C @@ -80,7 +83,7 @@ testNI(int start, int N, int M) testI(c1, c2); } -int main() +void basic_test() { { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; @@ -103,3 +106,51 @@ int main() } #endif } + +void test_emplacable_concept() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructibleMoveableAndAssignable; + using It = random_access_iterator; + { + std::deque v; + v.assign(It(arr1), It(std::end(arr1))); + assert(v[0].value == 42); + } + { + std::deque v; + v.assign(It(arr2), It(std::end(arr2))); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleMoveableAndAssignable; + using It = input_iterator; + { + std::deque v; + v.assign(It(arr1), It(std::end(arr1))); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::deque v; + v.assign(It(arr2), It(std::end(arr2))); + //assert(v[0].copied == 0); + assert(v[0].value == 1); + //assert(v[1].copied == 0); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); + } + } +#endif +} + +int main() { + basic_test(); + test_emplacable_concept(); +} diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp index 87445c5..793f2b1 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp @@ -15,9 +15,13 @@ #include #include +#include "test_macros.h" #include "test_allocator.h" #include "test_iterators.h" #include "min_allocator.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#endif template void @@ -48,7 +52,7 @@ test(InputIterator f, InputIterator l) assert(*i == *f); } -int main() +void basic_test() { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -61,3 +65,48 @@ int main() test >(ab, an); #endif } + + +void test_emplacable_concept() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructibleAndMoveable; + using It = random_access_iterator; + { + std::deque v(It(arr1), It(std::end(arr1))); + assert(v[0].value == 42); + } + { + std::deque v(It(arr2), It(std::end(arr2))); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleAndMoveable; + using It = input_iterator; + { + std::deque v(It(arr1), It(std::end(arr1))); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::deque v(It(arr2), It(std::end(arr2))); + //assert(v[0].copied == 0); + assert(v[0].value == 1); + //assert(v[1].copied == 0); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); + } + } +#endif +} + +int main() { + basic_test(); + test_emplacable_concept(); +} diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp index 54227eb..9ac342a 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp @@ -16,9 +16,13 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" #include "test_allocator.h" #include "min_allocator.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#endif template void @@ -35,7 +39,7 @@ test(InputIterator f, InputIterator l, const Allocator& a) assert(*i == *f); } -int main() +void basic_test() { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -50,3 +54,50 @@ int main() test(random_access_iterator(ab), random_access_iterator(an), min_allocator()); #endif } + + +void test_emplacable_concept() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructibleAndMoveable; + using It = random_access_iterator; + std::allocator a; + { + std::deque v(It(arr1), It(std::end(arr1)), a); + assert(v[0].value == 42); + } + { + std::deque v(It(arr2), It(std::end(arr2)), a); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleAndMoveable; + using It = input_iterator; + std::allocator a; + { + std::deque v(It(arr1), It(std::end(arr1)), a); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::deque v(It(arr2), It(std::end(arr2)), a); + //assert(v[0].copied == 0); + assert(v[0].value == 1); + //assert(v[1].copied == 0); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); + } + } +#endif +} + +int main() { + basic_test(); + test_emplacable_concept(); +} diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp index 3b3c2f7..3cdcc73 100644 --- a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp @@ -17,8 +17,12 @@ #include "test_iterators.h" #include "test_allocator.h" #include "min_allocator.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#include "container_test_types.h" +#endif -int main() +void basic_test() { { int a[] = {0, 1, 2, 3}; @@ -76,3 +80,179 @@ int main() } #endif } + + + +void test_emplacable_concept() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructible; + using It = random_access_iterator; + { + std::list v(It(arr1), It(std::end(arr1))); + auto I = v.begin(); + assert(I->value == 42); + } + { + std::list v(It(arr2), It(std::end(arr2))); + auto I = v.begin(); + assert(I->value == 1); + ++I; + assert(I->value == 101); + ++I; + assert(I->value == 42); + } + } + { + using T = EmplaceConstructible; + using It = input_iterator; + { + std::list v(It(arr1), It(std::end(arr1))); + auto I = v.begin(); + assert(I->value == 42); + } + { + std::list v(It(arr2), It(std::end(arr2))); + auto I = v.begin(); + //assert(v[0].copied == 0); + assert(I->value == 1); + //assert(v[1].copied == 0); + ++I; + assert(I->value == 101); + ++I; + assert(I->value == 42); + } + } +#endif +} + + + +void test_emplacable_concept_with_alloc() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructible; + using It = random_access_iterator; + std::allocator a; + { + std::list v(It(arr1), It(std::end(arr1)), a); + auto I = v.begin(); + assert(I->value == 42); + } + { + std::list v(It(arr2), It(std::end(arr2)), a); + auto I = v.begin(); + assert(I->value == 1); + ++I; + assert(I->value == 101); + ++I; + assert(I->value == 42); + } + } + { + using T = EmplaceConstructible; + using It = input_iterator; + std::allocator a; + { + std::list v(It(arr1), It(std::end(arr1)), a); + auto I = v.begin(); + assert(I->value == 42); + } + { + std::list v(It(arr2), It(std::end(arr2)), a); + auto I = v.begin(); + //assert(v[0].copied == 0); + assert(I->value == 1); + //assert(v[1].copied == 0); + ++I; + assert(I->value == 101); + ++I; + assert(I->value == 42); + } + } +#endif +} + +void test_ctor_under_alloc() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using C = TCT::list<>; + using T = typename C::value_type; + using It = forward_iterator; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1))); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2))); + } + } + { + using C = TCT::list<>; + using T = typename C::value_type; + using It = input_iterator; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1))); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2))); + } + } +#endif +} + +void test_ctor_under_alloc_with_alloc() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using C = TCT::list<>; + using T = typename C::value_type; + using It = forward_iterator; + using Alloc = typename C::allocator_type; + Alloc a; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1)), a); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2)), a); + } + } + { + using C = TCT::list<>; + using T = typename C::value_type; + using It = input_iterator; + using Alloc = typename C::allocator_type; + Alloc a; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1)), a); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2)), a); + } + } +#endif +} + + + +int main() { + basic_test(); + test_emplacable_concept(); + test_emplacable_concept_with_alloc(); + test_ctor_under_alloc(); + test_ctor_under_alloc_with_alloc(); +} diff --git a/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp new file mode 100644 index 0000000..f074956 --- /dev/null +++ b/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(size_type n, const_reference v); + +#include +#include +#include +#include +#include "test_macros.h" +#include "min_allocator.h" +#include "asan_testing.h" +#include "test_iterators.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#include "container_test_types.h" +#endif + + +void test_emplaceable_concept() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructibleMoveableAndAssignable; + using It = forward_iterator; + { + std::vector v; + v.assign(It(arr1), It(std::end(arr1))); + assert(v[0].value == 42); + } + { + std::vector v; + v.assign(It(arr2), It(std::end(arr2))); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleMoveableAndAssignable; + using It = input_iterator; + { + std::vector v; + v.assign(It(arr1), It(std::end(arr1))); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::vector v; + v.assign(It(arr2), It(std::end(arr2))); + //assert(v[0].copied == 0); + assert(v[0].value == 1); + //assert(v[1].copied == 0); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); + } + } +#endif +} + + + +int main() +{ + test_emplaceable_concept(); +} diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index ec4944d..88613ef 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -20,40 +20,137 @@ #include "test_allocator.h" #include "min_allocator.h" #include "asan_testing.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#include "container_test_types.h" +#endif template -void -test(Iterator first, Iterator last) -{ - C c(first, last); - LIBCPP_ASSERT(c.__invariants()); - assert(c.size() == static_cast(std::distance(first, last))); - LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); - for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) - assert(*i == *first); +void test(Iterator first, Iterator last) { + C c(first, last); + LIBCPP_ASSERT(c.__invariants()); + assert(c.size() == static_cast(std::distance(first, last))); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; + ++i, ++first) + assert(*i == *first); +} + +static void basic_test_cases() { + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; + int* an = a + sizeof(a) / sizeof(a[0]); + test >(input_iterator(a), + input_iterator(an)); + test >(forward_iterator(a), + forward_iterator(an)); + test >(bidirectional_iterator(a), + bidirectional_iterator(an)); + test >(random_access_iterator(a), + random_access_iterator(an)); + test >(a, an); + + test > >( + input_iterator(a), input_iterator(an)); + // Add 1 for implementations that dynamically allocate a container proxy. + test > >( + forward_iterator(a), forward_iterator(an)); + test > >( + bidirectional_iterator(a), + bidirectional_iterator(an)); + test > >( + random_access_iterator(a), + random_access_iterator(an)); + test > >(a, an); +#if TEST_STD_VER >= 11 + test > >(input_iterator(a), + input_iterator(an)); + test > >( + forward_iterator(a), forward_iterator(an)); + test > >( + bidirectional_iterator(a), + bidirectional_iterator(an)); + test > >( + random_access_iterator(a), + random_access_iterator(an)); + test >(a, an); +#endif } -int main() -{ - int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; - int* an = a + sizeof(a)/sizeof(a[0]); - test >(input_iterator(a), input_iterator(an)); - test >(forward_iterator(a), forward_iterator(an)); - test >(bidirectional_iterator(a), bidirectional_iterator(an)); - test >(random_access_iterator(a), random_access_iterator(an)); - test >(a, an); - - test > >(input_iterator(a), input_iterator(an)); - // Add 1 for implementations that dynamically allocate a container proxy. - test > >(forward_iterator(a), forward_iterator(an)); - test > >(bidirectional_iterator(a), bidirectional_iterator(an)); - test > >(random_access_iterator(a), random_access_iterator(an)); - test > >(a, an); +void emplaceable_concept_tests() { #if TEST_STD_VER >= 11 - test> >(input_iterator(a), input_iterator(an)); - test> >(forward_iterator(a), forward_iterator(an)); - test> >(bidirectional_iterator(a), bidirectional_iterator(an)); - test> >(random_access_iterator(a), random_access_iterator(an)); - test >(a, an); + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructible; + using It = forward_iterator; + { + std::vector v(It(arr1), It(std::end(arr1))); + assert(v[0].value == 42); + } + { + std::vector v(It(arr2), It(std::end(arr2))); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleAndMoveInsertable; + using It = input_iterator; + { + std::vector v(It(arr1), It(std::end(arr1))); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::vector v(It(arr2), It(std::end(arr2))); + //assert(v[0].copied == 0); + assert(v[0].value == 1); + //assert(v[1].copied == 0); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); + } + } #endif } + +void test_ctor_under_alloc() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using C = TCT::vector<>; + using T = typename C::value_type; + using It = forward_iterator; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1))); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2))); + } + } + { + using C = TCT::vector<>; + using T = typename C::value_type; + using It = input_iterator; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1))); + } + { + //ExpectConstructGuard G(3); + //C v(It(arr2), It(std::end(arr2)), a); + } + } +#endif +} + + +int main() { + basic_test_cases(); + emplaceable_concept_tests(); // See PR34898 + test_ctor_under_alloc(); +} diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index b4482dd..71743b3 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -21,56 +21,152 @@ #include "test_allocator.h" #include "min_allocator.h" #include "asan_testing.h" +#if TEST_STD_VER >= 11 +#include "emplace_constructible.h" +#include "container_test_types.h" +#endif template -void -test(Iterator first, Iterator last, const A& a) -{ - C c(first, last, a); - LIBCPP_ASSERT(c.__invariants()); - assert(c.size() == static_cast(std::distance(first, last))); - LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); - for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) - assert(*i == *first); +void test(Iterator first, Iterator last, const A& a) { + C c(first, last, a); + LIBCPP_ASSERT(c.__invariants()); + assert(c.size() == static_cast(std::distance(first, last))); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; + ++i, ++first) + assert(*i == *first); } #if TEST_STD_VER >= 11 template -struct implicit_conv_allocator : min_allocator -{ - implicit_conv_allocator(void*) {} - implicit_conv_allocator(const implicit_conv_allocator&) = default; +struct implicit_conv_allocator : min_allocator { + implicit_conv_allocator(void*) {} + implicit_conv_allocator(const implicit_conv_allocator&) = default; - template - implicit_conv_allocator(implicit_conv_allocator) {} + template + implicit_conv_allocator(implicit_conv_allocator) {} }; #endif -int main() -{ - { +void basic_tests() { + { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; - int* an = a + sizeof(a)/sizeof(a[0]); + int* an = a + sizeof(a) / sizeof(a[0]); std::allocator alloc; - test >(input_iterator(a), input_iterator(an), alloc); - test >(forward_iterator(a), forward_iterator(an), alloc); - test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); - test >(random_access_iterator(a), random_access_iterator(an), alloc); + test >(input_iterator(a), + input_iterator(an), alloc); + test >(forward_iterator(a), + forward_iterator(an), alloc); + test >(bidirectional_iterator(a), + bidirectional_iterator(an), alloc); + test >(random_access_iterator(a), + random_access_iterator(an), alloc); test >(a, an, alloc); - } + } #if TEST_STD_VER >= 11 - { + { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; - int* an = a + sizeof(a)/sizeof(a[0]); + int* an = a + sizeof(a) / sizeof(a[0]); min_allocator alloc; - test> >(input_iterator(a), input_iterator(an), alloc); - test> >(forward_iterator(a), forward_iterator(an), alloc); - test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); - test> >(random_access_iterator(a), random_access_iterator(an), alloc); - test> >(a, an, alloc); - test> >(a, an, nullptr); + test > >( + input_iterator(a), input_iterator(an), alloc); + test > >( + forward_iterator(a), forward_iterator(an), + alloc); + test > >( + bidirectional_iterator(a), + bidirectional_iterator(an), alloc); + test > >( + random_access_iterator(a), + random_access_iterator(an), alloc); + test > >(a, an, alloc); + test > >(a, an, nullptr); + } +#endif +} + +void emplaceable_concept_tests() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using T = EmplaceConstructible; + using It = forward_iterator; + using Alloc = std::allocator; + Alloc a; + { + std::vector v(It(arr1), It(std::end(arr1)), a); + assert(v[0].value == 42); + } + { + std::vector v(It(arr2), It(std::end(arr2)), a); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].value == 42); + } + } + { + using T = EmplaceConstructibleAndMoveInsertable; + using It = input_iterator; + using Alloc = std::allocator; + Alloc a; + { + std::vector v(It(arr1), It(std::end(arr1)), a); + assert(v[0].copied == 0); + assert(v[0].value == 42); + } + { + std::vector v(It(arr2), It(std::end(arr2)), a); + assert(v[0].value == 1); + assert(v[1].value == 101); + assert(v[2].copied == 0); + assert(v[2].value == 42); } + } #endif } + +void test_ctor_under_alloc() { +#if TEST_STD_VER >= 11 + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + using C = TCT::vector<>; + using T = typename C::value_type; + using It = forward_iterator; + using Alloc = typename C::allocator_type; + Alloc a; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1)), a); + } + { + ExpectConstructGuard G(3); + C v(It(arr2), It(std::end(arr2)), a); + } + } + { + using C = TCT::vector<>; + using T = typename C::value_type; + using It = input_iterator; + using Alloc = typename C::allocator_type; + Alloc a; + { + ExpectConstructGuard G(1); + C v(It(arr1), It(std::end(arr1)), a); + } + { + //ExpectConstructGuard G(3); + //C v(It(arr2), It(std::end(arr2)), a); + } + } +#endif +} + +int main() { + basic_tests(); + emplaceable_concept_tests(); // See PR34898 + test_ctor_under_alloc(); +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp new file mode 100644 index 0000000..6a5ba22 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp @@ -0,0 +1,383 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(size_type pos1, size_type n1, basic_string_vew sv) const; + +#include +#include +#include + +#include "min_allocator.h" + +#include "test_macros.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +void +test(const S& s, typename S::size_type pos1, typename S::size_type n1, + SV sv, int x) +{ + if (pos1 <= s.size()) + assert(sign(s.compare(pos1, n1, sv)) == sign(x)); +#ifndef TEST_HAS_NO_EXCEPTIONS + else + { + try + { + s.compare(pos1, n1, sv); + assert(false); + } + catch (std::out_of_range&) + { + assert(pos1 > s.size()); + } + } +#endif +} + +template +void test0() +{ + test(S(""), 0, 0, SV(""), 0); + test(S(""), 0, 0, SV("abcde"), -5); + test(S(""), 0, 0, SV("abcdefghij"), -10); + test(S(""), 0, 0, SV("abcdefghijklmnopqrst"), -20); + test(S(""), 0, 1, SV(""), 0); + test(S(""), 0, 1, SV("abcde"), -5); + test(S(""), 0, 1, SV("abcdefghij"), -10); + test(S(""), 0, 1, SV("abcdefghijklmnopqrst"), -20); + test(S(""), 1, 0, SV(""), 0); + test(S(""), 1, 0, SV("abcde"), 0); + test(S(""), 1, 0, SV("abcdefghij"), 0); + test(S(""), 1, 0, SV("abcdefghijklmnopqrst"), 0); + test(S("abcde"), 0, 0, SV(""), 0); + test(S("abcde"), 0, 0, SV("abcde"), -5); + test(S("abcde"), 0, 0, SV("abcdefghij"), -10); + test(S("abcde"), 0, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 0, 1, SV(""), 1); + test(S("abcde"), 0, 1, SV("abcde"), -4); + test(S("abcde"), 0, 1, SV("abcdefghij"), -9); + test(S("abcde"), 0, 1, SV("abcdefghijklmnopqrst"), -19); + test(S("abcde"), 0, 2, SV(""), 2); + test(S("abcde"), 0, 2, SV("abcde"), -3); + test(S("abcde"), 0, 2, SV("abcdefghij"), -8); + test(S("abcde"), 0, 2, SV("abcdefghijklmnopqrst"), -18); + test(S("abcde"), 0, 4, SV(""), 4); + test(S("abcde"), 0, 4, SV("abcde"), -1); + test(S("abcde"), 0, 4, SV("abcdefghij"), -6); + test(S("abcde"), 0, 4, SV("abcdefghijklmnopqrst"), -16); + test(S("abcde"), 0, 5, SV(""), 5); + test(S("abcde"), 0, 5, SV("abcde"), 0); + test(S("abcde"), 0, 5, SV("abcdefghij"), -5); + test(S("abcde"), 0, 5, SV("abcdefghijklmnopqrst"), -15); + test(S("abcde"), 0, 6, SV(""), 5); + test(S("abcde"), 0, 6, SV("abcde"), 0); + test(S("abcde"), 0, 6, SV("abcdefghij"), -5); + test(S("abcde"), 0, 6, SV("abcdefghijklmnopqrst"), -15); + test(S("abcde"), 1, 0, SV(""), 0); + test(S("abcde"), 1, 0, SV("abcde"), -5); + test(S("abcde"), 1, 0, SV("abcdefghij"), -10); + test(S("abcde"), 1, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 1, 1, SV(""), 1); + test(S("abcde"), 1, 1, SV("abcde"), 1); + test(S("abcde"), 1, 1, SV("abcdefghij"), 1); + test(S("abcde"), 1, 1, SV("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 2, SV(""), 2); + test(S("abcde"), 1, 2, SV("abcde"), 1); + test(S("abcde"), 1, 2, SV("abcdefghij"), 1); + test(S("abcde"), 1, 2, SV("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 3, SV(""), 3); + test(S("abcde"), 1, 3, SV("abcde"), 1); + test(S("abcde"), 1, 3, SV("abcdefghij"), 1); + test(S("abcde"), 1, 3, SV("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 4, SV(""), 4); + test(S("abcde"), 1, 4, SV("abcde"), 1); + test(S("abcde"), 1, 4, SV("abcdefghij"), 1); + test(S("abcde"), 1, 4, SV("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 1, 5, SV(""), 4); + test(S("abcde"), 1, 5, SV("abcde"), 1); + test(S("abcde"), 1, 5, SV("abcdefghij"), 1); + test(S("abcde"), 1, 5, SV("abcdefghijklmnopqrst"), 1); + test(S("abcde"), 2, 0, SV(""), 0); + test(S("abcde"), 2, 0, SV("abcde"), -5); + test(S("abcde"), 2, 0, SV("abcdefghij"), -10); + test(S("abcde"), 2, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 2, 1, SV(""), 1); + test(S("abcde"), 2, 1, SV("abcde"), 2); + test(S("abcde"), 2, 1, SV("abcdefghij"), 2); + test(S("abcde"), 2, 1, SV("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 2, SV(""), 2); + test(S("abcde"), 2, 2, SV("abcde"), 2); + test(S("abcde"), 2, 2, SV("abcdefghij"), 2); + test(S("abcde"), 2, 2, SV("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 3, SV(""), 3); + test(S("abcde"), 2, 3, SV("abcde"), 2); + test(S("abcde"), 2, 3, SV("abcdefghij"), 2); + test(S("abcde"), 2, 3, SV("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 2, 4, SV(""), 3); + test(S("abcde"), 2, 4, SV("abcde"), 2); + test(S("abcde"), 2, 4, SV("abcdefghij"), 2); + test(S("abcde"), 2, 4, SV("abcdefghijklmnopqrst"), 2); + test(S("abcde"), 4, 0, SV(""), 0); + test(S("abcde"), 4, 0, SV("abcde"), -5); + test(S("abcde"), 4, 0, SV("abcdefghij"), -10); + test(S("abcde"), 4, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 4, 1, SV(""), 1); + test(S("abcde"), 4, 1, SV("abcde"), 4); + test(S("abcde"), 4, 1, SV("abcdefghij"), 4); + test(S("abcde"), 4, 1, SV("abcdefghijklmnopqrst"), 4); + test(S("abcde"), 4, 2, SV(""), 1); + test(S("abcde"), 4, 2, SV("abcde"), 4); + test(S("abcde"), 4, 2, SV("abcdefghij"), 4); + test(S("abcde"), 4, 2, SV("abcdefghijklmnopqrst"), 4); + test(S("abcde"), 5, 0, SV(""), 0); + test(S("abcde"), 5, 0, SV("abcde"), -5); + test(S("abcde"), 5, 0, SV("abcdefghij"), -10); + test(S("abcde"), 5, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), 5, 1, SV(""), 0); + test(S("abcde"), 5, 1, SV("abcde"), -5); + test(S("abcde"), 5, 1, SV("abcdefghij"), -10); + test(S("abcde"), 5, 1, SV("abcdefghijklmnopqrst"), -20); +} + +template +void test1() +{ + test(S("abcde"), 6, 0, SV(""), 0); + test(S("abcde"), 6, 0, SV("abcde"), 0); + test(S("abcde"), 6, 0, SV("abcdefghij"), 0); + test(S("abcde"), 6, 0, SV("abcdefghijklmnopqrst"), 0); + test(S("abcdefghij"), 0, 0, SV(""), 0); + test(S("abcdefghij"), 0, 0, SV("abcde"), -5); + test(S("abcdefghij"), 0, 0, SV("abcdefghij"), -10); + test(S("abcdefghij"), 0, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 0, 1, SV(""), 1); + test(S("abcdefghij"), 0, 1, SV("abcde"), -4); + test(S("abcdefghij"), 0, 1, SV("abcdefghij"), -9); + test(S("abcdefghij"), 0, 1, SV("abcdefghijklmnopqrst"), -19); + test(S("abcdefghij"), 0, 5, SV(""), 5); + test(S("abcdefghij"), 0, 5, SV("abcde"), 0); + test(S("abcdefghij"), 0, 5, SV("abcdefghij"), -5); + test(S("abcdefghij"), 0, 5, SV("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), 0, 9, SV(""), 9); + test(S("abcdefghij"), 0, 9, SV("abcde"), 4); + test(S("abcdefghij"), 0, 9, SV("abcdefghij"), -1); + test(S("abcdefghij"), 0, 9, SV("abcdefghijklmnopqrst"), -11); + test(S("abcdefghij"), 0, 10, SV(""), 10); + test(S("abcdefghij"), 0, 10, SV("abcde"), 5); + test(S("abcdefghij"), 0, 10, SV("abcdefghij"), 0); + test(S("abcdefghij"), 0, 10, SV("abcdefghijklmnopqrst"), -10); + test(S("abcdefghij"), 0, 11, SV(""), 10); + test(S("abcdefghij"), 0, 11, SV("abcde"), 5); + test(S("abcdefghij"), 0, 11, SV("abcdefghij"), 0); + test(S("abcdefghij"), 0, 11, SV("abcdefghijklmnopqrst"), -10); + test(S("abcdefghij"), 1, 0, SV(""), 0); + test(S("abcdefghij"), 1, 0, SV("abcde"), -5); + test(S("abcdefghij"), 1, 0, SV("abcdefghij"), -10); + test(S("abcdefghij"), 1, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 1, 1, SV(""), 1); + test(S("abcdefghij"), 1, 1, SV("abcde"), 1); + test(S("abcdefghij"), 1, 1, SV("abcdefghij"), 1); + test(S("abcdefghij"), 1, 1, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 4, SV(""), 4); + test(S("abcdefghij"), 1, 4, SV("abcde"), 1); + test(S("abcdefghij"), 1, 4, SV("abcdefghij"), 1); + test(S("abcdefghij"), 1, 4, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 8, SV(""), 8); + test(S("abcdefghij"), 1, 8, SV("abcde"), 1); + test(S("abcdefghij"), 1, 8, SV("abcdefghij"), 1); + test(S("abcdefghij"), 1, 8, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 9, SV(""), 9); + test(S("abcdefghij"), 1, 9, SV("abcde"), 1); + test(S("abcdefghij"), 1, 9, SV("abcdefghij"), 1); + test(S("abcdefghij"), 1, 9, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 1, 10, SV(""), 9); + test(S("abcdefghij"), 1, 10, SV("abcde"), 1); + test(S("abcdefghij"), 1, 10, SV("abcdefghij"), 1); + test(S("abcdefghij"), 1, 10, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghij"), 5, 0, SV(""), 0); + test(S("abcdefghij"), 5, 0, SV("abcde"), -5); + test(S("abcdefghij"), 5, 0, SV("abcdefghij"), -10); + test(S("abcdefghij"), 5, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 5, 1, SV(""), 1); + test(S("abcdefghij"), 5, 1, SV("abcde"), 5); + test(S("abcdefghij"), 5, 1, SV("abcdefghij"), 5); + test(S("abcdefghij"), 5, 1, SV("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 2, SV(""), 2); + test(S("abcdefghij"), 5, 2, SV("abcde"), 5); + test(S("abcdefghij"), 5, 2, SV("abcdefghij"), 5); + test(S("abcdefghij"), 5, 2, SV("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 4, SV(""), 4); + test(S("abcdefghij"), 5, 4, SV("abcde"), 5); + test(S("abcdefghij"), 5, 4, SV("abcdefghij"), 5); + test(S("abcdefghij"), 5, 4, SV("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 5, SV(""), 5); + test(S("abcdefghij"), 5, 5, SV("abcde"), 5); + test(S("abcdefghij"), 5, 5, SV("abcdefghij"), 5); + test(S("abcdefghij"), 5, 5, SV("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 5, 6, SV(""), 5); + test(S("abcdefghij"), 5, 6, SV("abcde"), 5); + test(S("abcdefghij"), 5, 6, SV("abcdefghij"), 5); + test(S("abcdefghij"), 5, 6, SV("abcdefghijklmnopqrst"), 5); + test(S("abcdefghij"), 9, 0, SV(""), 0); + test(S("abcdefghij"), 9, 0, SV("abcde"), -5); + test(S("abcdefghij"), 9, 0, SV("abcdefghij"), -10); + test(S("abcdefghij"), 9, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 9, 1, SV(""), 1); + test(S("abcdefghij"), 9, 1, SV("abcde"), 9); + test(S("abcdefghij"), 9, 1, SV("abcdefghij"), 9); + test(S("abcdefghij"), 9, 1, SV("abcdefghijklmnopqrst"), 9); + test(S("abcdefghij"), 9, 2, SV(""), 1); + test(S("abcdefghij"), 9, 2, SV("abcde"), 9); + test(S("abcdefghij"), 9, 2, SV("abcdefghij"), 9); + test(S("abcdefghij"), 9, 2, SV("abcdefghijklmnopqrst"), 9); + test(S("abcdefghij"), 10, 0, SV(""), 0); + test(S("abcdefghij"), 10, 0, SV("abcde"), -5); + test(S("abcdefghij"), 10, 0, SV("abcdefghij"), -10); + test(S("abcdefghij"), 10, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 10, 1, SV(""), 0); + test(S("abcdefghij"), 10, 1, SV("abcde"), -5); + test(S("abcdefghij"), 10, 1, SV("abcdefghij"), -10); + test(S("abcdefghij"), 10, 1, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghij"), 11, 0, SV(""), 0); + test(S("abcdefghij"), 11, 0, SV("abcde"), 0); + test(S("abcdefghij"), 11, 0, SV("abcdefghij"), 0); + test(S("abcdefghij"), 11, 0, SV("abcdefghijklmnopqrst"), 0); +} + +template +void test2() +{ + test(S("abcdefghijklmnopqrst"), 0, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 0, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 0, 1, SV(""), 1); + test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcde"), -4); + test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcdefghij"), -9); + test(S("abcdefghijklmnopqrst"), 0, 1, SV("abcdefghijklmnopqrst"), -19); + test(S("abcdefghijklmnopqrst"), 0, 10, SV(""), 10); + test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcde"), 5); + test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcdefghij"), 0); + test(S("abcdefghijklmnopqrst"), 0, 10, SV("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), 0, 19, SV(""), 19); + test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcde"), 14); + test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcdefghij"), 9); + test(S("abcdefghijklmnopqrst"), 0, 19, SV("abcdefghijklmnopqrst"), -1); + test(S("abcdefghijklmnopqrst"), 0, 20, SV(""), 20); + test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcde"), 15); + test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 0, 20, SV("abcdefghijklmnopqrst"), 0); + test(S("abcdefghijklmnopqrst"), 0, 21, SV(""), 20); + test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcde"), 15); + test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 0, 21, SV("abcdefghijklmnopqrst"), 0); + test(S("abcdefghijklmnopqrst"), 1, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 1, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 1, 1, SV(""), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 1, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, SV(""), 9); + test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 9, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, SV(""), 18); + test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 18, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, SV(""), 19); + test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 19, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, SV(""), 19); + test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcde"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcdefghij"), 1); + test(S("abcdefghijklmnopqrst"), 1, 20, SV("abcdefghijklmnopqrst"), 1); + test(S("abcdefghijklmnopqrst"), 10, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 10, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 10, 1, SV(""), 1); + test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 1, SV("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, SV(""), 5); + test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 5, SV("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, SV(""), 9); + test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 9, SV("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, SV(""), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 10, SV("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, SV(""), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcde"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), 10, 11, SV("abcdefghijklmnopqrst"), 10); + test(S("abcdefghijklmnopqrst"), 19, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 19, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 19, 1, SV(""), 1); + test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcde"), 19); + test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcdefghij"), 19); + test(S("abcdefghijklmnopqrst"), 19, 1, SV("abcdefghijklmnopqrst"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, SV(""), 1); + test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcde"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcdefghij"), 19); + test(S("abcdefghijklmnopqrst"), 19, 2, SV("abcdefghijklmnopqrst"), 19); + test(S("abcdefghijklmnopqrst"), 20, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 20, 0, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 20, 1, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcde"), -5); + test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcdefghij"), -10); + test(S("abcdefghijklmnopqrst"), 20, 1, SV("abcdefghijklmnopqrst"), -20); + test(S("abcdefghijklmnopqrst"), 21, 0, SV(""), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcde"), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcdefghij"), 0); + test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcdefghijklmnopqrst"), 0); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + test2(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + test2(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp new file mode 100644 index 0000000..8f0d488 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(const basic_string_view sv) const + +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +void +test(const S& s, SV sv, int x) +{ + assert(sign(s.compare(sv)) == sign(x)); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test(S(""), SV(""), 0); + test(S(""), SV("abcde"), -5); + test(S(""), SV("abcdefghij"), -10); + test(S(""), SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), SV(""), 5); + test(S("abcde"), SV("abcde"), 0); + test(S("abcde"), SV("abcdefghij"), -5); + test(S("abcde"), SV("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), SV(""), 10); + test(S("abcdefghij"), SV("abcde"), 5); + test(S("abcdefghij"), SV("abcdefghij"), 0); + test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), SV(""), 20); + test(S("abcdefghijklmnopqrst"), SV("abcde"), 15); + test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test(S(""), SV(""), 0); + test(S(""), SV("abcde"), -5); + test(S(""), SV("abcdefghij"), -10); + test(S(""), SV("abcdefghijklmnopqrst"), -20); + test(S("abcde"), SV(""), 5); + test(S("abcde"), SV("abcde"), 0); + test(S("abcde"), SV("abcdefghij"), -5); + test(S("abcde"), SV("abcdefghijklmnopqrst"), -15); + test(S("abcdefghij"), SV(""), 10); + test(S("abcdefghij"), SV("abcde"), 5); + test(S("abcdefghij"), SV("abcdefghij"), 0); + test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10); + test(S("abcdefghijklmnopqrst"), SV(""), 20); + test(S("abcdefghijklmnopqrst"), SV("abcde"), 15); + test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10); + test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp new file mode 100644 index 0000000..fb69f8b --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(basic_string_view sv, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_first_not_of(sv, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.find_first_not_of(sv) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, S::npos); + test(S(""), SV("laenf"), 0, S::npos); + test(S(""), SV("pqlnkmbdjo"), 0, S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), SV(""), 1, S::npos); + test(S(""), SV("bjaht"), 1, S::npos); + test(S(""), SV("hjlcmgpket"), 1, S::npos); + test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), SV(""), 0, 0); + test(S("qanej"), SV("dfkap"), 0, 0); + test(S("clbao"), SV("ihqrfebgad"), 0, 0); + test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, S::npos); + test(S("srdfq"), SV(""), 1, 1); + test(S("oemth"), SV("ikcrq"), 1, 1); + test(S("cdaih"), SV("dmajblfhsg"), 1, 3); + test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, S::npos); + test(S("cshmd"), SV(""), 2, 2); + test(S("lhcdo"), SV("oebqi"), 2, 2); + test(S("qnsoh"), SV("kojhpmbsfe"), 2, S::npos); + test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, S::npos); + test(S("fmtsp"), SV(""), 4, 4); + test(S("khbpm"), SV("aobjd"), 4, 4); + test(S("pbsji"), SV("pcbahntsje"), 4, 4); + test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, S::npos); + test(S("eqmpa"), SV(""), 5, S::npos); + test(S("omigs"), SV("kocgb"), 5, S::npos); + test(S("onmje"), SV("fbslrjiqkm"), 5, S::npos); + test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), SV(""), 6, S::npos); + test(S("igdsc"), SV("qngpd"), 6, S::npos); + test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), SV(""), 0, 0); + test(S("daiprenocl"), SV("ashjd"), 0, 2); + test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 1); + test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, S::npos); + test(S("qpghtfbaji"), SV(""), 1, 1); + test(S("gfshlcmdjr"), SV("nadkh"), 1, 1); + test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 4); + test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, S::npos); + test(S("crnklpmegd"), SV(""), 5, 5); + test(S("jsbtafedoc"), SV("prqgn"), 5, 5); + test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 6); + test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, S::npos); + test(S("lmofqdhpki"), SV(""), 9, 9); + test(S("hnefkqimca"), SV("rtjpa"), 9, S::npos); + test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 9); + test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, S::npos); + test(S("elgofjmbrq"), SV(""), 10, S::npos); + test(S("mjqdgalkpc"), SV("dplqa"), 10, S::npos); + test(S("kthqnfcerm"), SV("dkacjoptns"), 10, S::npos); + test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), SV(""), 11, S::npos); + test(S("akiteljmoh"), SV("lofbc"), 11, S::npos); + test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, S::npos); + test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), SV(""), 0, 0); + test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 0); + test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 1); + test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, 1); + test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 3); + test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), SV(""), 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 11); + test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 13); + test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, S::npos); + test(S("niptglfbosehkamrdqcj"), SV(""), 19, 19); + test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, S::npos); + test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template +void test1() +{ + test(S(""), SV(""), S::npos); + test(S(""), SV("laenf"), S::npos); + test(S(""), SV("pqlnkmbdjo"), S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), SV(""), 0); + test(S("lahfb"), SV("irkhs"), 0); + test(S("gmfhd"), SV("kantesmpgj"), 2); + test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), S::npos); + test(S("eolhfgpjqk"), SV(""), 0); + test(S("nbatdlmekr"), SV("bnrpe"), 2); + test(S("jdmciepkaq"), SV("jtdaefblso"), 2); + test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), S::npos); + test(S("gprdcokbnjhlsfmtieqa"), SV(""), 0); + test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 0); + test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 1); + test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp new file mode 100644 index 0000000..05925af --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(const basic_string_view sv, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_first_of(sv, pos) == x); + if (x != S::npos) + assert(pos <= x && x < s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.find_first_of(sv) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, S::npos); + test(S(""), SV("laenf"), 0, S::npos); + test(S(""), SV("pqlnkmbdjo"), 0, S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), SV(""), 1, S::npos); + test(S(""), SV("bjaht"), 1, S::npos); + test(S(""), SV("hjlcmgpket"), 1, S::npos); + test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), SV(""), 0, S::npos); + test(S("qanej"), SV("dfkap"), 0, 1); + test(S("clbao"), SV("ihqrfebgad"), 0, 2); + test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, 0); + test(S("srdfq"), SV(""), 1, S::npos); + test(S("oemth"), SV("ikcrq"), 1, S::npos); + test(S("cdaih"), SV("dmajblfhsg"), 1, 1); + test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, 1); + test(S("cshmd"), SV(""), 2, S::npos); + test(S("lhcdo"), SV("oebqi"), 2, 4); + test(S("qnsoh"), SV("kojhpmbsfe"), 2, 2); + test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, 2); + test(S("fmtsp"), SV(""), 4, S::npos); + test(S("khbpm"), SV("aobjd"), 4, S::npos); + test(S("pbsji"), SV("pcbahntsje"), 4, S::npos); + test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, 4); + test(S("eqmpa"), SV(""), 5, S::npos); + test(S("omigs"), SV("kocgb"), 5, S::npos); + test(S("onmje"), SV("fbslrjiqkm"), 5, S::npos); + test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), SV(""), 6, S::npos); + test(S("igdsc"), SV("qngpd"), 6, S::npos); + test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), SV(""), 0, S::npos); + test(S("daiprenocl"), SV("ashjd"), 0, 0); + test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 0); + test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, 0); + test(S("qpghtfbaji"), SV(""), 1, S::npos); + test(S("gfshlcmdjr"), SV("nadkh"), 1, 3); + test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 1); + test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, 1); + test(S("crnklpmegd"), SV(""), 5, S::npos); + test(S("jsbtafedoc"), SV("prqgn"), 5, S::npos); + test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 5); + test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, 5); + test(S("lmofqdhpki"), SV(""), 9, S::npos); + test(S("hnefkqimca"), SV("rtjpa"), 9, 9); + test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, S::npos); + test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, 9); + test(S("elgofjmbrq"), SV(""), 10, S::npos); + test(S("mjqdgalkpc"), SV("dplqa"), 10, S::npos); + test(S("kthqnfcerm"), SV("dkacjoptns"), 10, S::npos); + test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), SV(""), 11, S::npos); + test(S("akiteljmoh"), SV("lofbc"), 11, S::npos); + test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, S::npos); + test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), SV(""), 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 3); + test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 0); + test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, 0); + test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 3); + test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 1); + test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, 1); + test(S("hdpkobnsalmcfijregtq"), SV(""), 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 10); + test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, 10); + test(S("niptglfbosehkamrdqcj"), SV(""), 19, S::npos); + test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, S::npos); + test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 19); + test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, 19); + test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, S::npos); + test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, S::npos); + test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, S::npos); + test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, S::npos); + test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template +void test1() +{ + test(S(""), SV(""), S::npos); + test(S(""), SV("laenf"), S::npos); + test(S(""), SV("pqlnkmbdjo"), S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), SV(""), S::npos); + test(S("lahfb"), SV("irkhs"), 2); + test(S("gmfhd"), SV("kantesmpgj"), 0); + test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), 0); + test(S("eolhfgpjqk"), SV(""), S::npos); + test(S("nbatdlmekr"), SV("bnrpe"), 0); + test(S("jdmciepkaq"), SV("jtdaefblso"), 0); + test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), 0); + test(S("gprdcokbnjhlsfmtieqa"), SV(""), S::npos); + test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 1); + test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 0); + test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 0); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp new file mode 100644 index 0000000..59d216d --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(basic_string_view sv, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_last_not_of(sv, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.find_last_not_of(sv) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, S::npos); + test(S(""), SV("laenf"), 0, S::npos); + test(S(""), SV("pqlnkmbdjo"), 0, S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), SV(""), 1, S::npos); + test(S(""), SV("bjaht"), 1, S::npos); + test(S(""), SV("hjlcmgpket"), 1, S::npos); + test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), SV(""), 0, 0); + test(S("qanej"), SV("dfkap"), 0, 0); + test(S("clbao"), SV("ihqrfebgad"), 0, 0); + test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, S::npos); + test(S("srdfq"), SV(""), 1, 1); + test(S("oemth"), SV("ikcrq"), 1, 1); + test(S("cdaih"), SV("dmajblfhsg"), 1, 0); + test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, S::npos); + test(S("cshmd"), SV(""), 2, 2); + test(S("lhcdo"), SV("oebqi"), 2, 2); + test(S("qnsoh"), SV("kojhpmbsfe"), 2, 1); + test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, S::npos); + test(S("fmtsp"), SV(""), 4, 4); + test(S("khbpm"), SV("aobjd"), 4, 4); + test(S("pbsji"), SV("pcbahntsje"), 4, 4); + test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, S::npos); + test(S("eqmpa"), SV(""), 5, 4); + test(S("omigs"), SV("kocgb"), 5, 4); + test(S("onmje"), SV("fbslrjiqkm"), 5, 4); + test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos); + test(S("schfa"), SV(""), 6, 4); + test(S("igdsc"), SV("qngpd"), 6, 4); + test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos); + test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos); + test(S("hcjitbfapl"), SV(""), 0, 0); + test(S("daiprenocl"), SV("ashjd"), 0, S::npos); + test(S("litpcfdghe"), SV("mgojkldsqh"), 0, S::npos); + test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, S::npos); + test(S("qpghtfbaji"), SV(""), 1, 1); + test(S("gfshlcmdjr"), SV("nadkh"), 1, 1); + test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 0); + test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, S::npos); + test(S("crnklpmegd"), SV(""), 5, 5); + test(S("jsbtafedoc"), SV("prqgn"), 5, 5); + test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 4); + test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, S::npos); + test(S("lmofqdhpki"), SV(""), 9, 9); + test(S("hnefkqimca"), SV("rtjpa"), 9, 8); + test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 9); + test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, S::npos); + test(S("elgofjmbrq"), SV(""), 10, 9); + test(S("mjqdgalkpc"), SV("dplqa"), 10, 9); + test(S("kthqnfcerm"), SV("dkacjoptns"), 10, 9); + test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos); + test(S("eqsgalomhb"), SV(""), 11, 9); + test(S("akiteljmoh"), SV("lofbc"), 11, 9); + test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, 8); + test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos); + test(S("snafbdlghrjkpqtoceim"), SV(""), 0, 0); + test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 0); + test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, S::npos); + test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, S::npos); + test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, 1); + test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 1); + test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 0); + test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, S::npos); + test(S("hdpkobnsalmcfijregtq"), SV(""), 10, 10); + test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 9); + test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 9); + test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, S::npos); + test(S("niptglfbosehkamrdqcj"), SV(""), 19, 19); + test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 19); + test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 16); + test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, S::npos); + test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, 19); + test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, 18); + test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, 19); + test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos); + test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, 19); + test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, 19); + test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, 19); + test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos); +} + +template +void test1() +{ + test(S(""), SV(""), S::npos); + test(S(""), SV("laenf"), S::npos); + test(S(""), SV("pqlnkmbdjo"), S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), SV(""), 4); + test(S("lahfb"), SV("irkhs"), 4); + test(S("gmfhd"), SV("kantesmpgj"), 4); + test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), S::npos); + test(S("eolhfgpjqk"), SV(""), 9); + test(S("nbatdlmekr"), SV("bnrpe"), 8); + test(S("jdmciepkaq"), SV("jtdaefblso"), 9); + test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), S::npos); + test(S("gprdcokbnjhlsfmtieqa"), SV(""), 19); + test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 18); + test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 17); + test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; +// test0(); +// test1(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp new file mode 100644 index 0000000..fb8ca34 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(const basic_string_view sv, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find_last_of(sv, pos) == x); + if (x != S::npos) + assert(x <= pos && x < s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.find_last_of(sv) == x); + if (x != S::npos) + assert(x < s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, S::npos); + test(S(""), SV("laenf"), 0, S::npos); + test(S(""), SV("pqlnkmbdjo"), 0, S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos); + test(S(""), SV(""), 1, S::npos); + test(S(""), SV("bjaht"), 1, S::npos); + test(S(""), SV("hjlcmgpket"), 1, S::npos); + test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos); + test(S("fodgq"), SV(""), 0, S::npos); + test(S("qanej"), SV("dfkap"), 0, S::npos); + test(S("clbao"), SV("ihqrfebgad"), 0, S::npos); + test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, 0); + test(S("srdfq"), SV(""), 1, S::npos); + test(S("oemth"), SV("ikcrq"), 1, S::npos); + test(S("cdaih"), SV("dmajblfhsg"), 1, 1); + test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, 1); + test(S("cshmd"), SV(""), 2, S::npos); + test(S("lhcdo"), SV("oebqi"), 2, S::npos); + test(S("qnsoh"), SV("kojhpmbsfe"), 2, 2); + test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, 2); + test(S("fmtsp"), SV(""), 4, S::npos); + test(S("khbpm"), SV("aobjd"), 4, 2); + test(S("pbsji"), SV("pcbahntsje"), 4, 3); + test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, 4); + test(S("eqmpa"), SV(""), 5, S::npos); + test(S("omigs"), SV("kocgb"), 5, 3); + test(S("onmje"), SV("fbslrjiqkm"), 5, 3); + test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, 4); + test(S("schfa"), SV(""), 6, S::npos); + test(S("igdsc"), SV("qngpd"), 6, 2); + test(S("brqgo"), SV("rodhqklgmb"), 6, 4); + test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, 4); + test(S("hcjitbfapl"), SV(""), 0, S::npos); + test(S("daiprenocl"), SV("ashjd"), 0, 0); + test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 0); + test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, 0); + test(S("qpghtfbaji"), SV(""), 1, S::npos); + test(S("gfshlcmdjr"), SV("nadkh"), 1, S::npos); + test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 1); + test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, 1); + test(S("crnklpmegd"), SV(""), 5, S::npos); + test(S("jsbtafedoc"), SV("prqgn"), 5, S::npos); + test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 5); + test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, 5); + test(S("lmofqdhpki"), SV(""), 9, S::npos); + test(S("hnefkqimca"), SV("rtjpa"), 9, 9); + test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 7); + test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, 9); + test(S("elgofjmbrq"), SV(""), 10, S::npos); + test(S("mjqdgalkpc"), SV("dplqa"), 10, 8); + test(S("kthqnfcerm"), SV("dkacjoptns"), 10, 6); + test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, 9); + test(S("eqsgalomhb"), SV(""), 11, S::npos); + test(S("akiteljmoh"), SV("lofbc"), 11, 8); + test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, 9); + test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, 9); + test(S("snafbdlghrjkpqtoceim"), SV(""), 0, S::npos); + test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, S::npos); + test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 0); + test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, 0); + test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, S::npos); + test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, S::npos); + test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 1); + test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, 1); + test(S("hdpkobnsalmcfijregtq"), SV(""), 10, S::npos); + test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 10); + test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 10); + test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, 10); + test(S("niptglfbosehkamrdqcj"), SV(""), 19, S::npos); + test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 16); + test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 19); + test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, 19); + test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos); + test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, 19); + test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, 18); + test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, 19); + test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos); + test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, 12); + test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, 17); + test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, 19); +} + +template +void test1() +{ + test(S(""), SV(""), S::npos); + test(S(""), SV("laenf"), S::npos); + test(S(""), SV("pqlnkmbdjo"), S::npos); + test(S(""), SV("qkamfogpnljdcshbreti"), S::npos); + test(S("nhmko"), SV(""), S::npos); + test(S("lahfb"), SV("irkhs"), 2); + test(S("gmfhd"), SV("kantesmpgj"), 1); + test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), 4); + test(S("eolhfgpjqk"), SV(""), S::npos); + test(S("nbatdlmekr"), SV("bnrpe"), 9); + test(S("jdmciepkaq"), SV("jtdaefblso"), 8); + test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), 9); + test(S("gprdcokbnjhlsfmtieqa"), SV(""), S::npos); + test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 19); + test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 19); + test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 19); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp new file mode 100644 index 0000000..096f47e --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find(basic_string_view sv, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.find(sv, pos) == x); + if (x != S::npos) + assert(pos <= x && x + sv.size() <= s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.find(sv) == x); + if (x != S::npos) + assert(0 <= x && x + sv.size() <= s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, 0); + test(S(""), SV("abcde"), 0, S::npos); + test(S(""), SV("abcdeabcde"), 0, S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S(""), SV(""), 1, S::npos); + test(S(""), SV("abcde"), 1, S::npos); + test(S(""), SV("abcdeabcde"), 1, S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), SV(""), 0, 0); + test(S("abcde"), SV("abcde"), 0, 0); + test(S("abcde"), SV("abcdeabcde"), 0, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcde"), SV(""), 1, 1); + test(S("abcde"), SV("abcde"), 1, S::npos); + test(S("abcde"), SV("abcdeabcde"), 1, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), SV(""), 2, 2); + test(S("abcde"), SV("abcde"), 2, S::npos); + test(S("abcde"), SV("abcdeabcde"), 2, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos); + test(S("abcde"), SV(""), 4, 4); + test(S("abcde"), SV("abcde"), 4, S::npos); + test(S("abcde"), SV("abcdeabcde"), 4, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos); + test(S("abcde"), SV(""), 5, 5); + test(S("abcde"), SV("abcde"), 5, S::npos); + test(S("abcde"), SV("abcdeabcde"), 5, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcde"), SV(""), 6, S::npos); + test(S("abcde"), SV("abcde"), 6, S::npos); + test(S("abcde"), SV("abcdeabcde"), 6, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos); + test(S("abcdeabcde"), SV(""), 0, 0); + test(S("abcdeabcde"), SV("abcde"), 0, 0); + test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcdeabcde"), SV(""), 1, 1); + test(S("abcdeabcde"), SV("abcde"), 1, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), SV(""), 5, 5); + test(S("abcdeabcde"), SV("abcde"), 5, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), SV(""), 9, 9); + test(S("abcdeabcde"), SV("abcde"), 9, S::npos); + test(S("abcdeabcde"), SV("abcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), SV(""), 10, 10); + test(S("abcdeabcde"), SV("abcde"), 10, S::npos); + test(S("abcdeabcde"), SV("abcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), SV(""), 11, S::npos); + test(S("abcdeabcde"), SV("abcde"), 11, S::npos); + test(S("abcdeabcde"), SV("abcdeabcde"), 11, S::npos); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 5); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 5); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, S::npos); +} + +template +void test1() +{ + test(S(""), SV(""), 0); + test(S(""), SV("abcde"), S::npos); + test(S(""), SV("abcdeabcde"), S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcde"), SV(""), 0); + test(S("abcde"), SV("abcde"), 0); + test(S("abcde"), SV("abcdeabcde"), S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcde"), SV(""), 0); + test(S("abcdeabcde"), SV("abcde"), 0); + test(S("abcdeabcde"), SV("abcdeabcde"), 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + } +#endif +} diff --git a/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp new file mode 100644 index 0000000..230c455 --- /dev/null +++ b/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type rfind(basic_string_view sv, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& s, SV sv, typename S::size_type pos, typename S::size_type x) +{ + assert(s.rfind(sv, pos) == x); + if (x != S::npos) + assert(x <= pos && x + sv.size() <= s.size()); +} + +template +void +test(const S& s, SV sv, typename S::size_type x) +{ + assert(s.rfind(sv) == x); + if (x != S::npos) + assert(0 <= x && x + sv.size() <= s.size()); +} + +template +void test0() +{ + test(S(""), SV(""), 0, 0); + test(S(""), SV("abcde"), 0, S::npos); + test(S(""), SV("abcdeabcde"), 0, S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S(""), SV(""), 1, 0); + test(S(""), SV("abcde"), 1, S::npos); + test(S(""), SV("abcdeabcde"), 1, S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), SV(""), 0, 0); + test(S("abcde"), SV("abcde"), 0, 0); + test(S("abcde"), SV("abcdeabcde"), 0, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcde"), SV(""), 1, 1); + test(S("abcde"), SV("abcde"), 1, 0); + test(S("abcde"), SV("abcdeabcde"), 1, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcde"), SV(""), 2, 2); + test(S("abcde"), SV("abcde"), 2, 0); + test(S("abcde"), SV("abcdeabcde"), 2, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos); + test(S("abcde"), SV(""), 4, 4); + test(S("abcde"), SV("abcde"), 4, 0); + test(S("abcde"), SV("abcdeabcde"), 4, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos); + test(S("abcde"), SV(""), 5, 5); + test(S("abcde"), SV("abcde"), 5, 0); + test(S("abcde"), SV("abcdeabcde"), 5, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcde"), SV(""), 6, 5); + test(S("abcde"), SV("abcde"), 6, 0); + test(S("abcde"), SV("abcdeabcde"), 6, S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos); + test(S("abcdeabcde"), SV(""), 0, 0); + test(S("abcdeabcde"), SV("abcde"), 0, 0); + test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); + test(S("abcdeabcde"), SV(""), 1, 1); + test(S("abcdeabcde"), SV("abcde"), 1, 0); + test(S("abcdeabcde"), SV("abcdeabcde"), 1, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); + test(S("abcdeabcde"), SV(""), 5, 5); + test(S("abcdeabcde"), SV("abcde"), 5, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 5, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); + test(S("abcdeabcde"), SV(""), 9, 9); + test(S("abcdeabcde"), SV("abcde"), 9, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 9, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos); + test(S("abcdeabcde"), SV(""), 10, 10); + test(S("abcdeabcde"), SV("abcde"), 10, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 10, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos); + test(S("abcdeabcde"), SV(""), 11, 10); + test(S("abcdeabcde"), SV("abcde"), 11, 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 11, 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, 15); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, 15); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, 0); + test(S("abcdeabcdeabcdeabcde"), SV(""), 21, 20); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, 15); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, 0); +} + +template +void test1() +{ + test(S(""), SV(""), 0); + test(S(""), SV("abcde"), S::npos); + test(S(""), SV("abcdeabcde"), S::npos); + test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcde"), SV(""), 5); + test(S("abcde"), SV("abcde"), 0); + test(S("abcde"), SV("abcdeabcde"), S::npos); + test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcde"), SV(""), 10); + test(S("abcdeabcde"), SV("abcde"), 5); + test(S("abcdeabcde"), SV("abcdeabcde"), 0); + test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos); + test(S("abcdeabcdeabcdeabcde"), SV(""), 20); + test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 15); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10); + test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test0(); + test1(); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::string_view SV; + test0(); + test1(); + } +#endif +} diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp index c8f4178..75e2eca 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp @@ -16,6 +16,7 @@ // Allow incomplete argument types in the __is_callable check #include +#include struct X{ typedef std::function callback_type; @@ -24,6 +25,40 @@ private: callback_type _cb; }; -int main() +struct IncompleteReturnType { + std::function fn; +}; + + +int called = 0; +IncompleteReturnType test_fn() { + ++called; + IncompleteReturnType I; + return I; +} + +// See llvm.org/PR34298 +void test_pr34298() { + static_assert(std::is_copy_constructible::value, ""); + static_assert(std::is_copy_assignable::value, ""); + { + IncompleteReturnType X; + X.fn = test_fn; + const IncompleteReturnType& CX = X; + IncompleteReturnType X2 = CX; + assert(X2.fn); + assert(called == 0); + X2.fn(); + assert(called == 1); + } + { + IncompleteReturnType Empty; + IncompleteReturnType X2 = Empty; + assert(!X2.fn); + } +} + +int main() { + test_pr34298(); } diff --git a/test/support/container_test_types.h b/test/support/container_test_types.h index 08e88f0..b8422ec 100644 --- a/test/support/container_test_types.h +++ b/test/support/container_test_types.h @@ -234,6 +234,19 @@ inline ConstructController* getConstructController() { return &c; } +template +struct ExpectConstructGuard { + ExpectConstructGuard(int N) { + auto CC = getConstructController(); + assert(!CC->unchecked()); + CC->expect(N); + } + + ~ExpectConstructGuard() { + assert(!getConstructController()->unchecked()); + } +}; + //===----------------------------------------------------------------------===// // ContainerTestAllocator //===----------------------------------------------------------------------===// @@ -417,7 +430,12 @@ namespace std { return arg.data; } }; - + template + class vector; + template + class deque; + template + class list; template class map; template @@ -444,6 +462,13 @@ _LIBCPP_END_NAMESPACE_STD // TCT - Test container type namespace TCT { +template > +using vector = std::vector >; +template > +using deque = std::deque >; +template > +using list = std::list >; + template , class Value = CopyInsertable<2>, class ValueTp = std::pair > using unordered_map = @@ -488,5 +513,4 @@ using multiset = } // end namespace TCT - #endif // SUPPORT_CONTAINER_TEST_TYPES_H diff --git a/test/support/emplace_constructible.h b/test/support/emplace_constructible.h new file mode 100644 index 0000000..f2bc0ec --- /dev/null +++ b/test/support/emplace_constructible.h @@ -0,0 +1,74 @@ +#ifndef TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H +#define TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +template +struct EmplaceConstructible { + T value; + explicit EmplaceConstructible(T value) : value(value) {} + EmplaceConstructible(EmplaceConstructible const&) = delete; +}; + +template +struct EmplaceConstructibleAndMoveInsertable { + int copied = 0; + T value; + explicit EmplaceConstructibleAndMoveInsertable(T value) : value(value) {} + + EmplaceConstructibleAndMoveInsertable( + EmplaceConstructibleAndMoveInsertable&& Other) + : copied(Other.copied + 1), value(std::move(Other.value)) {} +}; + +template +struct EmplaceConstructibleAndMoveable { + int copied = 0; + int assigned = 0; + T value; + explicit EmplaceConstructibleAndMoveable(T value) noexcept : value(value) {} + + EmplaceConstructibleAndMoveable(EmplaceConstructibleAndMoveable&& Other) + noexcept : copied(Other.copied + 1), + value(std::move(Other.value)) {} + + EmplaceConstructibleAndMoveable& + operator=(EmplaceConstructibleAndMoveable&& Other) noexcept { + copied = Other.copied; + assigned = Other.assigned + 1; + value = std::move(Other.value); + return *this; + } +}; + +template +struct EmplaceConstructibleMoveableAndAssignable { + int copied = 0; + int assigned = 0; + T value; + explicit EmplaceConstructibleMoveableAndAssignable(T value) noexcept + : value(value) {} + + EmplaceConstructibleMoveableAndAssignable( + EmplaceConstructibleMoveableAndAssignable&& Other) noexcept + : copied(Other.copied + 1), + value(std::move(Other.value)) {} + + EmplaceConstructibleMoveableAndAssignable& + operator=(EmplaceConstructibleMoveableAndAssignable&& Other) noexcept { + copied = Other.copied; + assigned = Other.assigned + 1; + value = std::move(Other.value); + return *this; + } + + EmplaceConstructibleMoveableAndAssignable& operator=(T xvalue) { + value = std::move(xvalue); + ++assigned; + return *this; + } +}; +#endif + +#endif // TEST_SUPPORT_EMPLACE_CONSTRUCTIBLE_H