try_seq_metadata_test.cc
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <memory>
16 
17 #include "absl/types/variant.h"
18 #include "gtest/gtest.h"
19 
21 #include <grpc/status.h>
22 
30 
31 namespace grpc_core {
32 
34  ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test"));
35 
36 struct TestMap : public MetadataMap<TestMap, GrpcStatusMetadata> {
38 };
39 
40 TEST(PromiseTest, SucceedAndThenFail) {
43  [&arena] {
44  TestMap m(arena.get());
46  return m;
47  },
48  [&arena]() {
49  TestMap m(arena.get());
51  return m;
52  })();
53  EXPECT_EQ(absl::get<TestMap>(r).get(GrpcStatusMetadata()),
55 }
56 
57 } // namespace grpc_core
58 
59 int main(int argc, char** argv) {
60  ::testing::InitGoogleTest(&argc, argv);
61  return RUN_ALL_TESTS();
62 }
grpc_core::MakeScopedArena
ScopedArenaPtr MakeScopedArena(size_t initial_size, MemoryAllocator *memory_allocator)
Definition: src/core/lib/resource_quota/arena.h:130
metadata_batch.h
get
absl::string_view get(const Cont &c)
Definition: abseil-cpp/absl/strings/str_replace_test.cc:185
GRPC_STATUS_UNAVAILABLE
@ GRPC_STATUS_UNAVAILABLE
Definition: include/grpc/impl/codegen/status.h:143
grpc_event_engine::experimental::MemoryAllocator
Definition: memory_allocator.h:35
grpc_core
Definition: call_metric_recorder.h:31
arena.h
grpc_core::TEST
TEST(AvlTest, NoOp)
Definition: avl_test.cc:21
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
grpc_core::MetadataMap
Definition: metadata_batch.h:984
status.h
main
int main(int argc, char **argv)
Definition: try_seq_metadata_test.cc:59
try_seq.h
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
grpc_core::g_memory_allocator
static auto * g_memory_allocator
Definition: call_finalization_test.cc:24
grpc_core::ResourceQuota::Default
static ResourceQuotaRefPtr Default()
Definition: resource_quota.cc:27
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
resource_quota.h
grpc_core::GrpcStatusMetadata
Definition: metadata_batch.h:293
grpc_core::TrySeq
promise_detail::TrySeq< Functors... > TrySeq(Functors... functors)
Definition: try_seq.h:134
grpc_core::TestMap
Definition: try_seq_metadata_test.cc:36
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
poll.h
fix_build_deps.r
r
Definition: fix_build_deps.py:491
ref_counted_ptr.h
memory_quota.h
memory_allocator.h
regress.m
m
Definition: regress/regress.py:25
absl::variant
Definition: abseil-cpp/absl/types/internal/variant.h:46


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:40