1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 "src/trace_processor/null_term_string_view.h"
18 
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21 
22 namespace perfetto {
23 namespace trace_processor {
24 namespace {
25 
TEST(NullTermStringViewTest,Comparisions)26 TEST(NullTermStringViewTest, Comparisions) {
27   // Test the < operator.
28   EXPECT_FALSE(NullTermStringView() < NullTermStringView());
29   EXPECT_FALSE(NullTermStringView() < NullTermStringView(""));
30   EXPECT_TRUE(NullTermStringView() < NullTermStringView("foo"));
31   EXPECT_TRUE(NullTermStringView("") < NullTermStringView("foo"));
32   EXPECT_FALSE(NullTermStringView("foo") < NullTermStringView("foo"));
33   EXPECT_TRUE(NullTermStringView("foo") < NullTermStringView("fooo"));
34   EXPECT_FALSE(NullTermStringView("fooo") < NullTermStringView("foo"));
35   EXPECT_TRUE(NullTermStringView("bar") < NullTermStringView("foo"));
36 
37   // Test the <= operator.
38   EXPECT_TRUE(NullTermStringView() <= NullTermStringView());
39   EXPECT_TRUE(NullTermStringView() <= NullTermStringView(""));
40   EXPECT_TRUE(NullTermStringView() <= NullTermStringView("foo"));
41   EXPECT_TRUE(NullTermStringView("") <= NullTermStringView("foo"));
42   EXPECT_TRUE(NullTermStringView("foo") <= NullTermStringView("foo"));
43   EXPECT_TRUE(NullTermStringView("foo") <= NullTermStringView("fooo"));
44   EXPECT_FALSE(NullTermStringView("fooo") <= NullTermStringView("foo"));
45   EXPECT_TRUE(NullTermStringView("bar") <= NullTermStringView("foo"));
46 
47   // Test the > operator.
48   EXPECT_FALSE(NullTermStringView() > NullTermStringView());
49   EXPECT_FALSE(NullTermStringView() > NullTermStringView(""));
50   EXPECT_FALSE(NullTermStringView() > NullTermStringView("foo"));
51   EXPECT_FALSE(NullTermStringView("") > NullTermStringView("foo"));
52   EXPECT_FALSE(NullTermStringView("foo") > NullTermStringView("foo"));
53   EXPECT_FALSE(NullTermStringView("foo") > NullTermStringView("fooo"));
54   EXPECT_TRUE(NullTermStringView("fooo") > NullTermStringView("foo"));
55   EXPECT_FALSE(NullTermStringView("bar") > NullTermStringView("foo"));
56 
57   // Test the >= operator.
58   EXPECT_TRUE(NullTermStringView() >= NullTermStringView());
59   EXPECT_TRUE(NullTermStringView() >= NullTermStringView(""));
60   EXPECT_FALSE(NullTermStringView() >= NullTermStringView("foo"));
61   EXPECT_FALSE(NullTermStringView("") >= NullTermStringView("foo"));
62   EXPECT_TRUE(NullTermStringView("foo") >= NullTermStringView("foo"));
63   EXPECT_FALSE(NullTermStringView("foo") >= NullTermStringView("fooo"));
64   EXPECT_TRUE(NullTermStringView("fooo") >= NullTermStringView("foo"));
65   EXPECT_FALSE(NullTermStringView("bar") >= NullTermStringView("foo"));
66 }
67 
68 }  // namespace
69 }  // namespace trace_processor
70 }  // namespace perfetto
71