diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-11-15 17:47:09 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-11-15 17:47:09 +0000 |
commit | 5f8d84ec924900b337f151f7fc5a77620f25a932 (patch) | |
tree | a1d9d00e431e1aa6cd01722c629fdecd5be2ae3e /libcxx/test/std/iterators | |
parent | cbf70486bce61783dfc35bfb9cfaa33131e63003 (diff) | |
download | bcm5719-llvm-5f8d84ec924900b337f151f7fc5a77620f25a932.tar.gz bcm5719-llvm-5f8d84ec924900b337f151f7fc5a77620f25a932.zip |
Clean up the tests for free data(), size() and empty()
llvm-svn: 318313
Diffstat (limited to 'libcxx/test/std/iterators')
3 files changed, 28 insertions, 24 deletions
diff --git a/libcxx/test/std/iterators/iterator.container/data.pass.cpp b/libcxx/test/std/iterators/iterator.container/data.pass.cpp index a7a17480235..09b7c013496 100644 --- a/libcxx/test/std/iterators/iterator.container/data.pass.cpp +++ b/libcxx/test/std/iterators/iterator.container/data.pass.cpp @@ -7,51 +7,54 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + // <iterator> // template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17 // template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17 // template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17 // template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17 -#include "test_macros.h" - -#if TEST_STD_VER <= 14 -int main () {} -#else - #include <iterator> #include <cassert> #include <vector> #include <array> #include <initializer_list> +#include "test_macros.h" + template<typename C> void test_const_container( const C& c ) { +// Can't say noexcept here because the container might not be assert ( std::data(c) == c.data()); } template<typename T> void test_const_container( const std::initializer_list<T>& c ) { + ASSERT_NOEXCEPT(std::data(c)); assert ( std::data(c) == c.begin()); } template<typename C> void test_container( C& c ) { +// Can't say noexcept here because the container might not be assert ( std::data(c) == c.data()); } template<typename T> void test_container( std::initializer_list<T>& c) { + ASSERT_NOEXCEPT(std::data(c)); assert ( std::data(c) == c.begin()); } template<typename T, size_t Sz> void test_const_array( const T (&array)[Sz] ) { + ASSERT_NOEXCEPT(std::data(array)); assert ( std::data(array) == &array[0]); } @@ -72,5 +75,3 @@ int main() static constexpr int arrA [] { 1, 2, 3 }; test_const_array ( arrA ); } - -#endif diff --git a/libcxx/test/std/iterators/iterator.container/empty.pass.cpp b/libcxx/test/std/iterators/iterator.container/empty.pass.cpp index f9b8b94a89f..cd000cc2fe7 100644 --- a/libcxx/test/std/iterators/iterator.container/empty.pass.cpp +++ b/libcxx/test/std/iterators/iterator.container/empty.pass.cpp @@ -7,17 +7,13 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + // <iterator> // template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17 // template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17 // template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17 -#include "test_macros.h" - -#if TEST_STD_VER <= 14 -int main () {} -#else - #include <iterator> #include <cassert> #include <vector> @@ -25,9 +21,12 @@ int main () {} #include <list> #include <initializer_list> +#include "test_macros.h" + template<typename C> void test_const_container( const C& c ) { +// Can't say noexcept here because the container might not be assert ( std::empty(c) == c.empty()); } @@ -40,18 +39,21 @@ void test_const_container( const std::initializer_list<T>& c ) template<typename C> void test_container( C& c ) { +// Can't say noexcept here because the container might not be assert ( std::empty(c) == c.empty()); } template<typename T> void test_container( std::initializer_list<T>& c ) { + ASSERT_NOEXCEPT(std::empty(c)); assert ( std::empty(c) == (c.size() == 0)); } template<typename T, size_t Sz> void test_const_array( const T (&array)[Sz] ) { + ASSERT_NOEXCEPT(std::empty(array)); assert (!std::empty(array)); } @@ -75,5 +77,3 @@ int main() static constexpr int arrA [] { 1, 2, 3 }; test_const_array ( arrA ); } - -#endif diff --git a/libcxx/test/std/iterators/iterator.container/size.pass.cpp b/libcxx/test/std/iterators/iterator.container/size.pass.cpp index 87b0ef89707..7d443e6e123 100644 --- a/libcxx/test/std/iterators/iterator.container/size.pass.cpp +++ b/libcxx/test/std/iterators/iterator.container/size.pass.cpp @@ -7,16 +7,12 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + // <iterator> // template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 // template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17 -#include "test_macros.h" - -#if TEST_STD_VER <= 14 -int main () {} -#else - #include <iterator> #include <cassert> #include <vector> @@ -24,33 +20,42 @@ int main () {} #include <list> #include <initializer_list> +#include "test_macros.h" + template<typename C> void test_const_container( const C& c ) { +// Can't say noexcept here because the container might not be assert ( std::size(c) == c.size()); } template<typename T> void test_const_container( const std::initializer_list<T>& c) { +// ASSERT_NOEXCEPT(std::size(c)); +// For some reason, there isn't a std::size() for initializer lists assert ( std::size(c) == c.size()); } template<typename C> void test_container( C& c) { +// Can't say noexcept here because the container might not be assert ( std::size(c) == c.size()); } template<typename T> void test_container( std::initializer_list<T>& c ) { +// ASSERT_NOEXCEPT(std::size(c)); +// For some reason, there isn't a std::size() for initializer lists assert ( std::size(c) == c.size()); } template<typename T, size_t Sz> void test_const_array( const T (&array)[Sz] ) { + ASSERT_NOEXCEPT(std::size(array)); assert ( std::size(array) == Sz ); } @@ -74,5 +79,3 @@ int main() static constexpr int arrA [] { 1, 2, 3 }; test_const_array ( arrA ); } - -#endif |