Add some more tests for the containers type requirements
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263029 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/std/containers/sequences/array/types.pass.cpp b/test/std/containers/sequences/array/types.pass.cpp
index 065ade9..a59b63d 100644
--- a/test/std/containers/sequences/array/types.pass.cpp
+++ b/test/std/containers/sequences/array/types.pass.cpp
@@ -44,6 +44,13 @@
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
{
typedef int* T;
@@ -58,5 +65,12 @@
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
}
diff --git a/test/std/containers/sequences/deque/types.pass.cpp b/test/std/containers/sequences/deque/types.pass.cpp
index da9470d..73dc964 100644
--- a/test/std/containers/sequences/deque/types.pass.cpp
+++ b/test/std/containers/sequences/deque/types.pass.cpp
@@ -64,6 +64,12 @@
static_assert((std::is_same<
typename C::const_reverse_iterator,
std::reverse_iterator<typename C::const_iterator> >::value), "");
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
int main()
@@ -73,6 +79,7 @@
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;
@@ -85,6 +92,13 @@
// 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), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
#endif
}
diff --git a/test/std/containers/sequences/forwardlist/types.pass.cpp b/test/std/containers/sequences/forwardlist/types.pass.cpp
index a1f8862..9a4e026 100644
--- a/test/std/containers/sequences/forwardlist/types.pass.cpp
+++ b/test/std/containers/sequences/forwardlist/types.pass.cpp
@@ -44,6 +44,13 @@
static_assert((std::is_same<C::const_pointer, const char*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
#if __cplusplus >= 201103L
{
@@ -57,6 +64,13 @@
// 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), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
}
#endif
}
diff --git a/test/std/containers/sequences/list/types.pass.cpp b/test/std/containers/sequences/list/types.pass.cpp
index 7730360..e70c5d2 100644
--- a/test/std/containers/sequences/list/types.pass.cpp
+++ b/test/std/containers/sequences/list/types.pass.cpp
@@ -31,18 +31,39 @@
int main()
{
- static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
- static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
- static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
- static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
- static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
- static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+ {
+ typedef std::list<int> C;
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, std::allocator<int>::reference>::value), "");
+ static_assert((std::is_same<C::const_reference, std::allocator<int>::const_reference>::value), "");
+ static_assert((std::is_same<C::pointer, std::allocator<int>::pointer>::value), "");
+ static_assert((std::is_same<C::const_pointer, std::allocator<int>::const_pointer>::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
+ }
+
#if __cplusplus >= 201103L
- static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), "");
- static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
- static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), "");
- static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), "");
- static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
- static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+ {
+ typedef std::list<int, min_allocator<int>> C;
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
+ }
#endif
}
diff --git a/test/std/containers/sequences/vector.bool/types.pass.cpp b/test/std/containers/sequences/vector.bool/types.pass.cpp
index b266b3b..4fb03f5 100644
--- a/test/std/containers/sequences/vector.bool/types.pass.cpp
+++ b/test/std/containers/sequences/vector.bool/types.pass.cpp
@@ -46,7 +46,15 @@
static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
- static_assert((std::is_same<
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type,
+ typename std::iterator_traits<typename C::const_iterator>::difference_type>::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<
diff --git a/test/std/containers/sequences/vector/types.pass.cpp b/test/std/containers/sequences/vector/types.pass.cpp
index 0fbc7e3..159a265 100644
--- a/test/std/containers/sequences/vector/types.pass.cpp
+++ b/test/std/containers/sequences/vector/types.pass.cpp
@@ -45,6 +45,9 @@
{
typedef std::vector<T, Allocator> C;
+// TODO: These tests should use allocator_traits to get stuff, rather than
+// blindly pulling typedefs out of the allocator. This is why we can't call
+// test<int, min_allocator<int>>() below.
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), "");
@@ -54,6 +57,14 @@
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_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+// static_assert((std::is_same<typename C::difference_type,
+// typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+// static_assert((std::is_same<typename C::difference_type,
+// typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
+
static_assert((std::is_same<
typename std::iterator_traits<typename C::iterator>::iterator_category,
std::random_access_iterator_tag>::value), "");
@@ -76,11 +87,22 @@
static_assert((std::is_same<std::vector<char>::allocator_type,
std::allocator<char> >::value), "");
#if __cplusplus >= 201103L
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
- static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+ {
+
+ typedef std::vector<int, min_allocator<int> > C;
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+
+ static_assert((std::is_signed<typename C::difference_type>::value), "");
+ static_assert((std::is_unsigned<typename C::size_type>::value), "");
+// static_assert((std::is_same<typename C::difference_type,
+// typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
+// static_assert((std::is_same<typename C::difference_type,
+// typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
+ }
#endif
}