Skip to content

Commit 2633292

Browse files
committed
Add unit test for MatchPluginName
1 parent 99ca1f4 commit 2633292

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lldb/unittests/Core/PluginManagerTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,25 @@ TEST_F(PluginManagerTest, UnRegisterSystemRuntimePluginChangesOrder) {
379379
ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
380380
CreateSystemRuntimePluginB);
381381
}
382+
383+
TEST_F(PluginManagerTest, MatchPluginName) {
384+
PluginNamespace Foo{"foo", nullptr, nullptr};
385+
RegisteredPluginInfo Bar{"bar", "bar plugin ", true};
386+
RegisteredPluginInfo Baz{"baz", "baz plugin ", true};
387+
388+
// Empty pattern matches everything.
389+
ASSERT_TRUE(PluginManager::MatchPluginName("", Foo, Bar));
390+
391+
// Plugin namespace matches all plugins in that namespace.
392+
ASSERT_TRUE(PluginManager::MatchPluginName("foo", Foo, Bar));
393+
ASSERT_TRUE(PluginManager::MatchPluginName("foo", Foo, Baz));
394+
395+
// Fully qualified plugin name matches only that plugin.
396+
ASSERT_TRUE(PluginManager::MatchPluginName("foo.bar", Foo, Bar));
397+
ASSERT_FALSE(PluginManager::MatchPluginName("foo.baz", Foo, Bar));
398+
399+
// Prefix match should not match.
400+
ASSERT_FALSE(PluginManager::MatchPluginName("f", Foo, Bar));
401+
ASSERT_FALSE(PluginManager::MatchPluginName("foo.", Foo, Bar));
402+
ASSERT_FALSE(PluginManager::MatchPluginName("foo.ba", Foo, Bar));
403+
}

0 commit comments

Comments
 (0)