Fix clang-tidy issues in common and testing (#3470)

Choosing to make the constructor explicit in the test, rather than
NOLINT, because it seems to better reflect how our code is usually
written (and may be more likely to trip an issue).
This commit is contained in:
Jon Ross-Perkins
2023-12-07 19:06:29 +00:00
committed by GitHub
parent 2e29b48d26
commit bd0ef62a8f
3 changed files with 12 additions and 8 deletions
+6 -5
View File
@@ -25,7 +25,7 @@ struct ReferenceField {
};
struct NoDefaultConstructor {
NoDefaultConstructor(int n) : v(n) {}
explicit NoDefaultConstructor(int n) : v(n) {}
int v;
};
@@ -42,8 +42,8 @@ TEST(StructReflectionTest, CanListInitialize) {
{
using Type = OneField;
using Field = Internal::AnyField<Type>;
static_assert(Internal::CanListInitialize<Type>(0));
static_assert(Internal::CanListInitialize<Type, Field>(0));
static_assert(Internal::CanListInitialize<Type>(nullptr));
static_assert(Internal::CanListInitialize<Type, Field>(nullptr));
static_assert(!Internal::CanListInitialize<Type, Field, Field>(0));
}
@@ -51,7 +51,7 @@ TEST(StructReflectionTest, CanListInitialize) {
using Type = OneFieldNoDefaultConstructor;
using Field = Internal::AnyField<Type>;
static_assert(!Internal::CanListInitialize<Type>(0));
static_assert(Internal::CanListInitialize<Type, Field>(0));
static_assert(Internal::CanListInitialize<Type, Field>(nullptr));
static_assert(!Internal::CanListInitialize<Type, Field, Field>(0));
}
}
@@ -82,7 +82,8 @@ TEST(StructReflectionTest, TwoField) {
TEST(StructReflectionTest, NoDefaultConstructor) {
std::tuple<NoDefaultConstructor, NoDefaultConstructor> fields =
AsTuple(TwoFieldsNoDefaultConstructor{.x = 1, .y = 2});
AsTuple(TwoFieldsNoDefaultConstructor{.x = NoDefaultConstructor(1),
.y = NoDefaultConstructor(2)});
EXPECT_EQ(std::get<0>(fields).v, 1);
EXPECT_EQ(std::get<1>(fields).v, 2);
}