mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 02:46:40 +00:00
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:
1 parent
2e29b48d26
commit
bd0ef62a8f
3 files changed
+12
-8
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user