From be19b174f7b42bd347da9d741da5ee1bde4ef263 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Wed, 19 Oct 2022 12:21:45 -0700 Subject: [PATCH] [promises] Cleanup: Always assert that contexts are non-null (#31397) --- src/core/lib/promise/context.h | 2 +- test/core/promise/context_test.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/promise/context.h b/src/core/lib/promise/context.h index 172b19e879e..9dc9c4923dd 100644 --- a/src/core/lib/promise/context.h +++ b/src/core/lib/promise/context.h @@ -73,7 +73,7 @@ bool HasContext() { return promise_detail::Context::get() != nullptr; } -// Retrieve the current value of a context. +// Retrieve the current value of a context, or abort if the value is unset. template T* GetContext() { auto* p = promise_detail::Context::get(); diff --git a/test/core/promise/context_test.cc b/test/core/promise/context_test.cc index 29ef47a3b89..8be2c5b5327 100644 --- a/test/core/promise/context_test.cc +++ b/test/core/promise/context_test.cc @@ -29,7 +29,7 @@ TEST(Context, WithContext) { EXPECT_FALSE(HasContext()); TestContext test; EXPECT_FALSE(HasContext()); - EXPECT_EQ(test.done, false); + EXPECT_FALSE(test.done); WithContext( []() { EXPECT_TRUE(HasContext()); @@ -37,7 +37,7 @@ TEST(Context, WithContext) { }, &test)(); EXPECT_FALSE(HasContext()); - EXPECT_EQ(test.done, true); + EXPECT_TRUE(test.done); } } // namespace grpc_core