diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:11 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:11 +0000 |
commit | dbabdb5220c44e5938d404eefb84b5ed55667ea8 (patch) | |
tree | 75c7e5204ae0564ac641b1629ef74066461d1884 /test/support | |
parent | 8a86acebf859efb1adc46c88fa0cd69381a7291f (diff) |
Notes
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/container_test_types.h | 28 | ||||
-rw-r--r-- | test/support/emplace_constructible.h | 74 |
2 files changed, 100 insertions, 2 deletions
diff --git a/test/support/container_test_types.h b/test/support/container_test_types.h index 08e88f091461..b8422ec4602d 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 <class ...Args> +struct ExpectConstructGuard { + ExpectConstructGuard(int N) { + auto CC = getConstructController(); + assert(!CC->unchecked()); + CC->expect<Args...>(N); + } + + ~ExpectConstructGuard() { + assert(!getConstructController()->unchecked()); + } +}; + //===----------------------------------------------------------------------===// // ContainerTestAllocator //===----------------------------------------------------------------------===// @@ -417,7 +430,12 @@ namespace std { return arg.data; } }; - + template <class T, class Alloc> + class vector; + template <class T, class Alloc> + class deque; + template <class T, class Alloc> + class list; template <class _Key, class _Value, class _Less, class _Alloc> class map; template <class _Key, class _Value, class _Less, class _Alloc> @@ -444,6 +462,13 @@ _LIBCPP_END_NAMESPACE_STD // TCT - Test container type namespace TCT { +template <class T = CopyInsertable<1>> +using vector = std::vector<T, ContainerTestAllocator<T, T> >; +template <class T = CopyInsertable<1>> +using deque = std::deque<T, ContainerTestAllocator<T, T> >; +template <class T = CopyInsertable<1>> +using list = std::list<T, ContainerTestAllocator<T, T> >; + template <class Key = CopyInsertable<1>, class Value = CopyInsertable<2>, class ValueTp = std::pair<const Key, Value> > 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 000000000000..f2bc0ec6a367 --- /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 <class T> +struct EmplaceConstructible { + T value; + explicit EmplaceConstructible(T value) : value(value) {} + EmplaceConstructible(EmplaceConstructible const&) = delete; +}; + +template <class T> +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 <class T> +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 <class T> +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 |