diff options
Diffstat (limited to 'libcxx/test')
4 files changed, 97 insertions, 25 deletions
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp index cd1dad60ade..91d6b4e5da2 100644 --- a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp @@ -14,20 +14,41 @@ #include <array> #include <type_traits> -int main() +template <class T> +void test() { { - typedef double T; - typedef std::array<T, 3> C; - static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), ""); - static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), ""); - static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), ""); + typedef T Exp; + typedef std::array<T, 3> C; + static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); + } + { + typedef T const Exp; + typedef std::array<T, 3> const C; + static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); + } + { + typedef T volatile Exp; + typedef std::array<T, 3> volatile C; + static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); } { - typedef int T; - typedef std::array<T, 3> C; - static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), ""); - static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), ""); - static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), ""); + typedef T const volatile Exp; + typedef std::array<T, 3> const volatile C; + static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); + static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); } } + +int main() +{ + test<double>(); + test<int>(); +} diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp index 83394b1e0c9..1e565d1946e 100644 --- a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp @@ -13,16 +13,30 @@ #include <array> -int main() +template <class T, std::size_t N> +void test() { { - typedef double T; - typedef std::array<T, 3> C; - static_assert((std::tuple_size<C>::value == 3), ""); + typedef std::array<T, N> C; + static_assert((std::tuple_size<C>::value == N), ""); + } + { + typedef std::array<T const, N> C; + static_assert((std::tuple_size<C>::value == N), ""); + } + { + typedef std::array<T volatile, N> C; + static_assert((std::tuple_size<C>::value == N), ""); } { - typedef double T; - typedef std::array<T, 0> C; - static_assert((std::tuple_size<C>::value == 0), ""); + typedef std::array<T const volatile, N> C; + static_assert((std::tuple_size<C>::value == N), ""); } } + +int main() +{ + test<double, 0>(); + test<double, 3>(); + test<double, 5>(); +} diff --git a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp index 9a303bae32f..5ac838b3742 100644 --- a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp @@ -15,16 +15,41 @@ #include <utility> -int main() +template <class T1, class T2> +void test() { { - typedef std::pair<int, short> P1; - static_assert((std::is_same<std::tuple_element<0, P1>::type, int>::value), ""); - static_assert((std::is_same<std::tuple_element<1, P1>::type, short>::value), ""); + typedef T1 Exp1; + typedef T2 Exp2; + typedef std::pair<T1, T2> P; + static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); + } + { + typedef T1 const Exp1; + typedef T2 const Exp2; + typedef std::pair<T1, T2> const P; + static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); + } + { + typedef T1 volatile Exp1; + typedef T2 volatile Exp2; + typedef std::pair<T1, T2> volatile P; + static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); } { - typedef std::pair<int*, char> P1; - static_assert((std::is_same<std::tuple_element<0, P1>::type, int*>::value), ""); - static_assert((std::is_same<std::tuple_element<1, P1>::type, char>::value), ""); + typedef T1 const volatile Exp1; + typedef T2 const volatile Exp2; + typedef std::pair<T1, T2> const volatile P; + static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); + static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); } } + +int main() +{ + test<int, short>(); + test<int*, char>(); +} diff --git a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp index 2be694e8a30..3756e963fa3 100644 --- a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp @@ -21,4 +21,16 @@ int main() typedef std::pair<int, short> P1; static_assert((std::tuple_size<P1>::value == 2), ""); } + { + typedef std::pair<int, short> const P1; + static_assert((std::tuple_size<P1>::value == 2), ""); + } + { + typedef std::pair<int, short> volatile P1; + static_assert((std::tuple_size<P1>::value == 2), ""); + } + { + typedef std::pair<int, short> const volatile P1; + static_assert((std::tuple_size<P1>::value == 2), ""); + } } |