proxygen
OrderingTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <folly/lang/Ordering.h>
18 
20 
21 using namespace folly;
22 
23 template <typename T>
24 struct OddCompare {
25  constexpr ordering operator()(T const& a, T const& b) const {
26  return b < a ? ordering::lt : a < b ? ordering::gt : ordering::eq;
27  }
28 };
29 
30 class OrderingTest : public testing::Test {};
31 
33  EXPECT_EQ(-1, int(ordering::lt));
34  EXPECT_EQ(0, int(ordering::eq));
35  EXPECT_EQ(+1, int(ordering::gt));
36 }
37 
42 
46 }
47 
50  EXPECT_FALSE(op(3, 4));
51  EXPECT_TRUE(op(3, 3));
52  EXPECT_FALSE(op(4, 3));
53 }
54 
57  EXPECT_TRUE(op(3, 4));
58  EXPECT_FALSE(op(3, 3));
59  EXPECT_TRUE(op(4, 3));
60 }
61 
64  EXPECT_FALSE(op(3, 4));
65  EXPECT_FALSE(op(3, 3));
66  EXPECT_TRUE(op(4, 3));
67 }
68 
71  EXPECT_FALSE(op(3, 4));
72  EXPECT_TRUE(op(3, 3));
73  EXPECT_TRUE(op(4, 3));
74 }
75 
78  EXPECT_TRUE(op(3, 4));
79  EXPECT_FALSE(op(3, 3));
80  EXPECT_FALSE(op(4, 3));
81 }
82 
85  EXPECT_TRUE(op(3, 4));
86  EXPECT_TRUE(op(3, 3));
87  EXPECT_FALSE(op(4, 3));
88 }
constexpr ordering to_ordering(T c)
Definition: Ordering.h:24
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr ordering operator()(T const &a, T const &b) const
folly::std T
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
ordering
Definition: Ordering.h:21
char a
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862