30 #include <gtest/gtest.h> 36 TEST(PluginlibUniquePtrTest, unknownPlugin) {
38 ASSERT_THROW(test_loader.createUniqueInstance(
"pluginlib/foobar"),
43 TEST(PluginlibUniquePtrTest, misspelledPlugin) {
45 ASSERT_THROW(bad_test_loader.createUniqueInstance(
49 TEST(PluginlibTest, brokenPlugin) {
54 TEST(PluginlibUniquePtrTest, workingPlugin) {
58 pluginlib::UniquePtr<test_base::Fubar> foo = test_loader.createUniqueInstance(
"pluginlib/foo");
59 foo->initialize(10.0);
60 EXPECT_EQ(100.0, foo->result());
62 FAIL() <<
"Throwing exception: " << ex.what();
65 FAIL() <<
"Uncaught exception";
69 TEST(PluginlibUniquePtrTest, createUniqueInstanceAndUnloadLibrary) {
70 ROS_INFO(
"Making the ClassLoader...");
75 pluginlib::UniquePtr<test_base::Fubar> inst = pl.createUniqueInstance(
"pluginlib/foo");
78 ROS_INFO(
"Checking if plugin is loaded with isClassLoaded...");
82 FAIL() <<
"Library containing class should be loaded but isn't.";
85 ROS_INFO(
"Trying to unload class with unloadLibraryForClass...");
89 FAIL() <<
"Could not unload library when I should be able to.";
95 int main(
int argc,
char ** argv)
97 testing::InitGoogleTest(&argc, argv);
98 return RUN_ALL_TESTS();
TEST(PluginlibUniquePtrTest, unknownPlugin)
virtual int unloadLibraryForClass(const std::string &lookup_name)
Decrement the counter for the library containing a class with a given name.
A base class for all pluginlib exceptions that inherits from std::runtime_exception.
bool isClassLoaded(const std::string &lookup_name)
Check if the library for a given class is currently loaded.
int main(int argc, char **argv)
A class to help manage and load classes.
Thrown when pluginlib is unable to load the library associated with a given plugin.