xref: /llvm-project/lldb/unittests/Utility/NameMatchesTest.cpp (revision 808142876c10b52e7ee57cdc6dcf0acc5c97c1b7)
1*80814287SRaphael Isemann //===-- NameMatchesTest.cpp -----------------------------------------------===//
2c4a33951SPavel Labath //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c4a33951SPavel Labath //
7c4a33951SPavel Labath //===----------------------------------------------------------------------===//
8c4a33951SPavel Labath 
9c4a33951SPavel Labath #include "lldb/Utility/NameMatches.h"
10c4a33951SPavel Labath #include "gtest/gtest.h"
11c4a33951SPavel Labath 
12c4a33951SPavel Labath using namespace lldb_private;
13c4a33951SPavel Labath 
TEST(NameMatchesTest,Ignore)14c4a33951SPavel Labath TEST(NameMatchesTest, Ignore) {
15c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::Ignore, "bar"));
16c4a33951SPavel Labath }
17c4a33951SPavel Labath 
TEST(NameMatchesTest,Equals)18c4a33951SPavel Labath TEST(NameMatchesTest, Equals) {
19c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::Equals, "foo"));
20c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("foo", NameMatch::Equals, "bar"));
21c4a33951SPavel Labath }
22c4a33951SPavel Labath 
TEST(NameMatchesTest,Contains)23c4a33951SPavel Labath TEST(NameMatchesTest, Contains) {
24c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foo"));
25c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "oob"));
26c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "bar"));
27c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foobar"));
28c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("", NameMatch::Contains, ""));
29c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("", NameMatch::Contains, "foo"));
30c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("foobar", NameMatch::Contains, "baz"));
31c4a33951SPavel Labath }
32c4a33951SPavel Labath 
TEST(NameMatchesTest,StartsWith)33c4a33951SPavel Labath TEST(NameMatchesTest, StartsWith) {
34c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, "f"));
35c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, ""));
36c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("", NameMatch::StartsWith, ""));
37c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("foo", NameMatch::StartsWith, "b"));
38c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("", NameMatch::StartsWith, "b"));
39c4a33951SPavel Labath }
40c4a33951SPavel Labath 
TEST(NameMatchesTest,EndsWith)41c4a33951SPavel Labath TEST(NameMatchesTest, EndsWith) {
42c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, "o"));
43c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, ""));
44c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("", NameMatch::EndsWith, ""));
45c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("foo", NameMatch::EndsWith, "b"));
46c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("", NameMatch::EndsWith, "b"));
47c4a33951SPavel Labath }
48c4a33951SPavel Labath 
TEST(NameMatchesTest,RegularExpression)49c4a33951SPavel Labath TEST(NameMatchesTest, RegularExpression) {
50c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "foo"));
51c4a33951SPavel Labath   EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "f[oa]o"));
523af3f1e8SJonas Devlieghere   EXPECT_FALSE(NameMatches("foo", NameMatch::RegularExpression, ""));
533af3f1e8SJonas Devlieghere   EXPECT_FALSE(NameMatches("", NameMatch::RegularExpression, ""));
54c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("foo", NameMatch::RegularExpression, "b"));
55c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("", NameMatch::RegularExpression, "b"));
56c4a33951SPavel Labath   EXPECT_FALSE(NameMatches("^a", NameMatch::RegularExpression, "^a"));
57c4a33951SPavel Labath }
58