xref: /aosp_15_r20/external/grpc-grpc/test/core/event_engine/handle_tests.cc (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 // Copyright 2023 The 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 #include <memory>
15 
16 #include "gtest/gtest.h"
17 
18 #include <grpc/event_engine/event_engine.h>
19 #include <grpc/support/port_platform.h>
20 
21 using ::grpc_event_engine::experimental::EventEngine;
22 
23 template <typename T>
24 class TaskHandleTest : public testing::Test {};
25 
26 using HandleTypes =
27     ::testing::Types<EventEngine::TaskHandle, EventEngine::ConnectionHandle>;
28 TYPED_TEST_SUITE(TaskHandleTest, HandleTypes);
29 
TYPED_TEST(TaskHandleTest,Identity)30 TYPED_TEST(TaskHandleTest, Identity) {
31   TypeParam t{42, 43};
32   ASSERT_EQ(t, t);
33 }
34 
TYPED_TEST(TaskHandleTest,CommutativeEquality)35 TYPED_TEST(TaskHandleTest, CommutativeEquality) {
36   TypeParam t1{42, 43};
37   TypeParam t2 = t1;
38   ASSERT_EQ(t1, t2);
39   ASSERT_EQ(t2, t1);
40 }
41 
TYPED_TEST(TaskHandleTest,Validity)42 TYPED_TEST(TaskHandleTest, Validity) {
43   TypeParam t{42, 43};
44   ASSERT_NE(t, TypeParam::kInvalid);
45   ASSERT_NE(TypeParam::kInvalid, t);
46   ASSERT_EQ(TypeParam::kInvalid, TypeParam::kInvalid);
47 }
48 
main(int argc,char ** argv)49 int main(int argc, char** argv) {
50   testing::InitGoogleTest(&argc, argv);
51   return RUN_ALL_TESTS();
52 }
53