Remove undefined behavior from tests; specifically, ensure that the value type of the allocators match the value type of the containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -33,16 +33,17 @@ struct some_comp
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
typedef std::pair<const MoveOnly, MoveOnly> V;
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly> C;
|
||||
static_assert(std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
|
||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
|
||||
@@ -31,16 +31,17 @@ struct some_comp
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
typedef std::pair<const MoveOnly, MoveOnly> V;
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
|
||||
@@ -33,16 +33,17 @@ struct some_comp
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
typedef std::pair<const MoveOnly, MoveOnly> V;
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly> C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
|
||||
@@ -31,16 +31,17 @@ struct some_comp
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
typedef std::pair<const MoveOnly, MoveOnly> V;
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
|
||||
@@ -94,18 +94,19 @@ struct some_alloc3
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
typedef std::pair<const MoveOnly, MoveOnly> V;
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
@@ -117,28 +118,28 @@ int main()
|
||||
|
||||
#if TEST_STD_VER >= 14
|
||||
{ // POCS allocator, throwable swap for comp
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <V>> C;
|
||||
C c1, c2;
|
||||
static_assert(!noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{ // always equal allocator, throwable swap for comp
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<V>> C;
|
||||
C c1, c2;
|
||||
static_assert(!noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{ // POCS allocator, nothrow swap for comp
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <V>> C;
|
||||
C c1, c2;
|
||||
static_assert( noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{ // always equal allocator, nothrow swap for comp
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C;
|
||||
C c1, c2;
|
||||
static_assert( noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
|
||||
{ // NOT always equal allocator, nothrow swap for comp
|
||||
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
|
||||
typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C;
|
||||
C c1, c2;
|
||||
static_assert( noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user