mirror of
https://github.com/google/googletest.git
synced 2026-09-25 04:09:59 +03:00
Fix the compilation of the matcher UnorderedElementsAre when used with
a native pointer and size PiperOrigin-RevId: 983276604 Change-Id: I76ee9771bae7b0801e6aa74c0786bf5809b43226
This commit is contained in:
committed by
Copybara-Service
parent
f840327b0f
commit
4267679b68
@@ -4150,7 +4150,8 @@ class [[nodiscard]] UnorderedElementsAreMatcher {
|
|||||||
template <typename Container>
|
template <typename Container>
|
||||||
operator Matcher<Container>() const {
|
operator Matcher<Container>() const {
|
||||||
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
|
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
|
||||||
typedef typename internal::RangeTraits<RawContainer>::value_type Element;
|
typedef typename internal::StlContainerView<RawContainer>::type View;
|
||||||
|
typedef typename internal::RangeTraits<View>::value_type Element;
|
||||||
typedef ::std::vector<Matcher<const Element&>> MatcherVec;
|
typedef ::std::vector<Matcher<const Element&>> MatcherVec;
|
||||||
MatcherVec matchers;
|
MatcherVec matchers;
|
||||||
matchers.reserve(::std::tuple_size<MatcherTuple>::value);
|
matchers.reserve(::std::tuple_size<MatcherTuple>::value);
|
||||||
|
|||||||
@@ -2288,6 +2288,13 @@ TEST_F(UnorderedElementsAreTest, WorksWithUncopyable) {
|
|||||||
UnorderedElementsAre(Truly(ValueIsPositive), UncopyableIs(-3)));
|
UnorderedElementsAre(Truly(ValueIsPositive), UncopyableIs(-3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(UnorderedElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {
|
||||||
|
int array[] = {0, 1};
|
||||||
|
::std::tuple<int*, size_t> array_as_tuple(array, 2);
|
||||||
|
EXPECT_THAT(array_as_tuple, UnorderedElementsAre(1, 0));
|
||||||
|
EXPECT_THAT(array_as_tuple, Not(UnorderedElementsAre(0)));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) {
|
TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) {
|
||||||
const int a[] = {1, 2, 3};
|
const int a[] = {1, 2, 3};
|
||||||
std::vector<int> s(std::begin(a), std::end(a));
|
std::vector<int> s(std::begin(a), std::end(a));
|
||||||
|
|||||||
Reference in New Issue
Block a user