all: Pass clang-tidy modernize-unary-static-assert check

Change-Id: If8c3e0d150c85713264fccbe6d2aca906b85bd18
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56924
Commit-Queue: Henri Chataing <henrichataing@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
This commit is contained in:
Henri Chataing 2022-08-10 20:09:28 +00:00 committed by CQ Bot Account
parent 3cd002f126
commit 6e3bc74cc4
4 changed files with 18 additions and 16 deletions

View File

@ -38,6 +38,7 @@ Checks: >
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-bool-literals,
modernize-use-equals-delete,
modernize-use-noexcept,
@ -88,9 +89,6 @@ HeaderFilterRegex: '.*'
# Note: added in c++11
# @ modernize-redundant-void-arg:
# modernize-return-braced-init-list:
# @ modernize-unary-static-assert:
# Note: added in c++17
# The message argument can be omitted when it is empty
# @ modernize-use-auto:
# Advises to use auto when initializing with a cast to
# avoid duplicating the type name

View File

@ -111,7 +111,7 @@ TEST(SpanTest, MakeSpanFromDataAndSize) {
auto made_span = make_span(vector.data(), vector.size());
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == dynamic_extent, "");
static_assert(decltype(made_span)::extent == dynamic_extent);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -127,7 +127,7 @@ TEST(SpanTest, MakeSpanFromPointerPair) {
auto made_span = make_span(vector.data(), vector.data() + vector.size());
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == dynamic_extent, "");
static_assert(decltype(made_span)::extent == dynamic_extent);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -139,7 +139,7 @@ TEST(SpanTest, MakeSpanFromConstexprArray) {
constexpr auto made_span = make_span(kArray);
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == 5, "");
static_assert(decltype(made_span)::extent == 5);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -151,7 +151,7 @@ TEST(SpanTest, MakeSpanFromStdArray) {
auto made_span = make_span(kArray);
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == 5, "");
static_assert(decltype(made_span)::extent == 5);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -163,7 +163,7 @@ TEST(SpanTest, MakeSpanFromConstContainer) {
auto made_span = make_span(vector);
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == dynamic_extent, "");
static_assert(decltype(made_span)::extent == dynamic_extent);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -177,7 +177,7 @@ TEST(SpanTest, MakeStaticSpanFromConstContainer) {
auto made_span = make_span<5>(vector);
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == 5, "");
static_assert(decltype(made_span)::extent == 5);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -191,7 +191,7 @@ TEST(SpanTest, MakeSpanFromContainer) {
auto made_span = make_span(vector);
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == dynamic_extent, "");
static_assert(decltype(made_span)::extent == dynamic_extent);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -205,7 +205,7 @@ TEST(SpanTest, MakeStaticSpanFromContainer) {
auto made_span = make_span<5>(vector);
EXPECT_EQ(expected_span.data(), make_span<5>(vector).data());
EXPECT_EQ(expected_span.size(), make_span<5>(vector).size());
static_assert(decltype(make_span<5>(vector))::extent == 5, "");
static_assert(decltype(make_span<5>(vector))::extent == 5);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -235,7 +235,7 @@ TEST(SpanTest, MakeSpanFromRValueContainer) {
auto made_span = make_span(static_cast<std::vector<int>&&>(vector));
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == dynamic_extent, "");
static_assert(decltype(made_span)::extent == dynamic_extent);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");
@ -253,7 +253,7 @@ TEST(SpanTest, MakeStaticSpanFromRValueContainer) {
auto made_span = make_span<5>(static_cast<std::vector<int>&&>(vector));
EXPECT_EQ(expected_span.data(), made_span.data());
EXPECT_EQ(expected_span.size(), made_span.size());
static_assert(decltype(made_span)::extent == 5, "");
static_assert(decltype(made_span)::extent == 5);
static_assert(
std::is_same<decltype(expected_span), decltype(made_span)>::value,
"the type of made_span differs from expected_span!");

View File

@ -120,8 +120,8 @@ pw::Result<std::unique_ptr<int>> ReturnUniquePtr() {
}
TEST(Result, ElementType) {
static_assert(std::is_same<pw::Result<int>::value_type, int>(), "");
static_assert(std::is_same<pw::Result<char>::value_type, char>(), "");
static_assert(std::is_same<pw::Result<int>::value_type, int>());
static_assert(std::is_same<pw::Result<char>::value_type, char>());
}
TEST(Result, TestMoveOnlyInitialization) {
@ -1345,7 +1345,7 @@ TEST(Result, TestPointerValueConst) {
TEST(Result, ResultVectorOfUniquePointerCanReserveAndResize) {
using EvilType = std::vector<std::unique_ptr<int>>;
static_assert(std::is_copy_constructible<EvilType>::value, "");
static_assert(std::is_copy_constructible<EvilType>::value);
std::vector<::pw::Result<EvilType>> v(5);
v.reserve(v.capacity() + 10);
v.resize(v.capacity() + 10);

View File

@ -21,6 +21,8 @@
// In order to minimize changes from the original, this file does NOT fully
// adhere to Pigweed's style guide.
// NOLINTBEGIN(modernize-unary-static-assert)
#ifndef PW_SPAN_TEST_INCLUDE
#error "The PW_SPAN_TEST_INCLUDE macro must be defined to compile this test."
#endif // PW_SPAN_TEST_INCLUDE
@ -1653,4 +1655,6 @@ TEST(SpanTest, IteratorConversions) {
"Error: const iterator should not be convertible to iterator");
}
// NOLINTEND(modernize-unary-static-assert)
} // namespace PW_SPAN_TEST_NAMESPACE