From 56d151ead24cbd462cbdf53e53b023f2c0d2cb68 Mon Sep 17 00:00:00 2001 From: walk_alone <2390335608@qq.com> Date: Sun, 5 May 2024 17:20:54 +0800 Subject: [PATCH] restore --- test/cpp/phi/core/unroll_array_ops_test.cc | 2 +- test/cpp/utils/span_test.cc | 357 +++++++++------------ 2 files changed, 157 insertions(+), 202 deletions(-) diff --git a/test/cpp/phi/core/unroll_array_ops_test.cc b/test/cpp/phi/core/unroll_array_ops_test.cc index 65d00dace78cc..d2233c95abfe8 100644 --- a/test/cpp/phi/core/unroll_array_ops_test.cc +++ b/test/cpp/phi/core/unroll_array_ops_test.cc @@ -28,7 +28,7 @@ bool CheckEquality(const T* p, size_t n, T val) { template bool FillConstantTestMain() { - static_assert(D1 >= D2, ""); + static_assert(D1 >= D2); std::array arr; arr.fill(0); diff --git a/test/cpp/utils/span_test.cc b/test/cpp/utils/span_test.cc index 3244990221f17..c6960dbad543a 100644 --- a/test/cpp/utils/span_test.cc +++ b/test/cpp/utils/span_test.cc @@ -26,17 +26,17 @@ using paddle::span; // span(); TEST(default_ctor, span) { - static_assert(std::is_nothrow_default_constructible>::value, ""); - static_assert(std::is_nothrow_default_constructible>::value, ""); - static_assert(!std::is_default_constructible>::value, ""); + static_assert(std::is_nothrow_default_constructible>::value); + static_assert(std::is_nothrow_default_constructible>::value); + static_assert(!std::is_default_constructible>::value); // dynamic size { constexpr span s{}; - static_assert(s.empty(), ""); - static_assert(s.data() == nullptr, ""); + static_assert(s.empty()); + static_assert(s.data() == nullptr); #ifndef _MSC_VER - static_assert(s.begin() == s.end(), ""); + static_assert(s.begin() == s.end()); #else CHECK(s.begin() == s.end()); #endif @@ -45,10 +45,10 @@ TEST(default_ctor, span) { // fixed size { constexpr span s{}; - static_assert(s.empty(), ""); - static_assert(s.data() == nullptr, ""); + static_assert(s.empty()); + static_assert(s.data() == nullptr); #ifndef _MSC_VER - static_assert(s.begin() == s.end(), ""); + static_assert(s.begin() == s.end()); #else CHECK(s.begin() == s.end()); #endif @@ -57,15 +57,13 @@ TEST(default_ctor, span) { // span(pointer ptr, size_type count); TEST(pointer_length_ctor, span) { - static_assert(std::is_constructible, int*, int>::value, ""); - static_assert(std::is_constructible, int*, int>::value, ""); - static_assert(std::is_constructible, const int*, int>::value, - ""); - static_assert(std::is_constructible, int*, int>::value, ""); - static_assert(std::is_constructible, int*, int>::value, - ""); + static_assert(std::is_constructible, int*, int>::value); + static_assert(std::is_constructible, int*, int>::value); + static_assert(std::is_constructible, const int*, int>::value); + static_assert(std::is_constructible, int*, int>::value); + static_assert(std::is_constructible, int*, int>::value); static_assert( - std::is_constructible, const int*, int>::value, ""); + std::is_constructible, const int*, int>::value); // dynamic size { @@ -92,11 +90,10 @@ TEST(pointer_length_ctor, span) { // span(pointer ptr, pointer ptr); TEST(pointer_pointer_ctor, span) { - static_assert(std::is_constructible, int*, int*>::value, ""); - static_assert(!std::is_constructible, float*, float*>::value, ""); - static_assert(std::is_constructible, int*, int*>::value, ""); - static_assert(!std::is_constructible, float*, float*>::value, - ""); + static_assert(std::is_constructible, int*, int*>::value); + static_assert(!std::is_constructible, float*, float*>::value); + static_assert(std::is_constructible, int*, int*>::value); + static_assert(!std::is_constructible, float*, float*>::value); // dynamic size { @@ -125,49 +122,40 @@ TEST(c_array_ctor, span) { using int_array_t = int[3]; // NOLINT using float_array_t = float[3]; // NOLINT - static_assert(std::is_nothrow_constructible, int_array_t&>::value, - ""); - static_assert(!std::is_constructible, int_array_t const&>::value, - ""); - static_assert(!std::is_constructible, float_array_t>::value, ""); + static_assert(std::is_nothrow_constructible, int_array_t&>::value); + static_assert(!std::is_constructible, int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, ""); - static_assert( - std::is_nothrow_constructible, int_array_t const&>::value, - ""); - static_assert(!std::is_constructible, float_array_t>::value, - ""); + std::is_nothrow_constructible, int_array_t&>::value); + static_assert(std::is_nothrow_constructible, + int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, ""); - static_assert(!std::is_constructible, int_array_t const&>::value, - ""); - static_assert(!std::is_constructible, float_array_t&>::value, - ""); + std::is_nothrow_constructible, int_array_t&>::value); + static_assert( + !std::is_constructible, int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t&>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, - ""); + std::is_nothrow_constructible, int_array_t&>::value); static_assert(std::is_nothrow_constructible, - int_array_t const&>::value, - ""); + int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t>::value, ""); + !std::is_constructible, float_array_t>::value); - static_assert(!std::is_constructible, int_array_t&>::value, ""); + static_assert(!std::is_constructible, int_array_t&>::value); static_assert( - !std::is_constructible, int_array_t const&>::value, ""); - static_assert(!std::is_constructible, float_array_t&>::value, - ""); + !std::is_constructible, int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t&>::value); static_assert( - !std::is_constructible, int_array_t&>::value, ""); + !std::is_constructible, int_array_t&>::value); static_assert( - !std::is_constructible, int_array_t const&>::value, - ""); + !std::is_constructible, int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t&>::value, ""); + !std::is_constructible, float_array_t&>::value); // non-const, dynamic size { @@ -215,66 +203,56 @@ TEST(std_array_ctor, span) { using float_array_t = std::array; using zero_array_t = std::array; - static_assert(std::is_nothrow_constructible, int_array_t&>::value, - ""); - static_assert(!std::is_constructible, int_array_t const&>::value, - ""); - static_assert(!std::is_constructible, float_array_t>::value, ""); + static_assert(std::is_nothrow_constructible, int_array_t&>::value); + static_assert(!std::is_constructible, int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, ""); - static_assert( - std::is_nothrow_constructible, int_array_t const&>::value, - ""); + std::is_nothrow_constructible, int_array_t&>::value); + static_assert(std::is_nothrow_constructible, + int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t const&>::value, ""); + !std::is_constructible, float_array_t const&>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, ""); - static_assert(!std::is_constructible, int_array_t const&>::value, - ""); - static_assert(!std::is_constructible, float_array_t>::value, ""); + std::is_nothrow_constructible, int_array_t&>::value); + static_assert( + !std::is_constructible, int_array_t const&>::value); + static_assert(!std::is_constructible, float_array_t>::value); static_assert( - std::is_nothrow_constructible, int_array_t&>::value, - ""); + std::is_nothrow_constructible, int_array_t&>::value); static_assert(std::is_nothrow_constructible, - int_array_t const&>::value, - ""); + int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t const&>::value, - ""); + !std::is_constructible, float_array_t const&>::value); - static_assert(!std::is_constructible, int_array_t&>::value, ""); + static_assert(!std::is_constructible, int_array_t&>::value); static_assert( - !std::is_constructible, int_array_t const&>::value, ""); + !std::is_constructible, int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t const&>::value, ""); + !std::is_constructible, float_array_t const&>::value); static_assert( - !std::is_constructible, int_array_t&>::value, ""); + !std::is_constructible, int_array_t&>::value); static_assert( - !std::is_constructible, int_array_t const&>::value, - ""); + !std::is_constructible, int_array_t const&>::value); static_assert( - !std::is_constructible, float_array_t&>::value, ""); + !std::is_constructible, float_array_t&>::value); - static_assert(std::is_constructible, zero_array_t&>::value, ""); - static_assert(!std::is_constructible, const zero_array_t&>::value, - ""); - static_assert(std::is_constructible, zero_array_t&>::value, - ""); + static_assert(std::is_constructible, zero_array_t&>::value); + static_assert(!std::is_constructible, const zero_array_t&>::value); + static_assert(std::is_constructible, zero_array_t&>::value); static_assert( - std::is_constructible, const zero_array_t&>::value, ""); + std::is_constructible, const zero_array_t&>::value); - static_assert(std::is_constructible, zero_array_t&>::value, ""); + static_assert(std::is_constructible, zero_array_t&>::value); + static_assert( + !std::is_constructible, const zero_array_t&>::value); static_assert( - !std::is_constructible, const zero_array_t&>::value, ""); - static_assert(std::is_constructible, zero_array_t&>::value, - ""); + std::is_constructible, zero_array_t&>::value); static_assert( - std::is_constructible, const zero_array_t&>::value, - ""); + std::is_constructible, const zero_array_t&>::value); // non-const, dynamic size { @@ -321,34 +299,29 @@ TEST(ctor_from_containers, span) { using vec_t = std::vector; using deque_t = std::deque; - static_assert(std::is_constructible, vec_t&>::value, ""); - static_assert(!std::is_constructible, const vec_t&>::value, ""); - static_assert(!std::is_constructible, const deque_t&>::value, ""); + static_assert(std::is_constructible, vec_t&>::value); + static_assert(!std::is_constructible, const vec_t&>::value); + static_assert(!std::is_constructible, const deque_t&>::value); - static_assert(std::is_constructible, vec_t&>::value, ""); - static_assert(std::is_constructible, const vec_t&>::value, - ""); - static_assert(!std::is_constructible, const deque_t&>::value, - ""); + static_assert(std::is_constructible, vec_t&>::value); + static_assert(std::is_constructible, const vec_t&>::value); + static_assert(!std::is_constructible, const deque_t&>::value); - static_assert(!std::is_constructible, vec_t&>::value, ""); - static_assert(!std::is_constructible, const vec_t&>::value, ""); - static_assert(!std::is_constructible, const deque_t&>::value, - ""); + static_assert(!std::is_constructible, vec_t&>::value); + static_assert(!std::is_constructible, const vec_t&>::value); + static_assert(!std::is_constructible, const deque_t&>::value); - static_assert(!std::is_constructible, vec_t&>::value, ""); - static_assert(!std::is_constructible, const vec_t&>::value, - ""); + static_assert(!std::is_constructible, vec_t&>::value); + static_assert( + !std::is_constructible, const vec_t&>::value); static_assert( - !std::is_constructible, const deque_t&>::value, ""); + !std::is_constructible, const deque_t&>::value); // vector is not contiguous and cannot be converted to span // Regression test for https://github.com/tcbrindle/span/issues/24 - static_assert(!std::is_constructible, std::vector&>::value, - ""); - static_assert( - !std::is_constructible, const std::vector&>::value, - ""); + static_assert(!std::is_constructible, std::vector&>::value); + static_assert(!std::is_constructible, + const std::vector&>::value); // non-const, dynamic size { @@ -399,91 +372,73 @@ TEST(ctor_from_spans, span) { using dynamic_span = span; using dynamic_const_span = span; - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, ""); - static_assert(!std::is_constructible::value, ""); - static_assert(!std::is_constructible::value, ""); - static_assert(!std::is_constructible::value, ""); - static_assert(std::is_nothrow_constructible::value, - ""); - static_assert(!std::is_constructible::value, - ""); - - static_assert( - std::is_nothrow_constructible::value, ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, - ""); - static_assert(!std::is_constructible::value, ""); - static_assert(!std::is_constructible::value, - ""); - static_assert( - std::is_nothrow_constructible::value, ""); - static_assert( - std::is_nothrow_constructible::value, - ""); - - static_assert(!std::is_constructible::value, ""); - static_assert(!std::is_constructible::value, ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, ""); - static_assert(!std::is_constructible::value, ""); - static_assert(std::is_nothrow_constructible::value, - ""); - static_assert(!std::is_constructible::value, - ""); - - static_assert(!std::is_constructible::value, ""); - static_assert(!std::is_constructible::value, - ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, - ""); - static_assert(std::is_nothrow_constructible::value, - ""); - static_assert( - std::is_nothrow_constructible::value, ""); - static_assert( - std::is_nothrow_constructible::value, - ""); - - static_assert(std::is_nothrow_constructible::value, - ""); - static_assert(!std::is_constructible::value, - ""); - static_assert(std::is_nothrow_constructible::value, - ""); - static_assert(!std::is_constructible::value, - ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, ""); - static_assert(!std::is_constructible::value, - ""); - - static_assert( - std::is_nothrow_constructible::value, ""); - static_assert( - std::is_nothrow_constructible::value, - ""); - static_assert( - std::is_nothrow_constructible::value, ""); - static_assert( - std::is_nothrow_constructible::value, - ""); - static_assert( - std::is_nothrow_constructible::value, - ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(std::is_trivially_move_constructible::value, - ""); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_nothrow_constructible::value); + static_assert(!std::is_constructible::value); + + static_assert( + std::is_nothrow_constructible::value); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(!std::is_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + static_assert(std::is_nothrow_constructible::value); + + static_assert(!std::is_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_nothrow_constructible::value); + static_assert(!std::is_constructible::value); + + static_assert(!std::is_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert(std::is_nothrow_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + + static_assert(std::is_nothrow_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_nothrow_constructible::value); + static_assert(!std::is_constructible::value); + static_assert(std::is_trivially_copyable::value); + static_assert(std::is_trivially_move_constructible::value); + static_assert( + !std::is_constructible::value); + + static_assert( + std::is_nothrow_constructible::value); + static_assert(std::is_nothrow_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + static_assert( + std::is_nothrow_constructible::value); + static_assert(std::is_trivially_copyable::value); + static_assert( + std::is_trivially_move_constructible::value); constexpr zero_const_span s0{}; constexpr dynamic_const_span d{s0}; - static_assert(d.empty(), ""); - static_assert(d.data() == nullptr, ""); + static_assert(d.empty()); + static_assert(d.data() == nullptr); #ifndef _MSC_VER - static_assert(d.begin() == d.end(), ""); + static_assert(d.begin() == d.end()); #else CHECK(d.begin() == d.end()); #endif @@ -496,7 +451,7 @@ TEST(subview, span) { span s{arr}; auto f = s.first<3>(); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(f.size(), 3UL); CHECK_EQ(f.data(), arr); CHECK_EQ(f.begin(), arr); @@ -509,7 +464,7 @@ TEST(subview, span) { span s{arr}; auto l = s.last<3>(); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(l.size(), 3UL); CHECK_EQ(l.data(), arr + 2); CHECK_EQ(l.begin(), arr + 2); @@ -522,7 +477,7 @@ TEST(subview, span) { span s{arr}; auto ss = s.subspan<1, 2>(); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(ss.size(), 2UL); CHECK_EQ(ss.data(), arr + 1); CHECK_EQ(ss.begin(), arr + 1); @@ -535,7 +490,7 @@ TEST(subview, span) { span s{arr}; auto f = s.first(3); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(f.size(), 3UL); CHECK_EQ(f.data(), arr); CHECK_EQ(f.begin(), arr); @@ -548,7 +503,7 @@ TEST(subview, span) { span s{arr}; auto l = s.last(3); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(l.size(), 3UL); CHECK_EQ(l.data(), arr + 2); CHECK_EQ(l.begin(), arr + 2); @@ -561,7 +516,7 @@ TEST(subview, span) { span s{arr}; auto ss = s.subspan(1, 2); - static_assert(std::is_same>::value, ""); + static_assert(std::is_same>::value); CHECK_EQ(ss.size(), 2UL); CHECK_EQ(ss.data(), arr + 1); CHECK_EQ(ss.begin(), arr + 1); @@ -574,12 +529,12 @@ TEST(subview, span) { TEST(observers, span) { // We already use this everywhere, but whatever constexpr span empty{}; - static_assert(empty.size() == 0, ""); // NOLINT - static_assert(empty.empty(), ""); + static_assert(empty.size() == 0); // NOLINT + static_assert(empty.empty()); constexpr int arr[] = {1, 2, 3}; // NOLINT - static_assert(span{arr}.size() == 3, ""); - static_assert(!span{arr}.empty(), ""); + static_assert(span{arr}.size() == 3); + static_assert(!span{arr}.empty()); } TEST(element_access, span) {