[libcxx] r346743 - Add emplace tests for multiset/unordered_multiset.

Eric Fiselier eric at efcs.ca
Mon Nov 12 22:30:36 PST 2018


Author: ericwf
Date: Mon Nov 12 22:30:36 2018
New Revision: 346743

URL: http://llvm.org/viewvc/llvm-project?rev=346743&view=rev
Log:
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.

Added:
    libcxx/trunk/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp
      - copied, changed from r346634, libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp
      - copied, changed from r346634, libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp
Removed:
    libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp
Modified:
    libcxx/trunk/test/std/containers/set_allocator_requirement_test_templates.h

Removed: libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp?rev=346742&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp (removed)
@@ -1,26 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     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 multiset
-
-// insert(...)
-
-// UNSUPPORTED: c++98, c++03
-
-#include <set>
-
-#include "container_test_types.h"
-#include "../../set_allocator_requirement_test_templates.h"
-
-int main()
-{
-  testMultisetInsert<TCT::multiset<> >();
-}

Copied: libcxx/trunk/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp (from r346634, libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp?p2=libcxx/trunk/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp&p1=libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp&r1=346634&r2=346743&rev=346743&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multiset/insert_emplace_allocator_requirements.pass.cpp Mon Nov 12 22:30:36 2018
@@ -23,4 +23,5 @@
 int main()
 {
   testMultisetInsert<TCT::multiset<> >();
+  testMultisetEmplace<TCT::multiset<> >();
 }

Modified: libcxx/trunk/test/std/containers/set_allocator_requirement_test_templates.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/set_allocator_requirement_test_templates.h?rev=346743&r1=346742&r2=346743&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/set_allocator_requirement_test_templates.h (original)
+++ libcxx/trunk/test/std/containers/set_allocator_requirement_test_templates.h Mon Nov 12 22:30:36 2018
@@ -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

Removed: libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp?rev=346742&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp (removed)
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     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.
-//
-//===----------------------------------------------------------------------===//
-
-// <unordered_set>
-
-// class unordered_multiset
-
-// insert(...)
-
-// UNSUPPORTED: c++98, c++03
-
-#include <unordered_set>
-#include "container_test_types.h"
-#include "../../set_allocator_requirement_test_templates.h"
-
-int main()
-{
-  testMultisetInsert<TCT::unordered_multiset<> >();
-}

Copied: libcxx/trunk/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp (from r346634, libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp?p2=libcxx/trunk/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp&p1=libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp&r1=346634&r2=346743&rev=346743&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/insert_emplace_allocator_requirements.pass.cpp Mon Nov 12 22:30:36 2018
@@ -22,4 +22,5 @@
 int main()
 {
   testMultisetInsert<TCT::unordered_multiset<> >();
+  testMultisetEmplace<TCT::unordered_multiset<> >();
 }




More information about the libcxx-commits mailing list