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