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:
Zie Weaver
2025-11-04 11:52:12 -08:00
committed by Copybara-Service
parent 7374f9b0f4
commit 6d94b2ce15

View File

@@ -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;
}