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,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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class Alloc>
// explicit stack(const Alloc& a);
#include <stack>
#include <cassert>
#include "test_allocator.h"
struct test
: private std::stack<int, std::deque<int, test_allocator<int> > >
{
typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
explicit test(const test_allocator<int>& a) : base(a) {}
test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
test_allocator<int> get_allocator() {return c.get_allocator();}
};
int main()
{
test q(test_allocator<int>(3));
assert(q.get_allocator() == test_allocator<int>(3));
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class Alloc>
// stack(const container_type& c, const Alloc& a);
#include <stack>
#include <cassert>
#include "test_allocator.h"
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
typedef std::deque<int, test_allocator<int> > C;
struct test
: public std::stack<int, C>
{
typedef std::stack<int, C> base;
explicit test(const test_allocator<int>& a) : base(a) {}
test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
test_allocator<int> get_allocator() {return c.get_allocator();}
};
int main()
{
C d = make<C>(5);
test q(d, test_allocator<int>(4));
assert(q.get_allocator() == test_allocator<int>(4));
assert(q.size() == 5);
for (int i = 0; i < d.size(); ++i)
{
assert(q.top() == d[d.size() - i - 1]);
q.pop();
}
}

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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class Alloc>
// stack(const stack& q, const Alloc& a);
#include <stack>
#include <cassert>
#include "test_allocator.h"
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(int(i));
return c;
}
typedef std::deque<int, test_allocator<int> > C;
template <class T>
struct test
: public std::stack<T, C>
{
typedef std::stack<T, C> base;
typedef test_allocator<int> allocator_type;
typedef typename base::container_type container_type;
explicit test(const allocator_type& a) : base(a) {}
test(const container_type& c, const allocator_type& a) : base(c, a) {}
test(const test& q, const allocator_type& a) : base(q, a) {}
allocator_type get_allocator() {return this->c.get_allocator();}
};
int main()
{
test<int> q(make<C>(5), test_allocator<int>(4));
test<int> q2(q, test_allocator<int>(5));
assert(q2.get_allocator() == test_allocator<int>(5));
assert(q2.size() == 5);
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class Alloc>
// stack(const container_type& c, const Alloc& a);
#include <stack>
#include <cassert>
#include "test_allocator.h"
#include "../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
return c;
}
typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
template <class T>
struct test
: public std::stack<T, C>
{
typedef std::stack<T, C> base;
typedef test_allocator<MoveOnly> allocator_type;
typedef typename base::container_type container_type;
explicit test(const allocator_type& a) : base(a) {}
test(const container_type& c, const allocator_type& a) : base(c, a) {}
test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
allocator_type get_allocator() {return this->c.get_allocator();}
};
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
assert(q.get_allocator() == test_allocator<MoveOnly>(4));
assert(q.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class Alloc>
// stack(stack&& q, const Alloc& a);
#include <stack>
#include <cassert>
#include "test_allocator.h"
#include "../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
return c;
}
typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
template <class T>
struct test
: public std::stack<T, C>
{
typedef std::stack<T, C> base;
typedef test_allocator<MoveOnly> allocator_type;
typedef typename base::container_type container_type;
explicit test(const allocator_type& a) : base(a) {}
test(const container_type& c, const allocator_type& a) : base(c, a) {}
test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
allocator_type get_allocator() {return this->c.get_allocator();}
};
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
assert(q2.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// explicit stack(const container_type& c);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::deque<int> d = make<std::deque<int> >(5);
std::stack<int> q(d);
assert(q.size() == 5);
for (int i = 0; i < d.size(); ++i)
{
assert(q.top() == d[d.size() - i - 1]);
q.pop();
}
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack(const stack&) = default;
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::stack<int> q(make<std::deque<int> >(5));
std::stack<int> q2 = q;
assert(q2 == q);
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack();
#include <stack>
#include <vector>
#include <cassert>
#include "../../../stack_allocator.h"
int main()
{
std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
assert(q.size() == 0);
q.push(1);
q.push(2);
assert(q.size() == 2);
assert(q.top() == 2);
}

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.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack(stack&& q);
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
return c;
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2 = std::move(q);
assert(q2.size() == 5);
assert(q.empty());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// explicit stack(container_type&& c);
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
return c;
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
assert(q.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack()
// noexcept(is_nothrow_default_constructible<container_type>::value);
// This tests a conforming extension
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// ~stack() // implied noexcept;
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack& operator=(stack&& c)
// noexcept(is_nothrow_move_assignable<container_type>::value);
// This tests a conforming extension
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack(stack&&)
// noexcept(is_nothrow_move_constructible<container_type>::value);
// This tests a conforming extension
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack& operator=(const stack& q);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::stack<int> q(make<std::deque<int> >(5));
std::stack<int> q2;
q2 = q;
assert(q2 == q);
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// stack& operator=(stack&& q);
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
return c;
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2;
q2 = std::move(q);
assert(q2.size() == 5);
assert(q.empty());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class... Args> void emplace(Args&&... args);
#include <stack>
#include <cassert>
#include "../../../Emplaceable.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<Emplaceable> q;
q.emplace(1, 2.5);
q.emplace(2, 3.5);
q.emplace(3, 4.5);
assert(q.size() == 3);
assert(q.top() == Emplaceable(3, 4.5));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// bool empty() const;
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
assert(q.empty());
q.push(1);
assert(!q.empty());
q.pop();
assert(q.empty());
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// void pop();
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
q.push(2);
q.push(3);
assert(q.size() == 3);
assert(q.top() == 3);
q.pop();
assert(q.size() == 2);
assert(q.top() == 2);
q.pop();
assert(q.size() == 1);
assert(q.top() == 1);
q.pop();
assert(q.size() == 0);
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// void push(const value_type& v);
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
q.push(1);
assert(q.size() == 1);
assert(q.top() == 1);
q.push(2);
assert(q.size() == 2);
assert(q.top() == 2);
q.push(3);
assert(q.size() == 3);
assert(q.top() == 3);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// void push(value_type&& v);
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q;
q.push(MoveOnly(1));
assert(q.size() == 1);
assert(q.top() == MoveOnly(1));
q.push(MoveOnly(2));
assert(q.size() == 2);
assert(q.top() == MoveOnly(2));
q.push(MoveOnly(3));
assert(q.size() == 3);
assert(q.top() == MoveOnly(3));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// size_type size() const;
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
assert(q.size() == 1);
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// void swap(stack& q);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}
int main()
{
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
std::stack<int> q2_save = q2;
q1.swap(q2);
assert(q1 == q2_save);
assert(q2 == q1_save);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// reference top();
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
q.push(2);
q.push(3);
int& ir = q.top();
assert(ir == 3);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// const_reference top() const;
#include <stack>
#include <cassert>
int main()
{
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
q.push(2);
q.push(3);
const std::stack<int>& cqr = q;
const int& cir = cqr.top();
assert(cir == 3);
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class T, class Container = deque<T>>
// class stack
// {
// public:
// typedef Container container_type;
// typedef typename container_type::value_type value_type;
// typedef typename container_type::reference reference;
// typedef typename container_type::const_reference const_reference;
// typedef typename container_type::size_type size_type;
//
// protected:
// container_type c;
// ...
// };
#include <stack>
#include <vector>
#include <type_traits>
struct test
: private std::stack<int>
{
test()
{
c.push_back(1);
}
};
struct C
{
typedef int value_type;
typedef int& reference;
typedef const int& const_reference;
typedef int size_type;
};
int main()
{
static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
test t;
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class T, class Container>
// bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
//
// template <class T, class Container>
// bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}
int main()
{
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
std::stack<int> q2_save = q2;
assert(q1 == q1_save);
assert(q1 != q2);
assert(q2 == q2_save);
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class T, class Container>
// bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
//
// template <class T, class Container>
// bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
//
// template <class T, class Container>
// bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
//
// template <class T, class Container>
// bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}
int main()
{
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
assert(q1 < q2);
assert(q2 > q1);
assert(q1 <= q2);
assert(q2 >= q1);
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// template <class T, class Container>
// void swap(stack<T, Container>& x, stack<T, Container>& y);
#include <stack>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}
int main()
{
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
std::stack<int> q2_save = q2;
swap(q1, q2);
assert(q1 == q2_save);
assert(q2 == q1_save);
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <stack>
// void swap(stack& c)
// noexcept(__is_nothrow_swappable<container_type>::value);
// This tests a conforming extension
#include <stack>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::stack<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
#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.
//
//===----------------------------------------------------------------------===//
// <stack>
#include <stack>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}