diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-03-09 17:19:07 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-03-09 17:19:07 +0000 |
commit | 1b868e19c3638fc48e20b9ac93b1ae75f9348ba3 (patch) | |
tree | 3d5d57badfe88ce9fcfbdd59b2404bbedb97a56b /libcxx/test/std/containers/sequences/vector | |
parent | d4312d8af09c6e345ac5c270b0d37b3cfab7815a (diff) | |
download | bcm5719-llvm-1b868e19c3638fc48e20b9ac93b1ae75f9348ba3.tar.gz bcm5719-llvm-1b868e19c3638fc48e20b9ac93b1ae75f9348ba3.zip |
Add some more tests for the containers type requirements
llvm-svn: 263029
Diffstat (limited to 'libcxx/test/std/containers/sequences/vector')
-rw-r--r-- | libcxx/test/std/containers/sequences/vector/types.pass.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/libcxx/test/std/containers/sequences/vector/types.pass.cpp b/libcxx/test/std/containers/sequences/vector/types.pass.cpp index 0fbc7e38b1a..159a2650f2f 100644 --- a/libcxx/test/std/containers/sequences/vector/types.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/types.pass.cpp @@ -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 } |