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