mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Allow IsOkAndHolds to rely on duck typing for matching StatusOr like types
instead of uniquely `absl::StatusOr`, e.g. `google::cloud::StatusOr`. This is intended to support existing types that provide compliant `.ok()` and `.status()`. However support for types other than absl::StatusOr is not a guaranteed feature and may be removed in the future PiperOrigin-RevId: 828072487 Change-Id: I1ae696b41eecf6048bd7a4ae3d893648e57e81d1
This commit is contained in:
committed by
Copybara-Service
parent
7374f9b0f4
commit
6d94b2ce15
@@ -69,8 +69,8 @@ class IsOkAndHoldsMatcherImpl
|
||||
bool MatchAndExplain(
|
||||
StatusOrType actual_value,
|
||||
::testing::MatchResultListener* result_listener) const override {
|
||||
if (!GetStatus(actual_value).ok()) {
|
||||
*result_listener << "which has status " << GetStatus(actual_value);
|
||||
if (!actual_value.ok()) {
|
||||
*result_listener << "which has status " << actual_value.status();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user