1 //===-- NameMatchesTest.cpp -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Utility/NameMatches.h" 11 #include "gtest/gtest.h" 12 13 using namespace lldb_private; 14 15 TEST(NameMatchesTest, Ignore) { 16 EXPECT_TRUE(NameMatches("foo", NameMatch::Ignore, "bar")); 17 } 18 19 TEST(NameMatchesTest, Equals) { 20 EXPECT_TRUE(NameMatches("foo", NameMatch::Equals, "foo")); 21 EXPECT_FALSE(NameMatches("foo", NameMatch::Equals, "bar")); 22 } 23 24 TEST(NameMatchesTest, Contains) { 25 EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foo")); 26 EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "oob")); 27 EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "bar")); 28 EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foobar")); 29 EXPECT_TRUE(NameMatches("", NameMatch::Contains, "")); 30 EXPECT_FALSE(NameMatches("", NameMatch::Contains, "foo")); 31 EXPECT_FALSE(NameMatches("foobar", NameMatch::Contains, "baz")); 32 } 33 34 TEST(NameMatchesTest, StartsWith) { 35 EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, "f")); 36 EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, "")); 37 EXPECT_TRUE(NameMatches("", NameMatch::StartsWith, "")); 38 EXPECT_FALSE(NameMatches("foo", NameMatch::StartsWith, "b")); 39 EXPECT_FALSE(NameMatches("", NameMatch::StartsWith, "b")); 40 } 41 42 TEST(NameMatchesTest, EndsWith) { 43 EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, "o")); 44 EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, "")); 45 EXPECT_TRUE(NameMatches("", NameMatch::EndsWith, "")); 46 EXPECT_FALSE(NameMatches("foo", NameMatch::EndsWith, "b")); 47 EXPECT_FALSE(NameMatches("", NameMatch::EndsWith, "b")); 48 } 49 50 TEST(NameMatchesTest, RegularExpression) { 51 EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "foo")); 52 EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "f[oa]o")); 53 EXPECT_TRUE(NameMatches("foo", NameMatch::RegularExpression, "")); 54 EXPECT_TRUE(NameMatches("", NameMatch::RegularExpression, "")); 55 EXPECT_FALSE(NameMatches("foo", NameMatch::RegularExpression, "b")); 56 EXPECT_FALSE(NameMatches("", NameMatch::RegularExpression, "b")); 57 EXPECT_FALSE(NameMatches("^a", NameMatch::RegularExpression, "^a")); 58 } 59