[libcxx] r263029 - Add some more tests for the containers type requirements

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 9 09:19:07 PST 2016


Author: marshall
Date: Wed Mar  9 11:19:07 2016
New Revision: 263029

URL: http://llvm.org/viewvc/llvm-project?rev=263029&view=rev
Log:
Add some more tests for the containers type requirements

Modified:
    libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp
    libcxx/trunk/test/std/containers/sequences/deque/types.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/types.pass.cpp
    libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -44,6 +44,13 @@ int main()
         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 @@ int main()
         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), "");
     }
 }

Modified: libcxx/trunk/test/std/containers/sequences/deque/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/deque/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/deque/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -64,6 +64,12 @@ test()
     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 @@ int main()
     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 @@ int main()
 //  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
 }

Modified: libcxx/trunk/test/std/containers/sequences/forwardlist/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -44,6 +44,13 @@ int main()
     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 @@ int main()
 //  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
 }

Modified: libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -31,18 +31,39 @@ struct A { std::list<A> v; }; // incompl
 
 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
 }

Modified: libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -46,7 +46,15 @@ test()
     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<

Modified: libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp?rev=263029&r1=263028&r2=263029&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp Wed Mar  9 11:19:07 2016
@@ -45,6 +45,9 @@ test()
 {
     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 @@ test()
     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 @@ int main()
     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
 }




More information about the cfe-commits mailing list