Add emplace tests for multiset/unordered_multiset.
This patch adds tests to ensure that multiset/unordered_multiset's emplace method correctly constructs the elements without any intervening constructions. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,4 +23,5 @@
|
||||
int main()
|
||||
{
|
||||
testMultisetInsert<TCT::multiset<> >();
|
||||
testMultisetEmplace<TCT::multiset<> >();
|
||||
}
|
||||
@@ -344,11 +344,54 @@ void testMultisetInsert()
|
||||
{
|
||||
CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
|
||||
Container c;
|
||||
ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
|
||||
ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(1) };
|
||||
cc->expect<ValueTp&>(3);
|
||||
c.insert(std::begin(ValueList), std::end(ValueList));
|
||||
assert(!cc->unchecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class Container>
|
||||
void testMultisetEmplace()
|
||||
{
|
||||
typedef typename Container::value_type ValueTp;
|
||||
typedef Container C;
|
||||
typedef std::pair<typename C::iterator, bool> R;
|
||||
ConstructController* cc = getConstructController();
|
||||
cc->reset();
|
||||
{
|
||||
CHECKPOINT("Testing C::emplace(const value_type&)");
|
||||
Container c;
|
||||
const ValueTp v(42);
|
||||
cc->expect<const ValueTp&>();
|
||||
c.emplace(v);
|
||||
assert(!cc->unchecked());
|
||||
}
|
||||
{
|
||||
CHECKPOINT("Testing C::emplace(value_type&)");
|
||||
Container c;
|
||||
ValueTp v(42);
|
||||
cc->expect<ValueTp&>();
|
||||
c.emplace(v);
|
||||
assert(!cc->unchecked());
|
||||
}
|
||||
{
|
||||
CHECKPOINT("Testing C::emplace(value_type&&)");
|
||||
Container c;
|
||||
ValueTp v(42);
|
||||
cc->expect<ValueTp&&>();
|
||||
c.emplace(std::move(v));
|
||||
assert(!cc->unchecked());
|
||||
}
|
||||
{
|
||||
CHECKPOINT("Testing C::emplace(const value_type&&)");
|
||||
Container c;
|
||||
const ValueTp v(42);
|
||||
cc->expect<const ValueTp&&>();
|
||||
c.emplace(std::move(v));
|
||||
assert(!cc->unchecked());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,4 +22,5 @@
|
||||
int main()
|
||||
{
|
||||
testMultisetInsert<TCT::unordered_multiset<> >();
|
||||
testMultisetEmplace<TCT::unordered_multiset<> >();
|
||||
}
|
||||
Reference in New Issue
Block a user