Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
141
test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
Normal file
141
test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class set
|
||||
|
||||
// set(set&& s, const allocator_type& a);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_compare.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly V;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<V> A;
|
||||
typedef std::set<MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(7));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly V;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<V> A;
|
||||
typedef std::set<MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly V;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef other_allocator<V> A;
|
||||
typedef std::set<MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1),
|
||||
V(1),
|
||||
V(1),
|
||||
V(2),
|
||||
V(2),
|
||||
V(2),
|
||||
V(3),
|
||||
V(3),
|
||||
V(3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
Reference in New Issue
Block a user