[status_flag] Fix bad stringifier (#37014)

Also add a test for ValueOrFailure stringification

Closes #37014

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37014 from ctiller:status_flag_fix 8194ca3ea8
PiperOrigin-RevId: 645438082
pull/37017/head
Craig Tiller 7 months ago committed by Copybara-Service
parent 4d18248a82
commit 698a66b9c3
  1. 2
      src/core/lib/promise/status_flag.h
  2. 5
      test/core/promise/status_flag_test.cc

@ -263,7 +263,7 @@ class ValueOrFailure {
friend void AbslStringify(Sink& sink, const ValueOrFailure& value) {
if (value.ok()) {
sink.Append("Success(");
sink.Append(absl::StrCat(value));
sink.Append(absl::StrCat(*value));
sink.Append(")");
} else {
sink.Append("Failure");

@ -38,6 +38,11 @@ TEST(StatusFlagTest, Basics) {
EXPECT_FALSE(IsStatusOk(Failure{}));
}
TEST(StatusFlagTest, StringifyValueOrFailure) {
EXPECT_EQ(absl::StrCat(ValueOrFailure<int>(42)), "Success(42)");
EXPECT_EQ(absl::StrCat(ValueOrFailure<int>(Failure{})), "Failure");
}
} // namespace grpc_core
int main(int argc, char** argv) {

Loading…
Cancel
Save