• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <grpc/event_engine/event_engine.h>
15 #include <grpc/support/port_platform.h>
16 
17 #include <memory>
18 
19 #include "absl/strings/str_cat.h"
20 #include "gtest/gtest.h"
21 
22 using ::grpc_event_engine::experimental::EventEngine;
23 
24 template <typename T>
25 class TaskHandleTest : public testing::Test {};
26 
27 using HandleTypes =
28     ::testing::Types<EventEngine::TaskHandle, EventEngine::ConnectionHandle>;
29 TYPED_TEST_SUITE(TaskHandleTest, HandleTypes);
30 
TYPED_TEST(TaskHandleTest,Identity)31 TYPED_TEST(TaskHandleTest, Identity) {
32   TypeParam t{42, 43};
33   ASSERT_EQ(t, t);
34 }
35 
TYPED_TEST(TaskHandleTest,CommutativeEquality)36 TYPED_TEST(TaskHandleTest, CommutativeEquality) {
37   TypeParam t1{42, 43};
38   TypeParam t2 = t1;
39   ASSERT_EQ(t1, t2);
40   ASSERT_EQ(t2, t1);
41 }
42 
TYPED_TEST(TaskHandleTest,Validity)43 TYPED_TEST(TaskHandleTest, Validity) {
44   TypeParam t{42, 43};
45   ASSERT_NE(t, TypeParam::kInvalid);
46   ASSERT_NE(TypeParam::kInvalid, t);
47   ASSERT_EQ(TypeParam::kInvalid, TypeParam::kInvalid);
48 }
49 
TYPED_TEST(TaskHandleTest,AbslStringify)50 TYPED_TEST(TaskHandleTest, AbslStringify) {
51   TypeParam t{42, 43};
52   ASSERT_EQ(absl::StrCat(t), "{000000000000002a,000000000000002b}");
53 }
54 
main(int argc,char ** argv)55 int main(int argc, char** argv) {
56   testing::InitGoogleTest(&argc, argv);
57   return RUN_ALL_TESTS();
58 }
59