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:
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// insert_iterator(Cont& x, Cont::iterator i);
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c)
|
||||
{
|
||||
std::insert_iterator<C> i(c, c.begin());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::vector<int>());
|
||||
test(nasty_vector<int>());
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// insert_iterator<Cont> operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c)
|
||||
{
|
||||
std::insert_iterator<C> i(c, c.end());
|
||||
std::insert_iterator<C> r = i++;
|
||||
r = 0;
|
||||
assert(c.size() == 1);
|
||||
assert(c.back() == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::vector<int>());
|
||||
test(nasty_vector<int>());
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// insert_iterator<Cont>& operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c)
|
||||
{
|
||||
std::insert_iterator<C> i(c, c.end());
|
||||
std::insert_iterator<C>& r = ++i;
|
||||
assert(&r == &i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::vector<int>());
|
||||
test(nasty_vector<int>());
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// requires CopyConstructible<Cont::value_type>
|
||||
// insert_iterator<Cont>&
|
||||
// operator=(const Cont::value_type& value);
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c1, typename C::difference_type j,
|
||||
typename C::value_type x1, typename C::value_type x2,
|
||||
typename C::value_type x3, const C& c2)
|
||||
{
|
||||
std::insert_iterator<C> q(c1, c1.begin() + j);
|
||||
q = x1;
|
||||
q = x2;
|
||||
q = x3;
|
||||
assert(c1 == c2);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void
|
||||
insert3at(C& c, typename C::iterator i,
|
||||
typename C::value_type x1, typename C::value_type x2,
|
||||
typename C::value_type x3)
|
||||
{
|
||||
i = c.insert(i, x1);
|
||||
i = c.insert(++i, x2);
|
||||
c.insert(++i, x3);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::vector<int> C;
|
||||
C c1;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(i);
|
||||
C c2 = c1;
|
||||
insert3at(c2, c2.begin(), 'a', 'b', 'c');
|
||||
test(c1, 0, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
|
||||
test(c1, 1, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
|
||||
test(c1, 2, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
|
||||
test(c1, 3, 'a', 'b', 'c', c2);
|
||||
}
|
||||
{
|
||||
typedef nasty_vector<int> C;
|
||||
C c1;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(i);
|
||||
C c2 = c1;
|
||||
insert3at(c2, c2.begin(), 'a', 'b', 'c');
|
||||
test(c1, 0, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
|
||||
test(c1, 1, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
|
||||
test(c1, 2, 'a', 'b', 'c', c2);
|
||||
c2 = c1;
|
||||
insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
|
||||
test(c1, 3, 'a', 'b', 'c', c2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// requires CopyConstructible<Cont::value_type>
|
||||
// insert_iterator<Cont>&
|
||||
// operator=(const Cont::value_type& value);
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c1, typename C::difference_type j,
|
||||
typename C::value_type x1, typename C::value_type x2,
|
||||
typename C::value_type x3, const C& c2)
|
||||
{
|
||||
std::insert_iterator<C> q(c1, c1.begin() + j);
|
||||
q = std::move(x1);
|
||||
q = std::move(x2);
|
||||
q = std::move(x3);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void
|
||||
insert3at(C& c, typename C::iterator i,
|
||||
typename C::value_type x1, typename C::value_type x2,
|
||||
typename C::value_type x3)
|
||||
{
|
||||
i = c.insert(i, std::move(x1));
|
||||
i = c.insert(++i, std::move(x2));
|
||||
c.insert(++i, std::move(x3));
|
||||
}
|
||||
|
||||
struct do_nothing
|
||||
{
|
||||
void operator()(void*) const {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::unique_ptr<int, do_nothing> Ptr;
|
||||
typedef std::vector<Ptr> C;
|
||||
C c1;
|
||||
int x[6] = {0};
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(Ptr(x+i));
|
||||
C c2;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c2.push_back(Ptr(x+i));
|
||||
insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
|
||||
test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
|
||||
c1.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(Ptr(x+i));
|
||||
c2.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c2.push_back(Ptr(x+i));
|
||||
insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
|
||||
test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
|
||||
c1.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(Ptr(x+i));
|
||||
c2.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c2.push_back(Ptr(x+i));
|
||||
insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
|
||||
test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
|
||||
c1.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c1.push_back(Ptr(x+i));
|
||||
c2.clear();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
c2.push_back(Ptr(x+i));
|
||||
insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
|
||||
test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// insert_iterator
|
||||
|
||||
// insert_iterator<Cont>& operator*();
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c)
|
||||
{
|
||||
std::insert_iterator<C> i(c, c.end());
|
||||
std::insert_iterator<C>& r = *i;
|
||||
assert(&r == &i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::vector<int>());
|
||||
test(nasty_vector<int>());
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <InsertionContainer Cont>
|
||||
// insert_iterator<Cont>
|
||||
// inserter(Cont& x, Cont::iterator i);
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "nasty_containers.hpp"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(C c)
|
||||
{
|
||||
std::insert_iterator<C> i = std::inserter(c, c.end());
|
||||
i = 0;
|
||||
assert(c.size() == 1);
|
||||
assert(c.back() == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::vector<int>());
|
||||
test(nasty_vector<int>());
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user