[ros-pluginlib] 01/03: New upstream version 1.10.4

Jochen Sprickerhof jspricke at moszumanska.debian.org
Fri Sep 23 08:17:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

jspricke pushed a commit to branch master
in repository ros-pluginlib.

commit 65c09a001169c0d3ee252e63341c16a5ddc1e0ca
Author: Jochen Sprickerhof <git at jochen.sprickerhof.de>
Date:   Fri Sep 23 10:03:46 2016 +0200

    New upstream version 1.10.4
---
 CHANGELOG.rst                        |  16 +++++-
 CMakeLists.txt                       |  12 +++++
 include/pluginlib/class_loader.h     |  30 +++++++++--
 include/pluginlib/class_loader_imp.h | 100 ++++++++++++++++++++++++-----------
 package.xml                          |   3 +-
 test/test_plugins_broken.xml         |   5 ++
 test/unique_ptr_test.cpp             |  81 ++++++++++++++++++++++++++++
 test/utest.cpp                       |  97 ++++++++-------------------------
 8 files changed, 233 insertions(+), 111 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index fd2a98c..eac6222 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -2,6 +2,20 @@
 Changelog for package pluginlib
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+1.10.4 (2016-09-20)
+-------------------
+* Merge pull request `#42 <https://github.com/ros/pluginlib/issues/42>`_ from delftrobotics-forks/unique-ptr
+  Add std::unique_ptr API
+* Add unit test for unique_ptr API.
+* Simplify unit tests with ASSERT_THROW.
+* Add ClassLoader::createUniqueInstance.
+* Wrap long comment on createInstance and friend.
+* Throw exception if plugin.xml is broken (`#41 <https://github.com/ros/pluginlib/issues/41>`_)
+  * added test case for broken xml files with missing attributes of class tag
+  * added checks if all needed attributes of the class tag are existing
+  * removed comment and empty line
+* Contributors: Maarten de Vries, Mikael Arguedas, cwecht
+
 1.10.3 (2016-06-22)
 -------------------
 * Merge pull request `#40 <https://github.com/ros/pluginlib/issues/40>`_ from ros/fix_warnings
@@ -104,7 +118,7 @@ Changelog for package pluginlib
 
 1.9.13 (2012-12-11)
 -------------------
-* Made robust to plugin package having different name from the folder it came from. `#6 <https://github.com/ros/pluginlib/issues/6`_
+* Made robust to plugin package having different name from the folder it came from. ```#6 <https://github.com/ros/pluginlib/issues/6`_``
 * Contributors: Mirza Shah
 
 1.9.12 (2012-12-06)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed1ecbe..de973b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,4 +40,16 @@ if(CATKIN_ENABLE_TESTING)
     target_link_libraries(${PROJECT_NAME}_utest ${TinyXML_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
     add_dependencies(${PROJECT_NAME}_utest test_plugins)
   endif()
+
+  include(CheckCXXCompilerFlag)
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  if(COMPILER_SUPPORTS_CXX11)
+    catkin_add_gtest(${PROJECT_NAME}_unique_ptr_test test/unique_ptr_test.cpp)
+    if(TARGET ${PROJECT_NAME}_unique_ptr_test)
+      target_link_libraries(${PROJECT_NAME}_unique_ptr_test ${TinyXML_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
+      set_target_properties(${PROJECT_NAME}_unique_ptr_test PROPERTIES COMPILE_FLAGS -std=c++11 LINK_FLAGS -std=c++11)
+      add_dependencies(${PROJECT_NAME}_unique_ptr_test test_plugins)
+    endif()
+  endif()
+
 endif()
diff --git a/include/pluginlib/class_loader.h b/include/pluginlib/class_loader.h
index b6d664b..0752290 100644
--- a/include/pluginlib/class_loader.h
+++ b/include/pluginlib/class_loader.h
@@ -45,6 +45,11 @@
 
 namespace pluginlib
 {
+
+#if __cplusplus >= 201103L
+  template<typename T>
+  using UniquePtr = class_loader::ClassLoader::UniquePtr<T>;
+#endif
   /**
    * @class ClassLoader
    * @brief A class to help manage and load classes
@@ -83,7 +88,8 @@ namespace pluginlib
         __attribute__((deprecated)) T* createClassInstance(const std::string& lookup_name, bool auto_load = true);
 
         /**
-         * @brief  Creates an instance of a desired class (which implicitly calls loadLibraryForClass() to increment the library counter). Deleting the instance and calling unloadLibraryForClass() is automatically handled by the shared pointer.
+         * @brief  Creates an instance of a desired class (which implicitly calls loadLibraryForClass() to increment the library counter).
+         * Deleting the instance and calling unloadLibraryForClass() is automatically handled by the shared pointer.
          * @param  lookup_name The name of the class to load
          * @exception pluginlib::LibraryLoadException Thrown when the library associated with the class cannot be loaded
          * @exception pluginlib::CreateClassException Thrown when the class cannot be instantiated
@@ -91,9 +97,25 @@ namespace pluginlib
          */
         boost::shared_ptr<T> createInstance(const std::string& lookup_name);
 
+#if __cplusplus >= 201103L
+        /**
+         * @brief  Creates an instance of a desired class (which implicitly calls loadLibraryForClass() to increment the library counter).
+         * Deleting the instance and calling unloadLibraryForClass() is automatically handled by the unique pointer.
+         *
+         * If you release the wrapped pointer you must manually call the original deleter when you want to destroy the released pointer.
+         *
+         * @param  lookup_name The name of the class to load
+         * @exception pluginlib::LibraryLoadException Thrown when the library associated with the class cannot be loaded
+         * @exception pluginlib::CreateClassException Thrown when the class cannot be instantiated
+         * @return An instance of the class
+         */
+        UniquePtr<T> createUniqueInstance(const std::string& lookup_name);
+#endif
+
         /**
          * @brief  Creates an instance of a desired class (which implicitly calls loadLibraryForClass() to increment the library counter).
-         * @attention The ownership is transfered to the caller, which is responsible for deleting the instance and calling unloadLibraryForClass() (in order to decrement the associated library counter and unloading it if it is no more used).
+         * @attention The ownership is transfered to the caller, which is responsible for deleting the instance and calling unloadLibraryForClass()
+         * (in order to decrement the associated library counter and unloading it if it is no more used).
          * @param  lookup_name The name of the class to load
          * @exception pluginlib::LibraryLoadException Thrown when the library associated with the class cannot be loaded
          * @exception pluginlib::CreateClassException Thrown when the class cannot be instantiated
@@ -173,7 +195,7 @@ namespace pluginlib
          * @return True if the class is loaded, false otherwise
          */
         bool isClassLoaded(const std::string& lookup_name);
-        
+
         /**
          * @brief  Checks if the class associated with a plugin name is available to be loaded
          * @param lookup_name The name of the plugin
@@ -249,7 +271,7 @@ namespace pluginlib
          * Gets the standard path separator for the native OS (e.g. "/" on *nix, "\" on windows)
          */
         std::string getPathSeparator();
-        
+
         /**
          * Gets the path where rosbuild build system thinks plugins are installed
          */
diff --git a/include/pluginlib/class_loader_imp.h b/include/pluginlib/class_loader_imp.h
index b2fd8f9..894fdbc 100644
--- a/include/pluginlib/class_loader_imp.h
+++ b/include/pluginlib/class_loader_imp.h
@@ -47,7 +47,7 @@
 #include <sstream>
 #include <stdexcept>
 
-namespace pluginlib 
+namespace pluginlib
 {
   template <class T>
   ClassLoader<T>::ClassLoader(std::string package, std::string base_class, std::string attrib_name, std::vector<std::string> plugin_xml_paths) :
@@ -103,8 +103,8 @@ namespace pluginlib
   {
     //Note: This method is deprecated
     ROS_DEBUG_NAMED("pluginlib.ClassLoader","In deprecated call createClassInstance(), lookup_name = %s, auto_load = %i.", (lookup_name.c_str()), auto_load);
-        
-    if(auto_load && !isClassLoaded(lookup_name))
+
+    if (auto_load && !isClassLoaded(lookup_name))
     {
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Autoloading class library before attempting to create instance.");
       loadLibraryForClass(lookup_name);
@@ -115,50 +115,79 @@ namespace pluginlib
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Attempting to create instance through low-level MultiLibraryClassLoader...");
       T* obj = lowlevel_class_loader_.createUnmanagedInstance<T>(getClassType(lookup_name));
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Instance created with object pointer = %p", obj);
-      
+
       return obj;
     }
-    catch(const class_loader::CreateClassException& ex)
+    catch (const class_loader::CreateClassException& ex)
     {
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","CreateClassException about to be raised for class %s", lookup_name.c_str());
-      throw(pluginlib::CreateClassException(ex.what()));
+      throw pluginlib::CreateClassException(ex.what());
     }
   }
-  
+
   template <class T>
   boost::shared_ptr<T> ClassLoader<T>::createInstance(const std::string& lookup_name)
   /***************************************************************************/
   {
     ROS_DEBUG_NAMED("pluginlib.ClassLoader","Attempting to create managed instance for class %s.", lookup_name.c_str());
-    
-    if(!isClassLoaded(lookup_name))
+
+    if (!isClassLoaded(lookup_name))
       loadLibraryForClass(lookup_name);
-    
+
     try
     {
       std::string class_type = getClassType(lookup_name);
-      ROS_DEBUG_NAMED("pluginlib.ClassLoader","%s maps to real class type %s", lookup_name.c_str(), class_type.c_str());    
-    
+      ROS_DEBUG_NAMED("pluginlib.ClassLoader","%s maps to real class type %s", lookup_name.c_str(), class_type.c_str());
+
       boost::shared_ptr<T> obj = lowlevel_class_loader_.createInstance<T>(class_type);
-      
-      ROS_DEBUG_NAMED("pluginlib.ClassLoader","boost::shared_ptr to object of real type %s created.", class_type.c_str());    
-      
+
+      ROS_DEBUG_NAMED("pluginlib.ClassLoader","boost::shared_ptr to object of real type %s created.", class_type.c_str());
+
       return obj;
     }
-    catch(const class_loader::CreateClassException& ex)
+    catch (const class_loader::CreateClassException& ex)
     {
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Exception raised by low-level multi-library class loader when attempting to create instance of class %s.", lookup_name.c_str());
-      throw(pluginlib::CreateClassException(ex.what()));
+      throw pluginlib::CreateClassException(ex.what());
     }
   }
 
+#if __cplusplus >= 201103L
+  template <class T>
+  UniquePtr<T> ClassLoader<T>::createUniqueInstance(const std::string& lookup_name)
+  {
+    ROS_DEBUG_NAMED("pluginlib.ClassLoader","Attempting to create managed (unique) instance for class %s.", lookup_name.c_str());
+
+    if (!isClassLoaded(lookup_name))
+      loadLibraryForClass(lookup_name);
+
+    try
+    {
+      std::string class_type = getClassType(lookup_name);
+      ROS_DEBUG_NAMED("pluginlib.ClassLoader","%s maps to real class type %s", lookup_name.c_str(), class_type.c_str());
+
+      UniquePtr<T> obj = lowlevel_class_loader_.createUniqueInstance<T>(class_type);
+
+      ROS_DEBUG_NAMED("pluginlib.ClassLoader","std::unique_ptr to object of real type %s created.", class_type.c_str());
+
+      return obj;
+    }
+    catch (const class_loader::CreateClassException& ex)
+    {
+      ROS_DEBUG_NAMED("pluginlib.ClassLoader","Exception raised by low-level multi-library class loader when attempting to create instance of class %s.", lookup_name.c_str());
+      throw pluginlib::CreateClassException(ex.what());
+    }
+
+  }
+#endif
+
   template <class T>
   T* ClassLoader<T>::createUnmanagedInstance(const std::string& lookup_name)
   /***************************************************************************/
   {
     ROS_DEBUG_NAMED("pluginlib.ClassLoader","Attempting to create UNMANAGED instance for class %s.", lookup_name.c_str());
 
-    if(!isClassLoaded(lookup_name))
+    if (!isClassLoaded(lookup_name))
       loadLibraryForClass(lookup_name);
 
     T* instance = 0;
@@ -170,10 +199,10 @@ namespace pluginlib
       instance = lowlevel_class_loader_.createUnmanagedInstance<T>(class_type);
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Instance of type %s created.", class_type.c_str());
     }
-    catch(const class_loader::CreateClassException& ex) //mas - change exception type here (DONE)
+    catch (const class_loader::CreateClassException& ex) //mas - change exception type here (DONE)
     {
       ROS_DEBUG_NAMED("pluginlib.ClassLoader","Exception raised by low-level multi-library class loader when attempting to create UNMANAGED instance of class %s.", lookup_name.c_str());
-      throw(pluginlib::CreateClassException(ex.what()));   
+      throw pluginlib::CreateClassException(ex.what());
     }
     return instance;
   }
@@ -209,7 +238,7 @@ namespace pluginlib
 
   template <class T>
   std::string ClassLoader<T>::extractPackageNameFromPackageXML(const std::string& package_xml_path)
- /***************************************************************************/  
+ /***************************************************************************/
   {
       TiXmlDocument document;
       document.LoadFile(package_xml_path);
@@ -380,7 +409,7 @@ namespace pluginlib
     {
       declared_types = declared_types + std::string(" ") + types[i];
     }
-    return "According to the loaded plugin descriptions the class " + lookup_name 
+    return "According to the loaded plugin descriptions the class " + lookup_name
       + " with base class type " + base_class_ + " does not exist. Declared types are " + declared_types;
   }
 
@@ -396,9 +425,9 @@ namespace pluginlib
 
   template <class T>
   std::string ClassLoader<T>::getPackageFromPluginXMLFilePath(const std::string & plugin_xml_file_path)
- /***************************************************************************/  
+ /***************************************************************************/
   {
-    //Note: This method takes an input a path to a plugin xml file and must determine which 
+    //Note: This method takes an input a path to a plugin xml file and must determine which
     //package the XML file came from. This is not necessariliy the same thing as the member
     //variable "package_". The plugin xml file can be located anywhere in the source tree for a
     //package
@@ -437,7 +466,7 @@ namespace pluginlib
         {
           package_name = package;
           break;
-        }       
+        }
       }
 
       //Recursive case - hop one folder up
@@ -448,7 +477,7 @@ namespace pluginlib
         return "";
     }
 
-    return package_name;    
+    return package_name;
   }
 
   template <class T>
@@ -599,14 +628,25 @@ namespace pluginlib
       TiXmlElement* class_element = library->FirstChildElement("class");
       while (class_element)
       {
-        std::string base_class_type = class_element->Attribute("base_class_type");
-        std::string derived_class = class_element->Attribute("type");
+        std::string derived_class;
+        if (class_element->Attribute("type") != NULL) {
+          derived_class = std::string(class_element->Attribute("type"));
+        } else {
+          throw pluginlib::ClassLoaderException("Class could not be loaded. Attribute 'type' in class tag is missing.");
+        }
+
+        std::string base_class_type;
+        if (class_element->Attribute("base_class_type") != NULL) {
+          base_class_type = std::string(class_element->Attribute("base_class_type"));
+        } else {
+          throw pluginlib::ClassLoaderException("Class could not be loaded. Attribute 'base_class_type' in class tag is missing.");
+        }
 
         std::string lookup_name;
         if(class_element->Attribute("name") != NULL)
         {
           lookup_name = class_element->Attribute("name");
-          ROS_DEBUG_NAMED("pluginlib.ClassLoader","XML file specifies lookup name (i.e. magic name) = %s.", lookup_name.c_str());          
+          ROS_DEBUG_NAMED("pluginlib.ClassLoader","XML file specifies lookup name (i.e. magic name) = %s.", lookup_name.c_str());
         }
         else
         {
@@ -705,7 +745,7 @@ namespace pluginlib
 
 }
 
-  
+
 
 
 #endif
diff --git a/package.xml b/package.xml
index 6a356cc..d1b1a07 100644
--- a/package.xml
+++ b/package.xml
@@ -1,6 +1,6 @@
 <package>
   <name>pluginlib</name>
-  <version>1.10.3</version>
+  <version>1.10.4</version>
   <description>
     The pluginlib package provides tools for writing and dynamically loading plugins using the ROS build infrastructure.
     To work, these tools require plugin providers to register their plugins in the package.xml of their package.
@@ -33,5 +33,6 @@
 
   <export>
     <pluginlib plugin="${prefix}/test/test_plugins.xml"/>
+    <pluginlib plugin_test="${prefix}/test/test_plugins_broken.xml"/>
   </export>
 </package>
diff --git a/test/test_plugins_broken.xml b/test/test_plugins_broken.xml
new file mode 100644
index 0000000..f28243c
--- /dev/null
+++ b/test/test_plugins_broken.xml
@@ -0,0 +1,5 @@
+<library path="lib/libtest_plugins">
+  <class name="pluginlib/foo" name="test_plugins::Foo" base_class_type="test_base::Fubar">
+    <description>This is a foo plugin.</description>
+  </class>
+</library>
diff --git a/test/unique_ptr_test.cpp b/test/unique_ptr_test.cpp
new file mode 100644
index 0000000..7fdd787
--- /dev/null
+++ b/test/unique_ptr_test.cpp
@@ -0,0 +1,81 @@
+#include <pluginlib/class_loader.h>
+#include "test_base.h"
+#include <gtest/gtest.h>
+
+TEST(PluginlibUniquePtrTest, unknownPlugin)
+{
+  pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
+  ASSERT_THROW(test_loader.createUniqueInstance("pluginlib/foobar"), pluginlib::LibraryLoadException);
+}
+
+
+TEST(PluginlibUniquePtrTest, misspelledPlugin)
+{
+  pluginlib::ClassLoader<test_base::Fubar> bad_test_loader("pluginlib", "test_base::Fuba");
+  ASSERT_THROW(bad_test_loader.createUniqueInstance("pluginlib/foo"), pluginlib::LibraryLoadException);
+}
+
+TEST(PluginlibTest, brokenPlugin)
+{
+  pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
+  ASSERT_THROW(test_loader.createUniqueInstance("pluginlib/none"), pluginlib::PluginlibException);
+}
+
+TEST(PluginlibUniquePtrTest, workingPlugin)
+{
+  pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
+
+  try
+  {
+    pluginlib::UniquePtr<test_base::Fubar> foo = test_loader.createUniqueInstance("pluginlib/foo");
+    foo->initialize(10.0);
+    EXPECT_EQ(foo->result(),100.0);
+  }
+  catch(pluginlib::PluginlibException& ex)
+  {
+    FAIL() << "Throwing exception: " << ex.what();
+    return;
+  }
+  catch(...)
+  {
+    FAIL() << "Uncaught exception";
+  }
+}
+
+TEST(PluginlibUniquePtrTest, createUniqueInstanceAndUnloadLibrary)
+{
+  ROS_INFO( "Making the ClassLoader..." );
+  pluginlib::ClassLoader<test_base::Fubar> pl("pluginlib", "test_base::Fubar");
+
+  ROS_INFO( "Instantiating plugin..." );
+  {
+   pluginlib::UniquePtr<test_base::Fubar> inst = pl.createUniqueInstance("pluginlib/foo");
+  }
+
+  ROS_INFO( "Checking if plugin is loaded with isClassLoaded..." );
+  if( pl.isClassLoaded( "pluginlib/foo" ) )
+    ROS_INFO( "Class is loaded" );
+  else
+  {
+    FAIL() <<  "Library containing class should be loaded but isn't.";
+  }
+
+  ROS_INFO( "Trying to unload class with unloadLibraryForClass..." );
+  try
+  {
+    pl.unloadLibraryForClass("pluginlib/foo");
+  }
+  catch(pluginlib::PluginlibException& e)
+  {
+    FAIL() << "Could not unload library when I should be able to.";
+  }
+  ROS_INFO( "Done." );
+}
+
+// Run all the tests that were declared with TEST()
+int main(int argc, char **argv){
+  testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+
diff --git a/test/utest.cpp b/test/utest.cpp
index 4655d1d..a48a448 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -5,103 +5,35 @@
 TEST(PluginlibTest, unknownPlugin)
 {
   pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
-
-  try
-  {
-    boost::shared_ptr<test_base::Fubar> foo = test_loader.createInstance("pluginlib/foobar");
-    foo->initialize(10.0);
-  }
-  catch(pluginlib::LibraryLoadException& ex)
-  {
-    SUCCEED();
-    return;
-  }
-  catch(...)
-  {
-    FAIL() << "Uncaught exception";
-  }
-  ADD_FAILURE() << "Didn't throw exception as expected";
- 
+  ASSERT_THROW(test_loader.createInstance("pluginlib/foobar"), pluginlib::LibraryLoadException);
 }
 
-
 TEST(PluginlibTest, misspelledPlugin)
 {
   pluginlib::ClassLoader<test_base::Fubar> bad_test_loader("pluginlib", "test_base::Fuba");
-
-  try
-  {
-    boost::shared_ptr<test_base::Fubar> foo = bad_test_loader.createInstance("pluginlib/foo");
-    foo->initialize(10.0);
-  }
-  catch(pluginlib::LibraryLoadException& ex)
-  {
-    SUCCEED();
-    return;
-  }
-  catch(...)
-  {
-    FAIL() << "Uncaught exception";
-  }
-  ADD_FAILURE() << "Didn't throw exception as expected";
- 
+  ASSERT_THROW(bad_test_loader.createInstance("pluginlib/foo"), pluginlib::LibraryLoadException);
 }
 
 TEST(PluginlibTest, invalidPackage)
-{  
-  try
-  {
-    pluginlib::ClassLoader<test_base::Fubar> bad_test_loader("pluginlib_bad", "test_base::Fubar");
-  }
-  catch(pluginlib::ClassLoaderException& ex)
-  {
-    SUCCEED();
-    return;
-  }
-  catch(...)
-  {
-    FAIL() << "Uncaught exception";
-  }
-  ADD_FAILURE() << "Didn't throw exception as expected";
- 
+{
+  ASSERT_THROW(pluginlib::ClassLoader<test_base::Fubar>("pluginlib_bad", "test_base::Fubar"), pluginlib::ClassLoaderException);
 }
 
 TEST(PluginlibTest, brokenPlugin)
 {
   pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
-
-  try
-  {
-    boost::shared_ptr<test_base::Fubar> none = test_loader.createInstance("pluginlib/none");
-    none->initialize(10.0);
-  }
-  catch(pluginlib::PluginlibException& ex)
-  {
-    SUCCEED();
-    return;
-  }
-  catch(class_loader::ClassLoaderException& ex)
-  {
-    FAIL() << "class_loader exception instead of pluginlib, argh. " << ex.what() << "\n";
-  }
-  catch(...)
-  {
-    FAIL() << "Uncaught exception";
-  }
-  ADD_FAILURE() << "Didn't throw exception as expected";
- 
+  ASSERT_THROW(test_loader.createInstance("pluginlib/none"), pluginlib::PluginlibException);
 }
 
 TEST(PluginlibTest, workingPlugin)
 {
   pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar");
-  
+
   try
   {
     boost::shared_ptr<test_base::Fubar> foo = test_loader.createInstance("pluginlib/foo");
     foo->initialize(10.0);
     EXPECT_EQ(foo->result(),100.0);
-
   }
   catch(pluginlib::PluginlibException& ex)
   {
@@ -161,7 +93,7 @@ TEST(PluginlibTest, createManagedInstanceAndUnloadLibrary)
   {
     FAIL() <<  "Library containing class should be loaded but isn't.";
   }
-  
+
   ROS_INFO( "Trying to unload class with unloadLibraryForClass..." );
   try
   {
@@ -174,6 +106,21 @@ TEST(PluginlibTest, createManagedInstanceAndUnloadLibrary)
   ROS_INFO( "Done." );
 }
 
+TEST(PluginlibTest, brokenXML)
+{
+  try
+  {
+    pluginlib::ClassLoader<test_base::Fubar> test_loader("pluginlib", "test_base::Fubar", "plugin_test");
+  }
+  catch(pluginlib::ClassLoaderException& ex)
+  {
+    SUCCEED();
+    return;
+  }
+
+  ADD_FAILURE() << "Didn't throw exception as expected";
+}
+
 // Run all the tests that were declared with TEST()
 int main(int argc, char **argv){
   testing::InitGoogleTest(&argc, argv);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ros/ros-pluginlib.git



More information about the debian-science-commits mailing list