Skip to content

Commit dd7a9d2

Browse files
Abseil Teamcopybara-github
authored andcommitted
Add support of 18-member structs to gmock UnpackStructImpl.
PiperOrigin-RevId: 463961734 Change-Id: Ib62e320a745c190955f181c1f4f12e4cd407ef22
1 parent 3bc8fb3 commit dd7a9d2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

googlemock/include/gmock/gmock-matchers.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,11 @@ auto UnpackStructImpl(const T& t, MakeIndexSequence<17>, char) {
32403240
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = t;
32413241
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
32423242
}
3243+
template <typename T>
3244+
auto UnpackStructImpl(const T& t, MakeIndexSequence<18>, char) {
3245+
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = t;
3246+
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
3247+
}
32433248
#endif // defined(__cpp_structured_bindings)
32443249

32453250
template <size_t I, typename T>
@@ -3306,8 +3311,8 @@ class FieldsAreMatcherImpl<Struct, IndexSequence<I...>>
33063311
std::vector<StringMatchResultListener> inner_listener(sizeof...(I));
33073312

33083313
VariadicExpand(
3309-
{failed_pos == ~size_t{} && !std::get<I>(matchers_).MatchAndExplain(
3310-
std::get<I>(tuple), &inner_listener[I])
3314+
{failed_pos == ~size_t{}&& !std::get<I>(matchers_).MatchAndExplain(
3315+
std::get<I>(tuple), &inner_listener[I])
33113316
? failed_pos = I
33123317
: 0 ...});
33133318
if (failed_pos != ~size_t{}) {

googlemock/test/gmock-matchers-comparisons_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,16 @@ TEST(FieldsAreTest, StructuredBindings) {
17101710
};
17111711
EXPECT_THAT(MyVarType16{},
17121712
FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1713+
struct MyVarType17 {
1714+
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
1715+
};
1716+
EXPECT_THAT(MyVarType17{},
1717+
FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1718+
struct MyVarType18 {
1719+
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r;
1720+
};
1721+
EXPECT_THAT(MyVarType18{},
1722+
FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
17131723
}
17141724
#endif
17151725

0 commit comments

Comments
 (0)