summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_allocator_requirements.pass.cpp143
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp108
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp107
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_allocator_requirements.pass.cpp142
4 files changed, 500 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_allocator_requirements.pass.cpp
new file mode 100644
index 00000000000..e889ce33480
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_allocator_requirements.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_map>
+
+// class unordered_map
+
+// insert(...);
+
+// UNSUPPORTED: c++98, c++03
+
+
+#include <unordered_map>
+#include <iostream>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+#include "container_test_types.h"
+
+#if TEST_STD_VER >= 11
+template <class Arg>
+void PrintInfo(int line, Arg&& arg)
+#else
+template <class Arg>
+void PrintInfo(int line, Arg arg)
+#endif
+{
+ std::cout << "In " << __FILE__ << ":" << line << ":\n " << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template <class Container>
+void testContainerInsert()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef Container C;
+ typedef std::pair<typename C::iterator, bool> R;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ PRINT("Testing C::insert(const value_type&)");
+ Container c;
+ const ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ assert(c.insert(v).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const ValueTp v2(42, 1);
+ assert(c.insert(v2).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(value_type&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ assert(c.insert(v).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42, 1);
+ assert(c.insert(v2).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(value_type&&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&&>();
+ assert(c.insert(std::move(v)).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42, 1);
+ assert(c.insert(std::move(v2)).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(std::initializer_list<ValueTp>)");
+ Container c;
+ std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
+ cc->expect<ValueTp const&>(2);
+ c.insert(il);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(il);
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
+ Container c;
+ const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
+ cc->expect<ValueTp&&>(3);
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
+ std::move_iterator<ValueTp*>(std::end(ValueList)));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp ValueList2[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)),
+ std::move_iterator<ValueTp*>(std::end(ValueList2)));
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ }
+ }
+}
+
+
+int main()
+{
+ testContainerInsert<TCT::unordered_map<> >();
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
new file mode 100644
index 00000000000..0926e8057ca
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_map>
+
+// class unordered_multimap
+
+// insert(...)
+
+// UNSUPPORTED: c++98, c++03
+
+#include <unordered_map>
+#include <iostream>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+#include "container_test_types.h"
+
+#if TEST_STD_VER >= 11
+template <class Arg>
+void PrintInfo(int line, Arg&& arg)
+#else
+template <class Arg>
+void PrintInfo(int line, Arg arg)
+#endif
+{
+ std::cout << "In " << __FILE__ << ":" << line << ":\n " << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template <class Container>
+void testContainerInsert()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef Container C;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ PRINT("Testing C::insert(const value_type&)");
+ Container c;
+ const ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ c.insert(v);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(value_type&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&>();
+ c.insert(v);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(value_type&&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&&>();
+ c.insert(std::move(v));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(std::initializer_list<ValueTp>)");
+ Container c;
+ std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
+ cc->expect<ValueTp const&>(2);
+ c.insert(il);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
+ Container c;
+ const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
+ cc->expect<ValueTp&&>(3);
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
+ std::move_iterator<ValueTp*>(std::end(ValueList)));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
+ cc->expect<ValueTp&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ }
+}
+
+
+int main()
+{
+ testContainerInsert<TCT::unordered_multimap<> >();
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp
new file mode 100644
index 00000000000..ae8ce055910
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <iostream>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+#include "container_test_types.h"
+
+#if TEST_STD_VER >= 11
+template <class Arg>
+void PrintInfo(int line, Arg&& arg)
+#else
+template <class Arg>
+void PrintInfo(int line, Arg arg)
+#endif
+{
+ std::cout << "In " << __FILE__ << ":" << line << ":\n " << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template <class Container>
+void testContainerInsert()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef Container C;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ PRINT("Testing C::insert(const value_type&)");
+ Container c;
+ const ValueTp v(42);
+ cc->expect<const ValueTp&>();
+ c.insert(v);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(value_type&)");
+ Container c;
+ ValueTp v(42);
+ cc->expect<const ValueTp&>();
+ c.insert(v);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(value_type&&)");
+ Container c;
+ ValueTp v(42);
+ cc->expect<ValueTp&&>();
+ c.insert(std::move(v));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(std::initializer_list<ValueTp>)");
+ Container c;
+ std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) };
+ cc->expect<ValueTp const&>(2);
+ c.insert(il);
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
+ Container c;
+ const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
+ cc->expect<ValueTp&&>(3);
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
+ std::move_iterator<ValueTp*>(std::end(ValueList)));
+ assert(!cc->unchecked());
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
+ cc->expect<ValueTp&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ }
+}
+
+int main()
+{
+ testContainerInsert<TCT::unordered_multiset<> >();
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_allocator_requirements.pass.cpp
new file mode 100644
index 00000000000..f5a30c237b9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_allocator_requirements.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_set
+
+// insert(...)
+
+// UNSUPPORTED: c++98, c++03
+
+#include <unordered_set>
+#include <iostream>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+#include "container_test_types.h"
+
+#if TEST_STD_VER >= 11
+template <class Arg>
+void PrintInfo(int line, Arg&& arg)
+#else
+template <class Arg>
+void PrintInfo(int line, Arg arg)
+#endif
+{
+ std::cout << "In " << __FILE__ << ":" << line << ":\n " << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template <class Container>
+void testContainerInsert()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef Container C;
+ typedef std::pair<typename C::iterator, bool> R;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ PRINT("Testing C::insert(const value_type&)");
+ Container c;
+ const ValueTp v(42);
+ cc->expect<const ValueTp&>();
+ assert(c.insert(v).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const ValueTp v2(42);
+ assert(c.insert(v2).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(value_type&)");
+ Container c;
+ ValueTp v(42);
+ cc->expect<const ValueTp&>();
+ assert(c.insert(v).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42);
+ assert(c.insert(v2).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(value_type&&)");
+ Container c;
+ ValueTp v(42);
+ cc->expect<ValueTp&&>();
+ assert(c.insert(std::move(v)).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42);
+ assert(c.insert(std::move(v2)).second == false);
+ }
+ }
+ {
+ PRINT("Testing C::insert(std::initializer_list<ValueTp>)");
+ Container c;
+ std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) };
+ cc->expect<ValueTp const&>(2);
+ c.insert(il);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(il);
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&");
+ Container c;
+ const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
+ cc->expect<ValueTp&&>(3);
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)),
+ std::move_iterator<ValueTp*>(std::end(ValueList)));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp ValueList2[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
+ c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)),
+ std::move_iterator<ValueTp*>(std::end(ValueList2)));
+ }
+ }
+ {
+ PRINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
+ Container c;
+ ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
+ cc->expect<ValueTp const&>(3);
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ c.insert(std::begin(ValueList), std::end(ValueList));
+ }
+ }
+}
+
+
+int main()
+{
+ testContainerInsert<TCT::unordered_set<> >();
+}
OpenPOWER on IntegriCloud