Clean up the tests for free data(), size() and empty()
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318313 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user