Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/googletest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-07-29 03:14:35 +0300
committerCopybara-Service <copybara-worker@google.com>2022-07-29 03:15:30 +0300
commitdd7a9d29a33de34836c345c3b753d4eba15c5f44 (patch)
tree5cc66eb50715217b2cb121a63f11594acb24d244 /googlemock
parent3bc8fb37232e0d51c2ce80094ea25ef6bf416187 (diff)
Add support of 18-member structs to gmock UnpackStructImpl.
PiperOrigin-RevId: 463961734 Change-Id: Ib62e320a745c190955f181c1f4f12e4cd407ef22
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h9
-rw-r--r--googlemock/test/gmock-matchers-comparisons_test.cc10
2 files changed, 17 insertions, 2 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 3c8cc32e..f45ace18 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -3240,6 +3240,11 @@ auto UnpackStructImpl(const T& t, MakeIndexSequence<17>, char) {
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = t;
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
}
+template <typename T>
+auto UnpackStructImpl(const T& t, MakeIndexSequence<18>, char) {
+ const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = t;
+ return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
+}
#endif // defined(__cpp_structured_bindings)
template <size_t I, typename T>
@@ -3306,8 +3311,8 @@ class FieldsAreMatcherImpl<Struct, IndexSequence<I...>>
std::vector<StringMatchResultListener> inner_listener(sizeof...(I));
VariadicExpand(
- {failed_pos == ~size_t{} && !std::get<I>(matchers_).MatchAndExplain(
- std::get<I>(tuple), &inner_listener[I])
+ {failed_pos == ~size_t{}&& !std::get<I>(matchers_).MatchAndExplain(
+ std::get<I>(tuple), &inner_listener[I])
? failed_pos = I
: 0 ...});
if (failed_pos != ~size_t{}) {
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index c90b0b4e..1c6cac62 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -1710,6 +1710,16 @@ TEST(FieldsAreTest, StructuredBindings) {
};
EXPECT_THAT(MyVarType16{},
FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+ struct MyVarType17 {
+ int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
+ };
+ EXPECT_THAT(MyVarType17{},
+ FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+ struct MyVarType18 {
+ int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r;
+ };
+ EXPECT_THAT(MyVarType18{},
+ FieldsAre(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
#endif