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:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <array>
// array();
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c;
assert(c.size() == 3);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c;
assert(c.size() == 0);
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <array>
// Construct with initizializer list
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
assert(c.size() == 3);
assert(c[0] == 1);
assert(c[1] == 2);
assert(c[2] == 3.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c = {};
assert(c.size() == 0);
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <array>
// T *data();
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
T* p = c.data();
assert(p[0] == 1);
assert(p[1] == 2);
assert(p[2] == 3.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c = {};
T* p = c.data();
(void)p; // to placate scan-build
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <array>
// const T* data() const;
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
const T* p = c.data();
assert(p[0] == 1);
assert(p[1] == 2);
assert(p[2] == 3.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
(void)p; // to placate scan-build
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <array>
// void fill(const T& u);
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
c.fill(5.5);
assert(c.size() == 3);
assert(c[0] == 5.5);
assert(c[1] == 5.5);
assert(c[2] == 5.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c = {};
c.fill(5.5);
assert(c.size() == 0);
}
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <class T, size_t N> constexpr size_type array<T,N>::size();
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
assert(c.size() == 3);
assert(c.max_size() == 3);
assert(!c.empty());
}
{
typedef double T;
typedef std::array<T, 0> C;
C c = {};
assert(c.size() == 0);
assert(c.max_size() == 0);
assert(c.empty());
}
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
{
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
static_assert(c.size() == 3, "");
static_assert(c.max_size() == 3, "");
static_assert(!c.empty(), "");
}
{
typedef double T;
typedef std::array<T, 0> C;
constexpr C c = {};
static_assert(c.size() == 0, "");
static_assert(c.max_size() == 0, "");
static_assert(c.empty(), "");
}
#endif
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c1 = {1, 2, 3.5};
C c2 = {4, 5, 6.5};
swap(c1, c2);
assert(c1.size() == 3);
assert(c1[0] == 4);
assert(c1[1] == 5);
assert(c1[2] == 6.5);
assert(c2.size() == 3);
assert(c2[0] == 1);
assert(c2[1] == 2);
assert(c2[2] == 3.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c1 = {};
C c2 = {};
swap(c1, c2);
assert(c1.size() == 0);
assert(c2.size() == 0);
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// void swap(array& a);
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c1 = {1, 2, 3.5};
C c2 = {4, 5, 6.5};
c1.swap(c2);
assert(c1.size() == 3);
assert(c1[0] == 4);
assert(c1[1] == 5);
assert(c1[2] == 6.5);
assert(c2.size() == 3);
assert(c2[0] == 1);
assert(c2[1] == 2);
assert(c2[2] == 3.5);
}
{
typedef double T;
typedef std::array<T, 0> C;
C c1 = {};
C c2 = {};
c1.swap(c2);
assert(c1.size() == 0);
assert(c2.size() == 0);
}
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
std::get<3>(c) = 5.5; // Can't get element 3!
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
#include <array>
#include <cassert>
#if __cplusplus > 201103L
struct S {
std::array<int, 3> a;
int k;
constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
};
constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
#endif
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
std::get<1>(c) = 5.5;
assert(c[0] == 1);
assert(c[1] == 5.5);
assert(c[2] == 3.5);
}
#if _LIBCPP_STD_VER > 11
{
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
static_assert(std::get<0>(c) == 1, "");
static_assert(std::get<1>(c) == 2, "");
static_assert(std::get<2>(c) == 3.5, "");
}
{
static_assert(S().k == 3, "");
static_assert(std::get<1>(getArr()) == 4, "");
}
#endif
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
assert(std::get<0>(c) == 1);
assert(std::get<1>(c) == 2);
assert(std::get<2>(c) == 3.5);
}
#if _LIBCPP_STD_VER > 11
{
typedef double T;
typedef std::array<T, 3> C;
constexpr const C c = {1, 2, 3.5};
static_assert(std::get<0>(c) == 1, "");
static_assert(std::get<1>(c) == 2, "");
static_assert(std::get<2>(c) == 3.5, "");
}
#endif
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
#include <array>
#include <memory>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unique_ptr<double> T;
typedef std::array<T, 1> C;
C c = {std::unique_ptr<double>(new double(3.5))};
T t = std::get<0>(std::move(c));
assert(*t == 3.5);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// tuple_element<I, array<T, N> >::type
#include <array>
#include <type_traits>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
}
{
typedef int T;
typedef std::array<T, 3> C;
static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// tuple_size<array<T, N> >::value
#include <array>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
static_assert((std::tuple_size<C>::value == 3), "");
}
{
typedef double T;
typedef std::array<T, 0> C;
static_assert((std::tuple_size<C>::value == 0), "");
}
}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// support for zero-sized array
#include <array>
int main()
{
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// reference operator[] (size_type)
// const_reference operator[] (size_type); // constexpr in C++14
// reference at (size_type)
// const_reference at (size_type); // constexpr in C++14
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
C::reference r1 = c.at(0);
assert(r1 == 1);
r1 = 5.5;
assert(c.front() == 5.5);
C::reference r2 = c.at(2);
assert(r2 == 3.5);
r2 = 7.5;
assert(c.back() == 7.5);
try { (void) c.at(3); }
catch (const std::out_of_range &) {}
}
{
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
C::const_reference r1 = c.at(0);
assert(r1 == 1);
C::const_reference r2 = c.at(2);
assert(r2 == 3.5);
try { (void) c.at(3); }
catch (const std::out_of_range &) {}
}
#if _LIBCPP_STD_VER > 11
{
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
constexpr T t1 = c.at(0);
static_assert (t1 == 1, "");
constexpr T t2 = c.at(2);
static_assert (t2 == 3.5, "");
}
#endif
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// iterator begin();
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
C::iterator i;
i = c.begin();
assert(*i == 1);
assert(&*i == c.data());
*i = 5.5;
assert(c[0] == 5.5);
}
{
}
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// reference front();
// reference back();
// const_reference front(); // constexpr in C++14
// const_reference back(); // constexpr in C++14
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
C::reference r1 = c.front();
assert(r1 == 1);
r1 = 5.5;
assert(c[0] == 5.5);
C::reference r2 = c.back();
assert(r2 == 3.5);
r2 = 7.5;
assert(c[2] == 7.5);
}
{
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
C::const_reference r1 = c.front();
assert(r1 == 1);
C::const_reference r2 = c.back();
assert(r2 == 3.5);
}
#if _LIBCPP_STD_VER > 11
{
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
constexpr T t1 = c.front();
static_assert (t1 == 1, "");
constexpr T t2 = c.back();
static_assert (t2 == 3.5, "");
}
#endif
}

View File

@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// reference operator[] (size_type)
// const_reference operator[] (size_type); // constexpr in C++14
// reference at (size_type)
// const_reference at (size_type); // constexpr in C++14
#include <array>
#include <cassert>
int main()
{
{
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
C::reference r1 = c[0];
assert(r1 == 1);
r1 = 5.5;
assert(c.front() == 5.5);
C::reference r2 = c[2];
assert(r2 == 3.5);
r2 = 7.5;
assert(c.back() == 7.5);
}
{
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
C::const_reference r1 = c[0];
assert(r1 == 1);
C::const_reference r2 = c[2];
assert(r2 == 3.5);
}
#if _LIBCPP_STD_VER > 11
{
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
constexpr T t1 = c[0];
static_assert (t1 == 1, "");
constexpr T t2 = c[2];
static_assert (t2 == 3.5, "");
}
#endif
}

View File

@@ -0,0 +1,110 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// iterator, const_iterator
#include <array>
#include <iterator>
#include <cassert>
int main()
{
{
typedef std::array<int, 5> C;
C c;
C::iterator i;
i = c.begin();
C::const_iterator j;
j = c.cbegin();
assert(i == j);
}
{
typedef std::array<int, 0> C;
C c;
C::iterator i;
i = c.begin();
C::const_iterator j;
j = c.cbegin();
assert(i == j);
}
#if _LIBCPP_STD_VER > 11
{ // N3644 testing
{
typedef std::array<int, 5> C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert ( ii1 == cii );
assert ( !(ii1 != ii2 ));
assert ( !(ii1 != cii ));
C c;
assert ( c.begin() == std::begin(c));
assert ( c.cbegin() == std::cbegin(c));
assert ( c.rbegin() == std::rbegin(c));
assert ( c.crbegin() == std::crbegin(c));
assert ( c.end() == std::end(c));
assert ( c.cend() == std::cend(c));
assert ( c.rend() == std::rend(c));
assert ( c.crend() == std::crend(c));
assert ( std::begin(c) != std::end(c));
assert ( std::rbegin(c) != std::rend(c));
assert ( std::cbegin(c) != std::cend(c));
assert ( std::crbegin(c) != std::crend(c));
}
{
typedef std::array<int, 0> C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert (!(ii1 != ii2 ));
assert ( (ii1 == cii ));
assert ( (cii == ii1 ));
assert (!(ii1 != cii ));
assert (!(cii != ii1 ));
assert (!(ii1 < cii ));
assert (!(cii < ii1 ));
assert ( (ii1 <= cii ));
assert ( (cii <= ii1 ));
assert (!(ii1 > cii ));
assert (!(cii > ii1 ));
assert ( (ii1 >= cii ));
assert ( (cii >= ii1 ));
assert (cii - ii1 == 0);
assert (ii1 - cii == 0);
C c;
assert ( c.begin() == std::begin(c));
assert ( c.cbegin() == std::cbegin(c));
assert ( c.rbegin() == std::rbegin(c));
assert ( c.crbegin() == std::crbegin(c));
assert ( c.end() == std::end(c));
assert ( c.cend() == std::cend(c));
assert ( c.rend() == std::rend(c));
assert ( c.crend() == std::crend(c));
assert ( std::begin(c) == std::end(c));
assert ( std::rbegin(c) == std::rend(c));
assert ( std::cbegin(c) == std::cend(c));
assert ( std::crbegin(c) == std::crend(c));
}
}
#endif
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <class T, size_t N >
// struct array
// {
// // types:
// typedef T& reference;
// typedef const T& const_reference;
// typedef implementation defined iterator;
// typedef implementation defined const_iterator;
// typedef T value_type;
// typedef T* pointer;
// typedef size_t size_type;
// typedef ptrdiff_t difference_type;
// typedef T value_type;
// typedef std::reverse_iterator<iterator> reverse_iterator;
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
#include <array>
#include <iterator>
#include <type_traits>
int main()
{
{
typedef double T;
typedef std::array<T, 10> C;
static_assert((std::is_same<C::reference, T&>::value), "");
static_assert((std::is_same<C::const_reference, const T&>::value), "");
static_assert((std::is_same<C::iterator, T*>::value), "");
static_assert((std::is_same<C::const_iterator, const T*>::value), "");
static_assert((std::is_same<C::pointer, T*>::value), "");
static_assert((std::is_same<C::const_pointer, const T*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
}
{
typedef int* T;
typedef std::array<T, 0> C;
static_assert((std::is_same<C::reference, T&>::value), "");
static_assert((std::is_same<C::const_reference, const T&>::value), "");
static_assert((std::is_same<C::iterator, T*>::value), "");
static_assert((std::is_same<C::const_iterator, const T*>::value), "");
static_assert((std::is_same<C::pointer, T*>::value), "");
static_assert((std::is_same<C::const_pointer, const T*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
}
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
#include <array>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,91 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// reference operator[](size_type __i);
// const_reference operator[](size_type __i) const;
//
// reference at(size_type __i);
// const_reference at(size_type __i) const;
//
// reference front();
// const_reference front() const;
//
// reference back();
// const_reference back() const;
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
int main()
{
{
std::deque<int> c = make<std::deque<int> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
{
const std::deque<int> c = make<std::deque<int> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
#if __cplusplus >= 201103L
{
std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
{
const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.at(i) == i);
assert(c.front() == 0);
assert(c.back() == 9);
}
#endif
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void resize(size_type n);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, int size)
{
typedef typename C::const_iterator CI;
typename C::size_type c1_osize = c1.size();
c1.resize(size);
assert(c1.size() == size);
assert(distance(c1.begin(), c1.end()) == c1.size());
CI i = c1.begin();
for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
assert(*i == j);
for (int j = c1_osize; j < c1.size(); ++j, ++i)
assert(*i == 0);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
test(c1, M);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
}
#endif
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void resize(size_type n, const value_type& v);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, int size, int x)
{
typedef typename C::const_iterator CI;
typename C::size_type c1_osize = c1.size();
c1.resize(size, x);
assert(c1.size() == size);
assert(distance(c1.begin(), c1.end()) == c1.size());
CI i = c1.begin();
for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
assert(*i == j);
for (int j = c1_osize; j < c1.size(); ++j, ++i)
assert(*i == x);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
test(c1, M, -10);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
}
#endif
}

View File

@@ -0,0 +1,77 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void shrink_to_fit();
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1)
{
C s = c1;
c1.shrink_to_fit();
assert(c1 == s);
}
template <class C>
void
testN(int start, int N)
{
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
test(c1);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// explicit deque(const allocator_type& a);
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "../../../NotConstructible.h"
#include "min_allocator.h"
template <class T, class Allocator>
void
test(const Allocator& a)
{
std::deque<T, Allocator> d(a);
assert(d.size() == 0);
assert(d.get_allocator() == a);
}
int main()
{
test<int>(std::allocator<int>());
test<NotConstructible>(test_allocator<NotConstructible>(3));
#if __cplusplus >= 201103L
test<int>(min_allocator<int>());
test<NotConstructible>(min_allocator<NotConstructible>{});
#endif
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void assign(initializer_list<value_type> il);
#include <deque>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::deque<int> d;
d.assign({3, 4, 5, 6});
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#if __cplusplus >= 201103L
{
std::deque<int, min_allocator<int>> d;
d.assign({3, 4, 5, 6});
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,109 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class InputIterator>
// void assign(InputIterator f, InputIterator l);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, const C& c2)
{
std::size_t c1_osize = c1.size();
c1.assign(c2.begin(), c2.end());
assert(distance(c1.begin(), c1.end()) == c1.size());
assert(c1 == c2);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(c1, c2);
}
template <class C>
void
testI(C& c1, const C& c2)
{
typedef typename C::const_iterator CI;
typedef input_iterator<CI> ICI;
std::size_t c1_osize = c1.size();
c1.assign(ICI(c2.begin()), ICI(c2.end()));
assert(distance(c1.begin(), c1.end()) == c1.size());
assert(c1 == c2);
}
template <class C>
void
testNI(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(c1, c2);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
testNI<std::deque<int> >(1500, 2000, 1000);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
}
#endif
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void assign(size_type n, const value_type& v);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, int size, int v)
{
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
c1.assign(size, v);
assert(c1.size() == size);
assert(distance(c1.begin(), c1.end()) == c1.size());
for (CI i = c1.begin(); i != c1.end(); ++i)
assert(*i == v);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
C c1 = make<C>(N, start);
test(c1, M, -10);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
}
#endif
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(const deque&);
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class C>
void
test(const C& x)
{
C c(x);
assert(c == x);
}
int main()
{
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int>(ab, an));
}
{
std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
std::deque<int, test_allocator<int> > v2 = v;
assert(v2 == v);
assert(v2.get_allocator() == v.get_allocator());
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
std::deque<int, other_allocator<int> > v2 = v;
assert(v2 == v);
assert(v2.get_allocator() == other_allocator<int>(-2));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int, min_allocator<int>>(ab, an));
}
{
std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
std::deque<int, min_allocator<int> > v2 = v;
assert(v2 == v);
assert(v2.get_allocator() == v.get_allocator());
}
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(const deque& c, const allocator_type& a);
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class C>
void
test(const C& x, const typename C::allocator_type& a)
{
C c(x, a);
assert(c == x);
assert(c.get_allocator() == a);
}
int main()
{
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
test_allocator<int>(4));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
other_allocator<int>(4));
}
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
min_allocator<int>());
}
#endif
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque()
#include <deque>
#include <cassert>
#include "../../../stack_allocator.h"
#include "../../../NotConstructible.h"
#include "min_allocator.h"
template <class T, class Allocator>
void
test()
{
std::deque<T, Allocator> d;
assert(d.size() == 0);
#if __cplusplus >= 201103L
std::deque<T, Allocator> d1 = {};
assert(d1.size() == 0);
#endif
}
int main()
{
test<int, std::allocator<int> >();
test<NotConstructible, stack_allocator<NotConstructible, 1> >();
#if __cplusplus >= 201103L
test<int, min_allocator<int> >();
test<NotConstructible, min_allocator<NotConstructible> >();
#endif
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque()
// noexcept(is_nothrow_default_constructible<allocator_type>::value);
// This tests a conforming extension
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::deque<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// ~deque() // implied noexcept;
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#if __has_feature(cxx_noexcept)
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
~some_alloc() noexcept(false);
};
#endif
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::deque<MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(initializer_list<value_type> il);
#include <deque>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::deque<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#if __cplusplus >= 201103L
{
std::deque<int, min_allocator<int>> d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
assert(d.get_allocator() == test_allocator<int>(3));
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#if __cplusplus >= 201103L
{
std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
assert(d.get_allocator() == min_allocator<int>());
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class InputIterator> deque(InputIterator f, InputIterator l);
#include <deque>
#include <cassert>
#include "../../../stack_allocator.h"
#include "test_iterators.h"
#include "min_allocator.h"
template <class InputIterator>
void
test(InputIterator f, InputIterator l)
{
typedef typename std::iterator_traits<InputIterator>::value_type T;
typedef std::allocator<T> Allocator;
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
C d(f, l);
assert(d.size() == std::distance(f, l));
assert(distance(d.begin(), d.end()) == d.size());
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
assert(*i == *f);
}
template <class Allocator, class InputIterator>
void
test(InputIterator f, InputIterator l)
{
typedef typename std::iterator_traits<InputIterator>::value_type T;
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
C d(f, l);
assert(d.size() == std::distance(f, l));
assert(distance(d.begin(), d.end()) == d.size());
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
assert(*i == *f);
}
int main()
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(input_iterator<const int*>(ab), input_iterator<const int*>(an));
test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an));
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
test<stack_allocator<int, 4096> >(ab, an);
#if __cplusplus >= 201103L
test<min_allocator<int> >(ab, an);
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class InputIterator>
// deque(InputIterator f, InputIterator l, const allocator_type& a);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "test_allocator.h"
#include "min_allocator.h"
template <class InputIterator, class Allocator>
void
test(InputIterator f, InputIterator l, const Allocator& a)
{
typedef typename std::iterator_traits<InputIterator>::value_type T;
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
C d(f, l, a);
assert(d.get_allocator() == a);
assert(d.size() == std::distance(f, l));
assert(distance(d.begin(), d.end()) == d.size());
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
assert(*i == *f);
}
int main()
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
#if __cplusplus >= 201103L
test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
#endif
}

View File

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(deque&&);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(1));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(2));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == c1.get_allocator());
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef other_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(1));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(2));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == c1.get_allocator());
}
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef min_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A{});
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A{});
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == c1.get_allocator());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(deque&& c, const allocator_type& a);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(1));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(1));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(std::move(c1), A(3));
assert(c2 == c3);
assert(c3.get_allocator() == A(3));
assert(c1.size() != 0);
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(1));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(1));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(std::move(c1), A(1));
assert(c2 == c3);
assert(c3.get_allocator() == A(1));
assert(c1.size() == 0);
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef other_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(1));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(1));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(std::move(c1), A(3));
assert(c2 == c3);
assert(c3.get_allocator() == A(3));
assert(c1.size() != 0);
}
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef min_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A{});
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A{});
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(std::move(c1), A());
assert(c2 == c3);
assert(c3.get_allocator() == A());
assert(c1.size() == 0);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,91 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque& operator=(deque&& c);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(5));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() != 0);
assert(c3.get_allocator() == A(6));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef other_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef min_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A{});
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A{});
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A{});
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque& operator=(deque&& c)
// noexcept(
// allocator_type::propagate_on_container_move_assignment::value &&
// is_nothrow_move_assignable<allocator_type>::value);
// This tests a conforming extension
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::deque<MoveOnly> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(deque&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value);
// This tests a conforming extension
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc(const some_alloc&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::deque<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque& operator=(const deque& c);
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class C>
void
test(const C& x)
{
C c;
c = x;
assert(c == x);
}
int main()
{
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int>(ab, an));
}
{
std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));
l2 = l;
assert(l2 == l);
assert(l2.get_allocator() == test_allocator<int>(3));
}
{
std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));
l2 = l;
assert(l2 == l);
assert(l2.get_allocator() == other_allocator<int>(5));
}
#if __cplusplus >= 201103L
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
test(std::deque<int, min_allocator<int>>(ab, an));
}
{
std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());
std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());
l2 = l;
assert(l2 == l);
assert(l2.get_allocator() == min_allocator<int>());
}
#endif
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque& operator=(initializer_list<value_type> il);
#include <deque>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::deque<int> d;
d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#if __cplusplus >= 201103L
{
std::deque<int, min_allocator<int>> d;
d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,113 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// explicit deque(size_type n);
#include <deque>
#include <cassert>
#include "../../../stack_allocator.h"
#include "DefaultOnly.h"
#include "min_allocator.h"
template <class T, class Allocator>
void
test2(unsigned n)
{
#if _LIBCPP_STD_VER > 11
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
assert(DefaultOnly::count == 0);
{
C d(n, Allocator());
assert(DefaultOnly::count == n);
assert(d.size() == n);
assert(distance(d.begin(), d.end()) == d.size());
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
assert(*i == T());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
assert(DefaultOnly::count == 0);
#endif
}
template <class T, class Allocator>
void
test1(unsigned n)
{
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
assert(DefaultOnly::count == 0);
{
C d(n);
assert(DefaultOnly::count == n);
assert(d.size() == n);
assert(distance(d.begin(), d.end()) == d.size());
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
assert(*i == T());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
assert(DefaultOnly::count == 0);
}
template <class T, class Allocator>
void
test3(unsigned n, Allocator const &alloc = Allocator())
{
#if _LIBCPP_STD_VER > 11
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
{
C d(n, alloc);
assert(d.size() == n);
assert(d.get_allocator() == alloc);
}
#endif
}
template <class T, class Allocator>
void
test(unsigned n)
{
test1<T, Allocator> ( n );
test2<T, Allocator> ( n );
}
int main()
{
test<DefaultOnly, std::allocator<DefaultOnly> >(0);
test<DefaultOnly, std::allocator<DefaultOnly> >(1);
test<DefaultOnly, std::allocator<DefaultOnly> >(10);
test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
#if __cplusplus >= 201103L
test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
#endif
#if _LIBCPP_STD_VER > 11
test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
test3<int, std::allocator<int>>(1);
test3<int, min_allocator<int>> (3);
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(size_type n, const value_type& v);
#include <deque>
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
template <class T, class Allocator>
void
test(unsigned n, const T& x)
{
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
C d(n, x);
assert(d.size() == n);
assert(distance(d.begin(), d.end()) == d.size());
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
assert(*i == x);
}
int main()
{
test<int, std::allocator<int> >(0, 5);
test<int, std::allocator<int> >(1, 10);
test<int, std::allocator<int> >(10, 11);
test<int, std::allocator<int> >(1023, -11);
test<int, std::allocator<int> >(1024, 25);
test<int, std::allocator<int> >(1025, 0);
test<int, std::allocator<int> >(2047, 110);
test<int, std::allocator<int> >(2048, -500);
test<int, std::allocator<int> >(2049, 654);
test<int, std::allocator<int> >(4095, 78);
test<int, std::allocator<int> >(4096, 1165);
test<int, std::allocator<int> >(4097, 157);
test<int, stack_allocator<int, 4096> >(4095, 90);
#if __cplusplus >= 201103L
test<int, min_allocator<int> >(4095, 90);
#endif
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque(size_type n, const value_type& v, const allocator_type& a);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class T, class Allocator>
void
test(unsigned n, const T& x, const Allocator& a)
{
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
C d(n, x, a);
assert(d.get_allocator() == a);
assert(d.size() == n);
assert(distance(d.begin(), d.end()) == d.size());
for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
assert(*i == x);
}
int main()
{
{
std::allocator<int> a;
test(0, 5, a);
test(1, 10, a);
test(10, 11, a);
test(1023, -11, a);
test(1024, 25, a);
test(1025, 0, a);
test(2047, 110, a);
test(2048, -500, a);
test(2049, 654, a);
test(4095, 78, a);
test(4096, 1165, a);
test(4097, 157, a);
}
#if __cplusplus >= 201103L
{
min_allocator<int> a;
test(0, 5, a);
test(1, 10, a);
test(10, 11, a);
test(1023, -11, a);
test(1024, 25, a);
test(1025, 0, a);
test(2047, 110, a);
test(2048, -500, a);
test(2049, 654, a);
test(4095, 78, a);
test(4096, 1165, a);
test(4097, 157, a);
}
#endif
}

View File

@@ -0,0 +1,112 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class... Args> iterator emplace(const_iterator p, Args&&... args);
#include <deque>
#include <cassert>
#include "../../../Emplaceable.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(Emplaceable());
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
assert(*i == Emplaceable(1, 2.5));
}
template <class C>
void
testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1);
}
}
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class... Args> void emplace_back(Args&&... args);
#include <deque>
#include <cassert>
#include "../../../Emplaceable.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(Emplaceable());
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.emplace_back(Emplaceable(1, 2.5));
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.end();
assert(*--i == Emplaceable(1, 2.5));
}
template <class C>
void
testN(int start, int N)
{
C c1 = make<C>(N, start);
test(c1);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class... Args> void emplace_front(Args&&... args);
#include <deque>
#include <cassert>
#include "../../../Emplaceable.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(Emplaceable());
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.emplace_front(Emplaceable(1, 2.5));
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.begin();
assert(*i == Emplaceable(1, 2.5));
}
template <class C>
void
testN(int start, int N)
{
C c1 = make<C>(N, start);
test(c1);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// iterator erase(const_iterator p)
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1)
{
typedef typename C::iterator I;
assert(P < c1.size());
std::size_t c1_osize = c1.size();
I i = c1.erase(c1.cbegin() + P);
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize - 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
int j = 0;
for (; j < P; ++j, ++i)
assert(*i == j);
for (++j; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
for (int p = 0; p < N; p += pstep)
{
C c1 = make<C>(N, start);
test(p, c1);
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,96 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//
// REQUIRES: long_tests
// <deque>
// iterator erase(const_iterator f, const_iterator l)
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1, int size)
{
typedef typename C::iterator I;
assert(P + size <= c1.size());
std::size_t c1_osize = c1.size();
I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize - size);
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
int j = 0;
for (; j < P; ++j, ++i)
assert(*i == j);
for (j += size; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
for (int p = 0; p <= N; p += pstep)
{
int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
for (int s = 0; s <= N - p; s += sstep)
{
C c1 = make<C>(N, start);
test(p, c1, s);
}
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// iterator insert(const_iterator p, initializer_list<value_type> il);
#include <deque>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::deque<int> d(10, 1);
std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
assert(d.size() == 14);
assert(i == d.begin() + 2);
assert(d[0] == 1);
assert(d[1] == 1);
assert(d[2] == 3);
assert(d[3] == 4);
assert(d[4] == 5);
assert(d[5] == 6);
assert(d[6] == 1);
assert(d[7] == 1);
assert(d[8] == 1);
assert(d[9] == 1);
assert(d[10] == 1);
assert(d[11] == 1);
assert(d[12] == 1);
assert(d[13] == 1);
}
{
std::deque<int, min_allocator<int>> d(10, 1);
std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
assert(d.size() == 14);
assert(i == d.begin() + 2);
assert(d[0] == 1);
assert(d[1] == 1);
assert(d[2] == 3);
assert(d[3] == 4);
assert(d[4] == 5);
assert(d[5] == 6);
assert(d[6] == 1);
assert(d[7] == 1);
assert(d[8] == 1);
assert(d[9] == 1);
assert(d[10] == 1);
assert(d[11] == 1);
assert(d[12] == 1);
assert(d[13] == 1);
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,256 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//
// REQUIRES: long_tests
// <deque>
// template <class InputIterator>
// iterator insert (const_iterator p, InputIterator f, InputIterator l);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "../../../MoveOnly.h"
#include "../../../stack_allocator.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1, const C& c2)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef bidirectional_iterator<CI> BCI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + c2.size());
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
for (int j = 0; j < P; ++j, ++i)
assert(*i == j);
for (int j = 0; j < c2.size(); ++j, ++i)
assert(*i == j);
for (int j = P; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
for (int i = M-1; i <= M+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
for (int i = N - M - 1; i <= N - M + 1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
for (int i = N - M - 1; i <= N - M + 1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
test(i, c1, c2);
}
}
}
template <class C>
void
testI(int P, C& c1, const C& c2)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef input_iterator<CI> ICI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + c2.size());
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
for (int j = 0; j < P; ++j, ++i)
assert(*i == j);
for (int j = 0; j < c2.size(); ++j, ++i)
assert(*i == j);
for (int j = P; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testNI(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(i, c1, c2);
}
}
for (int i = M-1; i <= M+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(i, c1, c2);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(i, c1, c2);
}
}
for (int i = N - M - 1; i <= N - M + 1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(i, c1, c2);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
testI(i, c1, c2);
}
}
}
template <class C>
void
test_move()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
C c;
typedef typename C::const_iterator CI;
{
MoveOnly mo(0);
typedef MoveOnly* I;
c.insert(c.end(), std::move_iterator<I>(&mo), std::move_iterator<I>(&mo+1));
}
int j = 0;
for (CI i = c.begin(); i != c.end(); ++i, ++j)
assert(*i == MoveOnly(j));
{
MoveOnly mo(1);
typedef input_iterator<MoveOnly*> I;
c.insert(c.end(), std::move_iterator<I>(I(&mo)), std::move_iterator<I>(I(&mo+1)));
}
j = 0;
for (CI i = c.begin(); i != c.end(); ++i, ++j)
assert(*i == MoveOnly(j));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
testNI<std::deque<int> >(1500, 2000, 1000);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >();
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
testNI<std::deque<int> >(1500, 2000, 1000);
test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >();
}
#endif
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// iterator insert (const_iterator p, value_type&& v);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(MoveOnly(i));
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1, int x)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, MoveOnly(x));
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
for (int j = 0; j < P; ++j, ++i)
assert(*i == MoveOnly(j));
assert(*i == MoveOnly(x));
++i;
for (int j = P; j < c1_osize; ++j, ++i)
assert(*i == MoveOnly(j));
}
template <class C>
void
testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<MoveOnly> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,159 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//
// REQUIRES: long_tests
// <deque>
// iterator insert (const_iterator p, size_type n, const value_type& v);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1, int size, int x)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, size, x);
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + size);
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
for (int j = 0; j < P; ++j, ++i)
assert(*i == j);
for (int j = 0; j < size; ++j, ++i)
assert(*i == x);
for (int j = P; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N, int M)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
for (int i = M-1; i <= M+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
for (int i = N - M - 1; i <= N - M + 1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
}
template <class C>
void
self_reference_test()
{
typedef typename C::const_iterator CI;
for (int i = 0; i < 20; ++i)
{
for (int j = 0; j < 20; ++j)
{
C c = make<C>(20);
CI it = c.cbegin() + i;
CI jt = c.cbegin() + j;
c.insert(it, 5, *jt);
assert(c.size() == 25);
assert(distance(c.begin(), c.end()) == c.size());
it = c.cbegin();
for (int k = 0; k < i; ++k, ++it)
assert(*it == k);
for (int k = 0; k < 5; ++k, ++it)
assert(*it == j);
for (int k = i; k < 20; ++k, ++it)
assert(*it == k);
}
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
self_reference_test<std::deque<int> >();
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
self_reference_test<std::deque<int, min_allocator<int>> >();
}
#endif
}

View File

@@ -0,0 +1,139 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// iterator insert (const_iterator p, const value_type& v);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(int P, C& c1, int x)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, x);
assert(i == c1.begin() + P);
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
i = c1.begin();
for (int j = 0; j < P; ++j, ++i)
assert(*i == j);
assert(*i == x);
++i;
for (int j = P; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
for (int i = N/2-1; i <= N/2+1; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
for (int i = N - 3; i <= N; ++i)
{
if (0 <= i && i <= N)
{
C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
}
template <class C>
void
self_reference_test()
{
typedef typename C::const_iterator CI;
for (int i = 0; i < 20; ++i)
{
for (int j = 0; j < 20; ++j)
{
C c = make<C>(20);
CI it = c.cbegin() + i;
CI jt = c.cbegin() + j;
c.insert(it, *jt);
assert(c.size() == 21);
assert(distance(c.begin(), c.end()) == c.size());
it = c.cbegin();
for (int k = 0; k < i; ++k, ++it)
assert(*it == k);
assert(*it == j);
++it;
for (int k = i; k < 20; ++k, ++it)
assert(*it == k);
}
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
self_reference_test<std::deque<int> >();
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
self_reference_test<std::deque<int, min_allocator<int>> >();
}
#endif
}

View File

@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void pop_back()
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.pop_back();
assert(c1.size() == c1_osize - 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.begin();
for (int j = 0; j < c1.size(); ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
if (N != 0)
{
C c1 = make<C>(N, start);
test(c1);
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void pop_front()
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.pop_front();
assert(c1.size() == c1_osize - 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.begin();
for (int j = 1; j < c1.size(); ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
if (N != 0)
{
C c1 = make<C>(N, start);
test(c1);
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_back(const value_type& v);
// void pop_back();
// void pop_front();
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void test(int size)
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
{
C c = make<C>(size, rng[j]);
typename C::const_iterator it = c.begin();
for (int i = 0; i < size; ++i, ++it)
assert(*it == i);
}
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
test<std::deque<int> >(rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
test<std::deque<int, min_allocator<int>> >(rng[j]);
}
#endif
}

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_back(const value_type& x);
#include <deque>
#include <cassert>
// Flag that makes the copy constructor for CMyClass throw an exception
static bool gCopyConstructorShouldThow = false;
class CMyClass {
public: CMyClass(int tag);
public: CMyClass(const CMyClass& iOther);
public: ~CMyClass();
bool equal(const CMyClass &rhs) const
{ return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
private:
int fMagicValue;
int fTag;
private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue;
};
// Value for fMagicValue when the constructor has started running, but not yet finished
int CMyClass::kStartedConstructionMagicValue = 0;
// Value for fMagicValue when the constructor has finished running
int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass(int tag) :
fMagicValue(kStartedConstructionMagicValue), fTag(tag)
{
// Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue;
}
CMyClass::CMyClass(const CMyClass& iOther) :
fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
{
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) {
throw std::exception();
}
// Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue;
}
CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue);
}
bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
int main()
{
CMyClass instance(42);
std::deque<CMyClass> vec;
vec.push_back(instance);
std::deque<CMyClass> vec2(vec);
gCopyConstructorShouldThow = true;
try {
vec.push_back(instance);
}
catch (...) {
assert(vec==vec2);
}
}

View File

@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_back(value_type&& v);
// void pop_back();
// void pop_front();
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(MoveOnly(i));
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void test(int size)
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
{
C c = make<C>(size, rng[j]);
typename C::const_iterator it = c.begin();
for (int i = 0; i < size; ++i, ++it)
assert(*it == MoveOnly(i));
}
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
test<std::deque<MoveOnly> >(rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_front(const value_type& v);
#include <deque>
#include <cassert>
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, int x)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.push_front(x);
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.begin();
assert(*i == x);
++i;
for (int j = 0; j < c1_osize; ++j, ++i)
assert(*i == j);
}
template <class C>
void
testN(int start, int N)
{
C c1 = make<C>(N, start);
test(c1, -10);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_front(const value_type& x);
#include <deque>
#include <cassert>
// Flag that makes the copy constructor for CMyClass throw an exception
static bool gCopyConstructorShouldThow = false;
class CMyClass {
public: CMyClass(int tag);
public: CMyClass(const CMyClass& iOther);
public: ~CMyClass();
bool equal(const CMyClass &rhs) const
{ return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
private:
int fMagicValue;
int fTag;
private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue;
};
// Value for fMagicValue when the constructor has started running, but not yet finished
int CMyClass::kStartedConstructionMagicValue = 0;
// Value for fMagicValue when the constructor has finished running
int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass(int tag) :
fMagicValue(kStartedConstructionMagicValue), fTag(tag)
{
// Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue;
}
CMyClass::CMyClass(const CMyClass& iOther) :
fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
{
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) {
throw std::exception();
}
// Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue;
}
CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue);
}
bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
int main()
{
CMyClass instance(42);
std::deque<CMyClass> vec;
vec.push_front(instance);
std::deque<CMyClass> vec2(vec);
gCopyConstructorShouldThow = true;
try {
vec.push_front(instance);
}
catch (...) {
assert(vec==vec2);
}
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void push_front(value_type&& v);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(MoveOnly(i));
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void
test(C& c1, int x)
{
typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.push_front(MoveOnly(x));
assert(c1.size() == c1_osize + 1);
assert(distance(c1.begin(), c1.end()) == c1.size());
I i = c1.begin();
assert(*i == MoveOnly(x));
++i;
for (int j = 0; j < c1_osize; ++j, ++i)
assert(*i == MoveOnly(j));
}
template <class C>
void
testN(int start, int N)
{
C c1 = make<C>(N, start);
test(c1, -10);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<MoveOnly> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Optimization for deque::iterators
// template <class InputIterator, class OutputIterator>
// OutputIterator
// copy(InputIterator first, InputIterator last, OutputIterator result);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
typedef input_iterator<CI> ICI;
C c1 = make<C>(N, start);
C c2 = make<C>(N);
assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
assert(c1 == c2);
assert(std::copy(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
assert(c1 == c2);
assert(std::copy(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
assert(c1 == c2);
assert(std::copy(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::copy(ICI(c2.cbegin()), ICI(c2.cend()), c1.begin()) == c1.end());
assert(c1 == c2);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Optimization for deque::iterators
// template <class InputIterator, class OutputIterator>
// OutputIterator
// copy_backward(InputIterator first, InputIterator last, OutputIterator result);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
C c1 = make<C>(N, start);
C c2 = make<C>(N);
assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
assert(c1 == c2);
assert(std::copy_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
assert(c1 == c2);
assert(std::copy_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
assert(c1 == c2);
assert(std::copy_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::copy_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
assert(c1 == c2);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Optimization for deque::iterators
// template <class InputIterator, class OutputIterator>
// OutputIterator
// move(InputIterator first, InputIterator last, OutputIterator result);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
C c1 = make<C>(N, start);
C c2 = make<C>(N);
assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
assert(c1 == c2);
assert(std::move(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
assert(c1 == c2);
assert(std::move(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
assert(c1 == c2);
assert(std::move(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::move(RACI(c2.cbegin()), RACI(c2.cend()), c1.begin()) == c1.end());
assert(c1 == c2);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Optimization for deque::iterators
// template <class InputIterator, class OutputIterator>
// OutputIterator
// move_backward(InputIterator first, InputIterator last, OutputIterator result);
#include <deque>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void testN(int start, int N)
{
typedef typename C::iterator I;
typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
C c1 = make<C>(N, start);
C c2 = make<C>(N);
assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
assert(c1 == c2);
assert(std::move_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
assert(c1 == c2);
assert(std::move_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
assert(c1 == c2);
assert(std::move_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::move_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
assert(c1 == c2);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int> >(rng[i], rng[j]);
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]);
}
#endif
}

View File

@@ -0,0 +1,110 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// template <class T, class A>
// void swap(deque<T, A>& x, deque<T, A>& y);
#include <deque>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
template <class C>
C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
int init = 0;
if (start > 0)
{
init = (start+1) / b + ((start+1) % b != 0);
init *= b;
--init;
}
C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
c.push_back(i);
for (int i = 0; i < start; ++i)
c.pop_front();
return c;
};
template <class C>
void testN(int start, int N, int M)
{
C c1 = make<C>(N, start);
C c2 = make<C>(M);
C c1_save = c1;
C c2_save = c2;
swap(c1, c2);
assert(c1 == c2_save);
assert(c2 == c1_save);
}
int main()
{
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int> >(rng[i], rng[j], rng[k]);
}
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef test_allocator<int> A;
std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
swap(c1, c2);
assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
assert(c1.get_allocator() == A(1));
assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
assert(c2.get_allocator() == A(2));
}
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef other_allocator<int> A;
std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
swap(c1, c2);
assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
assert(c1.get_allocator() == A(2));
assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
assert(c2.get_allocator() == A(1));
}
#if __cplusplus >= 201103L
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
}
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef min_allocator<int> A;
std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
swap(c1, c2);
assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
assert(c1.get_allocator() == A());
assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
assert(c2.get_allocator() == A());
}
#endif
}

View File

@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// void swap(deque& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
// This tests a conforming extension
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc() {}
some_alloc(const some_alloc&);
void deallocate(void*, unsigned) {}
typedef std::true_type propagate_on_container_swap;
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::deque<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
#endif
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Test nested types and default template args:
// template <class T, class Allocator = allocator<T> >
// class deque;
// iterator, const_iterator
#include <deque>
#include <iterator>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::deque<int> C;
C c;
C::iterator i;
i = c.begin();
C::const_iterator j;
j = c.cbegin();
assert(i == j);
}
#if __cplusplus >= 201103L
{
typedef std::deque<int, min_allocator<int>> C;
C c;
C::iterator i;
i = c.begin();
C::const_iterator j;
j = c.cbegin();
assert(i == j);
}
#endif
#if _LIBCPP_STD_VER > 11
{ // N3644 testing
std::deque<int>::iterator ii1{}, ii2{};
std::deque<int>::iterator ii4 = ii1;
std::deque<int>::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert (!(ii1 != ii2 ));
assert ( (ii1 == cii ));
assert ( (cii == ii1 ));
assert (!(ii1 != cii ));
assert (!(cii != ii1 ));
assert (!(ii1 < cii ));
assert (!(cii < ii1 ));
assert ( (ii1 <= cii ));
assert ( (cii <= ii1 ));
assert (!(ii1 > cii ));
assert (!(cii > ii1 ));
assert ( (ii1 >= cii ));
assert ( (cii >= ii1 ));
assert (cii - ii1 == 0);
assert (ii1 - cii == 0);
// std::deque<int> c;
// assert ( ii1 != c.cbegin());
// assert ( cii != c.begin());
// assert ( cii != c.cend());
// assert ( ii1 != c.end());
}
#endif
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// Test nested types and default template args:
// template <class T, class Allocator = allocator<T> >
// class deque
// {
// public:
// typedef T value_type;
// typedef Allocator allocator_type;
// typedef typename allocator_type::reference reference;
// typedef typename allocator_type::const_reference const_reference;
// typedef implementation-defined iterator;
// typedef implementation-defined const_iterator;
// typedef typename allocator_type::size_type size_type;
// typedef typename allocator_type::difference_type difference_type;
// typedef typename allocator_type::pointer pointer;
// typedef typename allocator_type::const_pointer const_pointer;
// typedef std::reverse_iterator<iterator> reverse_iterator;
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// };
#include <deque>
#include <iterator>
#include <type_traits>
#include "test_allocator.h"
#include "../../Copyable.h"
#include "min_allocator.h"
template <class T, class Allocator>
void
test()
{
typedef std::deque<T, Allocator> C;
static_assert((std::is_same<typename C::value_type, T>::value), "");
static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
static_assert((std::is_same<
typename std::iterator_traits<typename C::iterator>::iterator_category,
std::random_access_iterator_tag>::value), "");
static_assert((std::is_same<
typename std::iterator_traits<typename C::const_iterator>::iterator_category,
std::random_access_iterator_tag>::value), "");
static_assert((std::is_same<
typename C::reverse_iterator,
std::reverse_iterator<typename C::iterator> >::value), "");
static_assert((std::is_same<
typename C::const_reverse_iterator,
std::reverse_iterator<typename C::const_iterator> >::value), "");
}
int main()
{
test<int, test_allocator<int> >();
test<int*, std::allocator<int*> >();
test<Copyable, test_allocator<Copyable> >();
static_assert((std::is_same<std::deque<char>::allocator_type,
std::allocator<char> >::value), "");
#if __cplusplus >= 201103L
{
typedef std::deque<short, min_allocator<short>> C;
static_assert((std::is_same<C::value_type, short>::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
static_assert((std::is_same<C::reference, C::value_type&>::value), "");
static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
#include <deque>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.cons
// template <class Alloc>
// dynarray(size_type c, const Alloc& alloc);
// template <class Alloc>
// dynarray(size_type c, const T& v, const Alloc& alloc);
// template <class Alloc>
// dynarray(const dynarray& d, const Alloc& alloc);
// template <class Alloc>
// dynarray(initializer_list<T>, const Alloc& alloc);
// ~dynarray();
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
#include "test_allocator.h"
using std::experimental::dynarray;
template <class T, class Allocator>
void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
for ( int i = 0; i < dyn.size (); ++i )
assert ( dyn[i].get_allocator() == alloc );
}
template <class T, class Allocator>
void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
typedef dynarray<T> dynA;
dynA d1 ( vals, alloc );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
check_allocator ( d1, alloc );
}
template <class T, class Allocator>
void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
typedef dynarray<T> dynA;
dynA d1 ( 4, alloc1 );
assert ( d1.size () == 4 );
assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
check_allocator ( d1, alloc1 );
dynA d2 ( 7, val, alloc1 );
assert ( d2.size () == 7 );
assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
check_allocator ( d2, alloc1 );
dynA d3 ( d2, alloc2 );
assert ( d3.size () == 7 );
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
check_allocator ( d3, alloc2 );
}
int main()
{
// This test is waiting on the resolution of LWG issue #2235
// typedef test_allocator<char> Alloc;
// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
//
// test ( nstr("fourteen"), Alloc(3), Alloc(4) );
// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.cons
// explicit dynarray(size_type c);
// dynarray(size_type c, const T& v);
// dynarray(initializer_list<T>);
// dynarray(const dynarray& d);
// ~dynarray();
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void test ( const std::initializer_list<T> &vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
}
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
assert ( d1.size () == 4 );
assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
dynA d2 ( 7, val );
assert ( d2.size () == 7 );
assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
dynA d3 ( d2 );
assert ( d3.size () == 7 );
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
}
void test_bad_length () {
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
catch ( std::bad_array_length & ) { return ; }
assert ( false );
}
void test_bad_alloc () {
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
catch ( std::bad_alloc & ) { return ; }
assert ( false );
}
int main()
{
// test<int> ( 14 ); // ints don't get default initialized
test<long> ( 0 );
test<double> ( 14.0 );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
// Make sure we don't pick up the Allocator version here
dynarray<long> d1 ( 20, 3 );
assert ( d1.size() == 20 );
assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
test_bad_length ();
test_bad_alloc ();
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.data
// T* data() noexcept;
// const T* data() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_test_const ( const dynarray<T> &dyn ) {
const T *data = dyn.data ();
assert ( data != NULL );
assert ( std::equal ( dyn.begin(), dyn.end(), data ));
}
template <class T>
void dyn_test ( dynarray<T> &dyn ) {
T *data = dyn.data ();
assert ( data != NULL );
assert ( std::equal ( dyn.begin(), dyn.end(), data ));
}
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
dyn_test ( d1 );
dyn_test_const ( d1 );
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
}
int main()
{
test<int> ( 14 );
test<double> ( 14.0 );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.data
// void fill(const T& v);
// const T* data() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
d1.fill ( val );
assert ( std::all_of ( d1.begin (), d1.end (),
[&val]( const T &item ){ return item == val; } ));
}
int main()
{
test<int> ( 14 );
test<double> ( 14.0 );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,94 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_at_fail ( dynarray<T> &dyn, size_t sz ) {
try { dyn.at (sz); }
catch (const std::out_of_range &) { return; }
assert ( false );
}
template <class T>
void dyn_at_fail_const ( const dynarray<T> &dyn, size_t sz ) {
try { dyn.at (sz); }
catch (const std::out_of_range &) { return; }
assert ( false );
}
template <class T>
void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
const T *data = dyn.data ();
auto it = vals.begin ();
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
assert ( data + i == &dyn.at(i));
assert ( *it == dyn.at(i));
}
dyn_at_fail_const ( dyn, dyn.size ());
dyn_at_fail_const ( dyn, 2*dyn.size ());
dyn_at_fail_const ( dyn, size_t (-1));
}
template <class T>
void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
T *data = dyn.data ();
auto it = vals.begin ();
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
assert ( data + i == &dyn.at(i));
assert ( *it == dyn.at(i));
}
dyn_at_fail ( dyn, dyn.size ());
dyn_at_fail ( dyn, 2*dyn.size ());
dyn_at_fail ( dyn, size_t (-1));
}
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
}
int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// dynarray.overview
// iterator begin() noexcept;
// const_iterator begin() const noexcept;
// const_iterator cbegin() const noexcept;
// iterator end() noexcept;
// const_iterator end() const noexcept;
// const_iterator cend() const noexcept;
//
// reverse_iterator rbegin() noexcept;
// const_reverse_iterator rbegin() const noexcept;
// const_reverse_iterator crbegin() const noexcept;
// reverse_iterator rend() noexcept;
// const_reverse_iterator rend() const noexcept;
// const_reverse_iterator crend() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_test_const ( const dynarray<T> &dyn ) {
const T *data = dyn.data ();
assert ( data == &*dyn.begin ());
assert ( data == &*dyn.cbegin ());
assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
assert ( dyn.begin () == dyn.cbegin ());
assert ( &*dyn.begin () == &*dyn.cbegin ());
assert ( dyn.rbegin () == dyn.crbegin ());
assert ( &*dyn.rbegin () == &*dyn.crbegin ());
assert ( dyn.end () == dyn.cend ());
assert ( dyn.rend () == dyn.crend ());
}
template <class T>
void dyn_test ( dynarray<T> &dyn ) {
T *data = dyn.data ();
assert ( data == &*dyn.begin ());
assert ( data == &*dyn.cbegin ());
assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
assert ( dyn.begin () == dyn.cbegin ());
assert ( &*dyn.begin () == &*dyn.cbegin ());
assert ( dyn.rbegin () == dyn.crbegin ());
assert ( &*dyn.rbegin () == &*dyn.crbegin ());
assert ( dyn.end () == dyn.cend ());
assert ( dyn.rend () == dyn.crend ());
}
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
dyn_test ( d1 );
dyn_test_const ( d1 );
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
}
int main()
{
test<int> ( 14 );
test<double> ( 14.0 );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.overview
// size_type size() const noexcept;
// size_type max_size() const noexcept;
// bool empty() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
assert ( dyn.size () == sz );
assert ( dyn.max_size () == sz );
assert ( dyn.empty () == ( sz == 0 ));
}
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals.size ());
}
int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.overview
// reference front();
// const_reference front() const;
// reference back();
// const_reference back() const;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_test_const ( const dynarray<T> &dyn ) {
const T *data = dyn.data ();
assert ( *data == dyn.front ());
assert ( *(data + dyn.size() - 1 ) == dyn.back ());
}
template <class T>
void dyn_test ( dynarray<T> &dyn ) {
T *data = dyn.data ();
assert ( *data == dyn.front ());
assert ( *(data + dyn.size() - 1 ) == dyn.back ());
}
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
dyn_test ( d1 );
dyn_test_const ( d1 );
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
}
int main()
{
test<int> ( 14 );
test<double> ( 14.0 );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
const T *data = dyn.data ();
auto it = vals.begin ();
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
assert ( data + i == &dyn[i]);
assert ( *it == dyn[i]);
}
}
template <class T>
void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
T *data = dyn.data ();
auto it = vals.begin ();
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
assert ( data + i == &dyn[i]);
assert ( *it == dyn[i]);
}
}
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
}
int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// dynarray.data
// template <class Type, class Alloc>
// struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include "test_allocator.h"
using std::experimental::dynarray;
int main()
{
static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// dynarray.zero
// dynarray shall provide support for the special case of construction with a size of zero.
// In the case that the size is zero, begin() == end() == unique value.
// The return value of data() is unspecified.
// The effect of calling front() or back() for a zero-sized dynarray is undefined.
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void test ( ) {
typedef dynarray<T> dynA;
dynA d1 ( 0 );
assert ( d1.size() == 0 );
assert ( d1.begin() == d1.end ());
}
int main()
{
test<int> ();
test<double> ();
test<std::complex<double>> ();
test<std::string> ();
}
#else
int main() {}
#endif

View File

@@ -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()
{
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// reference front();
// const_reference front() const;
#include <forward_list>
#include <cassert>
#include <iterator>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t), std::end(t));
assert(c.front() == 0);
c.front() = 10;
assert(c.front() == 10);
assert(*c.begin() == 10);
}
{
typedef int T;
typedef std::forward_list<T> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const C c(std::begin(t), std::end(t));
assert(c.front() == 0);
assert(*c.begin() == 0);
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t), std::end(t));
assert(c.front() == 0);
c.front() = 10;
assert(c.front() == 10);
assert(*c.begin() == 10);
}
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const C c(std::begin(t), std::end(t));
assert(c.front() == 0);
assert(*c.begin() == 0);
}
#endif
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// explicit forward_list(const allocator_type& a);
#include <forward_list>
#include <cassert>
#include "test_allocator.h"
#include "../../../NotConstructible.h"
int main()
{
{
typedef test_allocator<NotConstructible> A;
typedef A::value_type T;
typedef std::forward_list<T, A> C;
C c = A(12);
assert(c.get_allocator() == A(12));
assert(c.empty());
}
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// explicit forward_list(const allocator_type& a);
#include <forward_list>
#include <cassert>
#include "test_allocator.h"
#include "../../../NotConstructible.h"
#include "min_allocator.h"
int main()
{
{
typedef test_allocator<NotConstructible> A;
typedef A::value_type T;
typedef std::forward_list<T, A> C;
C c(A(12));
assert(c.get_allocator() == A(12));
assert(c.empty());
}
#if __cplusplus >= 201103L
{
typedef min_allocator<NotConstructible> A;
typedef A::value_type T;
typedef std::forward_list<T, A> C;
C c(A{});
assert(c.get_allocator() == A());
assert(c.empty());
}
#endif
}

View File

@@ -0,0 +1,146 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list& operator=(const forward_list& x);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(10));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(11));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(11));
}
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(10));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(11));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(11));
}
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(10));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(11));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(10));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t0), std::end(t0), A(10));
C c1(std::begin(t1), std::end(t1), A(11));
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A(10));
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef min_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c0(std::begin(t0), std::end(t0), A());
C c1(std::begin(t1), std::end(t1), A());
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A());
}
{
typedef int T;
typedef min_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t0), std::end(t0), A());
C c1(std::begin(t1), std::end(t1), A());
c1 = c0;
assert(c1 == c0);
assert(c1.get_allocator() == A());
}
#endif
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void assign(initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c.assign({10, 11, 12, 13});
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c.assign({10, 11, 12, 13});
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,199 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list& operator=(forward_list&& x);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "test_allocator.h"
#include "../../../MoveOnly.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef MoveOnly T;
typedef test_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
T t1[] = {10, 11, 12, 13};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef test_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
T t1[] = {10, 11, 12, 13};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
assert(c1.get_allocator() == A(11));
assert(!c0.empty());
}
{
typedef MoveOnly T;
typedef test_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {10, 11, 12, 13};
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef test_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {10, 11, 12, 13};
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
assert(c1.get_allocator() == A(11));
assert(!c0.empty());
}
{
typedef MoveOnly T;
typedef other_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
T t1[] = {10, 11, 12, 13};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef other_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
T t1[] = {10, 11, 12, 13};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef other_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {10, 11, 12, 13};
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef other_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {10, 11, 12, 13};
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
assert(c1.get_allocator() == A(10));
assert(c0.empty());
}
#if __cplusplus >= 201103L
{
typedef MoveOnly T;
typedef min_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
T t1[] = {10, 11, 12, 13};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A());
C c1(I(std::begin(t1)), I(std::end(t1)), A());
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
assert(c1.get_allocator() == A());
assert(c0.empty());
}
{
typedef MoveOnly T;
typedef min_allocator<T> A;
typedef std::forward_list<T, A> C;
T t0[] = {10, 11, 12, 13};
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
typedef std::move_iterator<T*> I;
C c0(I(std::begin(t0)), I(std::end(t0)), A());
C c1(I(std::begin(t1)), I(std::end(t1)), A());
c1 = std::move(c0);
int n = 0;
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
assert(c1.get_allocator() == A());
assert(c0.empty());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list& operator=(initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c = {10, 11, 12, 13};
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c = {10, 11, 12, 13};
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,78 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class InputIterator>
// void assign(InputIterator first, InputIterator last);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "test_iterators.h"
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
typedef input_iterator<const T*> I;
c.assign(I(std::begin(t0)), I(std::end(t0)));
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
typedef input_iterator<const T*> I;
c.assign(I(std::begin(t0)), I(std::end(t0)));
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10+n);
assert(n == 4);
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
typedef input_iterator<const T*> I;
c.assign(I(std::begin(t0)), I(std::end(t0)));
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == n);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t0[] = {10, 11, 12, 13};
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
typedef input_iterator<const T*> I;
c.assign(I(std::begin(t0)), I(std::end(t0)));
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, (void) ++n)
assert(*i == 10+n);
assert(n == 4);
}
#endif
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void assign(size_type n, const value_type& v);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c.assign(10, 1);
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 1);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c.assign(4, 10);
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10);
assert(n == 4);
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {10, 11, 12, 13};
C c(std::begin(t1), std::end(t1));
c.assign(10, 1);
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 1);
assert(n == 10);
}
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t1), std::end(t1));
c.assign(4, 10);
int n = 0;
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
assert(*i == 10);
assert(n == 4);
}
#endif
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list(const forward_list& x);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A(10));
C c = c0;
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A(10));
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A(10));
C c = c0;
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A(-2));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if __cplusplus >= 201103L
{
typedef int T;
typedef min_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A());
C c = c0;
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A());
}
#endif
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list(const forward_list& x, const allocator_type& a);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef test_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A(10));
C c(c0, A(9));
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A(9));
}
{
typedef int T;
typedef other_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A(10));
C c(c0, A(9));
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A(9));
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef min_allocator<int> A;
typedef std::forward_list<T, A> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c0(std::begin(t), std::end(t), A());
C c(c0, A());
unsigned n = 0;
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
assert(*i == n);
assert(n == std::end(t) - std::begin(t));
assert(c == c0);
assert(c.get_allocator() == A());
}
#endif
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list();
#include <forward_list>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
C c;
assert(c.empty());
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::forward_list<T, min_allocator<T>> C;
C c;
assert(c.empty());
}
{
typedef int T;
typedef std::forward_list<T> C;
C c = {};
assert(c.empty());
}
#endif
}

Some files were not shown because too many files have changed in this diff Show More