Update dependency googletest to 0.12 #84
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.11
->0.12
Release Notes
google/googletest-rust (googletest)
v0.12.0
Compare Source
Breaking changes
Matcher trait definition
The
Matcher
trait definition has changed:Pre 0.12.0
0.12.0
This makes the trait implementation more generic in three ways:
Matcher
for multiple types, sinceActual
is now a generic type parameter.ActualT
can be passed as value if it implementsCopy
, which solved #351.ActualT
is a reference, theMatcher
implementation can put constraint on its lifetime, which solved #323.We tried to make sure this change had as limited an impact on users of the library as possible. Often, the library can be updated without changes on the tests. However, there are two areas requiring changes:
Matcher
implementationObviously, libraries implementing their own matcher will need to update their implementation to match the new trait definition. For instance:
Pre 0.12.0
will become:
If
MyEnum
implementsCopy
, it is appropriate to also implementMatcher<MyEnum>
.MatcherBase
is a super trait toMatcher
which allow the usage of.and(...)
and.or(...)
.eq(...)
often becomeseq(&...)
The
eq(...)
matcher now expects a type matching the actual reference-ness. In other words, you may get error:for instance from a test like:
The issue is that
actual
is auto-ref to match theCopy
bound from the matcher. However,verify_that!
is not able to auto-refexpected
which stays aMyStruct
. The simple solution is to add a&
beforeexpected
.Even if the snippet above compiles, it will look strange to the reader, as it seems to compare a
MyStruct
to a&MyStruct
.There are two solutions here:
&
toactual
as well, since the auto-ref will detect that another&
is not necessary.verify_that!(&actual, eq(&expected))
verify_eq!()
which supports auto-ref on bothactual
andexpected
.verify_eq!(actual, expected)
.Changes to
property!
andmatches_pattern!
Receiver reference-ness
property!
andmatches_pattern!
now requires that the receiver must also be referenced in the declaration to match the method definition. In other words,fn method1(&self) -> ...
requiresmatches_pattern!(&MyStruct { method1(): ....})
andproperty!(&MyStruct.method1(), ...)
.Dereference not necessary
Previously,
property!
andmatches_pattern!
required to add a*
to "dereference" the method returned value.Pre 0.12.0
In 0.12.0, this is not necessary nor supported
New features
expect_eq!(..., ...)
and friendsGoogleTest now provides macros similar to
assert_eq!()
and friends withverify_
andexpect_
behavior.auto_eq
Most macro matchers now automatically inject
eq()
matchers if the parameters they are expecting does not implementMatcher
.For instance:
Generalized
.into_test_result()?
.into_test_result()
now extends allstd::result::Result
andOption
which simplifies error handling in test arrangements.matches_pattern!(...)
binding modesmatches_pattern!(...)
now supports both move and reference binding modes, to be more consistent with Rust pattern matching.For instance,
This is useful, if you prefer to capture some fields by reference, with the
ref
keyword, and some by value (they would need to implementCopy
).Full Changelog: google/googletest-rust@v0.11.0...v0.12.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.