From 51072bd6bf79ef2bc6a922079bff57c31c1effbc Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:47:26 +0000 Subject: Vendor import of libc++ release_39 branch r276489: https://llvm.org/svn/llvm-project/libcxx/branches/release_39@276489 --- .../array/array.cons/initializer_list.pass.cpp | 14 +++++++ .../sequences/array/array.special/swap.pass.cpp | 38 +++++++++++++++++ .../sequences/array/array.swap/swap.pass.cpp | 48 +++++++++++++++++++++- test/std/containers/sequences/array/at.pass.cpp | 4 +- .../containers/sequences/array/front_back.pass.cpp | 2 +- .../containers/sequences/array/indexing.pass.cpp | 2 +- .../containers/sequences/array/iterators.pass.cpp | 2 +- test/std/containers/sequences/array/types.pass.cpp | 43 +++++++++++++++++-- .../containers/sequences/array/version.pass.cpp | 20 --------- 9 files changed, 143 insertions(+), 30 deletions(-) delete mode 100644 test/std/containers/sequences/array/version.pass.cpp (limited to 'test/std/containers/sequences/array') diff --git a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp index 5e429adb6fc9..64ea75a40064 100644 --- a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp @@ -35,4 +35,18 @@ int main() C c = {}; assert(c.size() == 0); } + + { + typedef double T; + typedef std::array C; + C c = {1}; + assert(c.size() == 3.0); + assert(c[0] == 1); + } + { + typedef int T; + typedef std::array C; + C c = {}; + assert(c.size() == 1); + } } diff --git a/test/std/containers/sequences/array/array.special/swap.pass.cpp b/test/std/containers/sequences/array/array.special/swap.pass.cpp index c1b0b235ab34..413f291a2a36 100644 --- a/test/std/containers/sequences/array/array.special/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.special/swap.pass.cpp @@ -14,10 +14,28 @@ #include #include +#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +struct NonSwappable { + NonSwappable() {} +private: + NonSwappable(NonSwappable const&); + NonSwappable& operator=(NonSwappable const&); +}; + +template +decltype(swap(std::declval(), std::declval())) +can_swap_imp(int); + +template +std::false_type can_swap_imp(...); + +template +struct can_swap : std::is_same(0)), void> {}; + int main() { { @@ -44,4 +62,24 @@ int main() assert(c1.size() == 0); assert(c2.size() == 0); } + { + typedef NonSwappable T; + typedef std::array C0; + static_assert(can_swap::value, ""); + C0 l = {}; + C0 r = {}; + swap(l, r); +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(l, r)), ""); +#endif + } +#if TEST_STD_VER >= 11 + { + // NonSwappable is still considered swappable in C++03 because there + // is no access control SFINAE. + typedef NonSwappable T; + typedef std::array C1; + static_assert(!can_swap::value, ""); + } +#endif } diff --git a/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/test/std/containers/sequences/array/array.swap/swap.pass.cpp index 651798e1e790..8d01dbf959ce 100644 --- a/test/std/containers/sequences/array/array.swap/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.swap/swap.pass.cpp @@ -10,14 +10,24 @@ // // void swap(array& a); +// namespace std { void swap(array &x, array &y); -#include #include +#include + +#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +struct NonSwappable { + NonSwappable() {} +private: + NonSwappable(NonSwappable const&); + NonSwappable& operator=(NonSwappable const&); +}; + int main() { { @@ -35,6 +45,22 @@ int main() assert(c2[1] == 2); assert(c2[2] == 3.5); } + { + typedef double T; + typedef std::array C; + C c1 = {1, 2, 3.5}; + C c2 = {4, 5, 6.5}; + std::swap(c1, c2); + assert(c1.size() == 3); + assert(c1[0] == 4); + assert(c1[1] == 5); + assert(c1[2] == 6.5); + assert(c2.size() == 3); + assert(c2[0] == 1); + assert(c2[1] == 2); + assert(c2[2] == 3.5); + } + { typedef double T; typedef std::array C; @@ -44,4 +70,24 @@ int main() assert(c1.size() == 0); assert(c2.size() == 0); } + { + typedef double T; + typedef std::array C; + C c1 = {}; + C c2 = {}; + std::swap(c1, c2); + assert(c1.size() == 0); + assert(c2.size() == 0); + } + { + typedef NonSwappable T; + typedef std::array C0; + C0 l = {}; + C0 r = {}; + l.swap(r); +#if TEST_STD_VER >= 11 + static_assert(noexcept(l.swap(r)), ""); +#endif + } + } diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index 5cb89dfeeb9a..9707beeb3946 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -49,14 +49,14 @@ int main() const C c = {1, 2, 3.5}; C::const_reference r1 = c.at(0); assert(r1 == 1); - + C::const_reference r2 = c.at(2); assert(r2 == 3.5); try { (void) c.at(3); } catch (const std::out_of_range &) {} } - + #if TEST_STD_VER > 11 { typedef double T; diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp index bccaade986ea..7d53b8265e96 100644 --- a/test/std/containers/sequences/array/front_back.pass.cpp +++ b/test/std/containers/sequences/array/front_back.pass.cpp @@ -34,7 +34,7 @@ int main() assert(r1 == 1); r1 = 5.5; assert(c[0] == 5.5); - + C::reference r2 = c.back(); assert(r2 == 3.5); r2 = 7.5; diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp index 5ccb0b487b95..64d2716a7592 100644 --- a/test/std/containers/sequences/array/indexing.pass.cpp +++ b/test/std/containers/sequences/array/indexing.pass.cpp @@ -33,7 +33,7 @@ int main() assert(r1 == 1); r1 = 5.5; assert(c.front() == 5.5); - + C::reference r2 = c[2]; assert(r2 == 3.5); r2 = 7.5; diff --git a/test/std/containers/sequences/array/iterators.pass.cpp b/test/std/containers/sequences/array/iterators.pass.cpp index 98997d8c26d5..233e9328c4ed 100644 --- a/test/std/containers/sequences/array/iterators.pass.cpp +++ b/test/std/containers/sequences/array/iterators.pass.cpp @@ -59,7 +59,7 @@ int main() assert ( c.cend() == std::cend(c)); assert ( c.rend() == std::rend(c)); assert ( c.crend() == std::crend(c)); - + assert ( std::begin(c) != std::end(c)); assert ( std::rbegin(c) != std::rend(c)); assert ( std::cbegin(c) != std::cend(c)); diff --git a/test/std/containers/sequences/array/types.pass.cpp b/test/std/containers/sequences/array/types.pass.cpp index 065ade959d05..9cf390c4eacb 100644 --- a/test/std/containers/sequences/array/types.pass.cpp +++ b/test/std/containers/sequences/array/types.pass.cpp @@ -29,6 +29,25 @@ #include #include +#include "test_macros.h" + +template +void test_iterators() { + typedef std::iterator_traits ItT; + typedef std::iterator_traits CItT; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + int main() { { @@ -36,27 +55,43 @@ int main() typedef std::array C; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same::value), ""); + test_iterators(); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same >::value), ""); static_assert((std::is_same >::value), ""); + + static_assert((std::is_signed::value), ""); + static_assert((std::is_unsigned::value), ""); + static_assert((std::is_same::difference_type>::value), ""); + static_assert((std::is_same::difference_type>::value), ""); } { typedef int* T; typedef std::array C; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same::value), ""); + test_iterators(); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same >::value), ""); static_assert((std::is_same >::value), ""); + + static_assert((std::is_signed::value), ""); + static_assert((std::is_unsigned::value), ""); + static_assert((std::is_same::difference_type>::value), ""); + static_assert((std::is_same::difference_type>::value), ""); } } diff --git a/test/std/containers/sequences/array/version.pass.cpp b/test/std/containers/sequences/array/version.pass.cpp deleted file mode 100644 index b89a8dd8cca3..000000000000 --- a/test/std/containers/sequences/array/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -#include - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} -- cgit v1.3