Fix some non-standard parts of our test suite. Reported by STL
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267131 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
File diff suppressed because it is too large
Load Diff
98
test/libcxx/containers/associative/tree_left_rotate.pass.cpp
Normal file
98
test/libcxx/containers/associative/tree_left_rotate.pass.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Not a portable test
|
||||
|
||||
// Precondition: __x->__right_ != nullptr
|
||||
// template <class _NodePtr>
|
||||
// void
|
||||
// __tree_left_rotate(_NodePtr __x);
|
||||
|
||||
#include <__tree>
|
||||
#include <cassert>
|
||||
|
||||
struct Node
|
||||
{
|
||||
Node* __left_;
|
||||
Node* __right_;
|
||||
Node* __parent_;
|
||||
|
||||
Node() : __left_(), __right_(), __parent_() {}
|
||||
};
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
Node root;
|
||||
Node x;
|
||||
Node y;
|
||||
root.__left_ = &x;
|
||||
x.__left_ = 0;
|
||||
x.__right_ = &y;
|
||||
x.__parent_ = &root;
|
||||
y.__left_ = 0;
|
||||
y.__right_ = 0;
|
||||
y.__parent_ = &x;
|
||||
std::__tree_left_rotate(&x);
|
||||
assert(root.__parent_ == 0);
|
||||
assert(root.__left_ == &y);
|
||||
assert(root.__right_ == 0);
|
||||
assert(y.__parent_ == &root);
|
||||
assert(y.__left_ == &x);
|
||||
assert(y.__right_ == 0);
|
||||
assert(x.__parent_ == &y);
|
||||
assert(x.__left_ == 0);
|
||||
assert(x.__right_ == 0);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
Node root;
|
||||
Node x;
|
||||
Node y;
|
||||
Node a;
|
||||
Node b;
|
||||
Node c;
|
||||
root.__left_ = &x;
|
||||
x.__left_ = &a;
|
||||
x.__right_ = &y;
|
||||
x.__parent_ = &root;
|
||||
y.__left_ = &b;
|
||||
y.__right_ = &c;
|
||||
y.__parent_ = &x;
|
||||
a.__parent_ = &x;
|
||||
b.__parent_ = &y;
|
||||
c.__parent_ = &y;
|
||||
std::__tree_left_rotate(&x);
|
||||
assert(root.__parent_ == 0);
|
||||
assert(root.__left_ == &y);
|
||||
assert(root.__right_ == 0);
|
||||
assert(y.__parent_ == &root);
|
||||
assert(y.__left_ == &x);
|
||||
assert(y.__right_ == &c);
|
||||
assert(x.__parent_ == &y);
|
||||
assert(x.__left_ == &a);
|
||||
assert(x.__right_ == &b);
|
||||
assert(a.__parent_ == &x);
|
||||
assert(a.__left_ == 0);
|
||||
assert(a.__right_ == 0);
|
||||
assert(b.__parent_ == &x);
|
||||
assert(b.__left_ == 0);
|
||||
assert(b.__right_ == 0);
|
||||
assert(c.__parent_ == &y);
|
||||
assert(c.__left_ == 0);
|
||||
assert(c.__right_ == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
1648
test/libcxx/containers/associative/tree_remove.pass.cpp
Normal file
1648
test/libcxx/containers/associative/tree_remove.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Not a portable test
|
||||
|
||||
// Precondition: __x->__left_ != nullptr
|
||||
// template <class _NodePtr>
|
||||
// void
|
||||
// __tree_right_rotate(_NodePtr __x);
|
||||
|
||||
#include <__tree>
|
||||
#include <cassert>
|
||||
|
||||
struct Node
|
||||
{
|
||||
Node* __left_;
|
||||
Node* __right_;
|
||||
Node* __parent_;
|
||||
|
||||
Node() : __left_(), __right_(), __parent_() {}
|
||||
};
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
Node root;
|
||||
Node x;
|
||||
Node y;
|
||||
root.__left_ = &x;
|
||||
x.__left_ = &y;
|
||||
x.__right_ = 0;
|
||||
x.__parent_ = &root;
|
||||
y.__left_ = 0;
|
||||
y.__right_ = 0;
|
||||
y.__parent_ = &x;
|
||||
std::__tree_right_rotate(&x);
|
||||
assert(root.__parent_ == 0);
|
||||
assert(root.__left_ == &y);
|
||||
assert(root.__right_ == 0);
|
||||
assert(y.__parent_ == &root);
|
||||
assert(y.__left_ == 0);
|
||||
assert(y.__right_ == &x);
|
||||
assert(x.__parent_ == &y);
|
||||
assert(x.__left_ == 0);
|
||||
assert(x.__right_ == 0);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
Node root;
|
||||
Node x;
|
||||
Node y;
|
||||
Node a;
|
||||
Node b;
|
||||
Node c;
|
||||
root.__left_ = &x;
|
||||
x.__left_ = &y;
|
||||
x.__right_ = &c;
|
||||
x.__parent_ = &root;
|
||||
y.__left_ = &a;
|
||||
y.__right_ = &b;
|
||||
y.__parent_ = &x;
|
||||
a.__parent_ = &y;
|
||||
b.__parent_ = &y;
|
||||
c.__parent_ = &x;
|
||||
std::__tree_right_rotate(&x);
|
||||
assert(root.__parent_ == 0);
|
||||
assert(root.__left_ == &y);
|
||||
assert(root.__right_ == 0);
|
||||
assert(y.__parent_ == &root);
|
||||
assert(y.__left_ == &a);
|
||||
assert(y.__right_ == &x);
|
||||
assert(x.__parent_ == &y);
|
||||
assert(x.__left_ == &b);
|
||||
assert(x.__right_ == &c);
|
||||
assert(a.__parent_ == &y);
|
||||
assert(a.__left_ == 0);
|
||||
assert(a.__right_ == 0);
|
||||
assert(b.__parent_ == &x);
|
||||
assert(b.__left_ == 0);
|
||||
assert(b.__right_ == 0);
|
||||
assert(c.__parent_ == &x);
|
||||
assert(c.__left_ == 0);
|
||||
assert(c.__right_ == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <list>
|
||||
|
||||
// template <class T, class Alloc>
|
||||
// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
#include <__debug>
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
||||
std::list<int>::iterator i1 = c1.begin();
|
||||
std::list<int>::iterator i2 = c2.begin();
|
||||
swap(c1, c2);
|
||||
c1.erase(i2);
|
||||
c2.erase(i1);
|
||||
std::list<int>::iterator j = i1;
|
||||
c1.erase(i1);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
||||
std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
|
||||
std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
|
||||
swap(c1, c2);
|
||||
c1.erase(i2);
|
||||
c2.erase(i1);
|
||||
std::list<int, min_allocator<int>>::iterator j = i1;
|
||||
c1.erase(i1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
51
test/libcxx/containers/unord/next_prime.pass.cpp
Normal file
51
test/libcxx/containers/unord/next_prime.pass.cpp
Normal 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// REQUIRES: long_tests
|
||||
|
||||
// Not a portable test
|
||||
|
||||
// <__hash_table>
|
||||
|
||||
// size_t __next_prime(size_t n);
|
||||
|
||||
// If n == 0, return 0, else return the lowest prime greater than or equal to n
|
||||
|
||||
#include <__hash_table>
|
||||
#include <cassert>
|
||||
|
||||
bool
|
||||
is_prime(size_t n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 2; i*i <= n; ++i)
|
||||
{
|
||||
if (n % i == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::__next_prime(0) == 0);
|
||||
for (std::size_t n = 1; n <= 100000; ++n)
|
||||
{
|
||||
std::size_t p = std::__next_prime(n);
|
||||
assert(p >= n);
|
||||
for (std::size_t i = n; i < p; ++i)
|
||||
assert(!is_prime(i));
|
||||
assert(is_prime(p));
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// Increment iterator past end.
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::unordered_map<int, std::string> C;
|
||||
C c;
|
||||
c.insert(std::make_pair(1, "one"));
|
||||
C::iterator i = c.begin();
|
||||
++i;
|
||||
assert(i == c.end());
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
||||
min_allocator<std::pair<const int, std::string>>> C;
|
||||
C c;
|
||||
c.insert(std::make_pair(1, "one"));
|
||||
C::iterator i = c.begin();
|
||||
++i;
|
||||
assert(i == c.end());
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// Dereference non-dereferenceable iterator.
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::unordered_map<int, std::string> C;
|
||||
C c;
|
||||
c.insert(std::make_pair(1, "one"));
|
||||
C::iterator i = c.end();
|
||||
C::value_type j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
||||
min_allocator<std::pair<const int, std::string>>> C;
|
||||
C c;
|
||||
c.insert(std::make_pair(1, "one"));
|
||||
C::iterator i = c.end();
|
||||
C::value_type j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// Increment local_iterator past end.
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::unordered_map<int, std::string> C;
|
||||
C c(1);
|
||||
C::local_iterator i = c.begin(0);
|
||||
++i;
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
||||
min_allocator<std::pair<const int, std::string>>> C;
|
||||
C c(1);
|
||||
C::local_iterator i = c.begin(0);
|
||||
++i;
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// Dereference non-dereferenceable iterator.
|
||||
|
||||
#if _LIBCPP_DEBUG >= 1
|
||||
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::unordered_map<int, std::string> C;
|
||||
C c(1);
|
||||
C::local_iterator i = c.end(0);
|
||||
C::value_type j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
||||
min_allocator<std::pair<const int, std::string>>> C;
|
||||
C c(1);
|
||||
C::local_iterator i = c.end(0);
|
||||
C::value_type j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user