Go to the documentation of this file.
34 #include <gtest/gtest.h>
51 TEST(ClassLoaderUniquePtrTest, basicLoad) {
57 FAIL() <<
"ClassLoaderException: " << e.what() <<
"\n";
61 TEST(ClassLoaderUniquePtrTest, correctLazyLoadUnload) {
78 FAIL() <<
"ClassLoaderException: " << e.what() <<
"\n";
80 FAIL() <<
"Unhandled exception";
84 TEST(ClassLoaderUniquePtrTest, nonExistentPlugin) {
90 FAIL() <<
"Null object being returned instead of exception thrown.";
98 FAIL() <<
"Unknown exception caught.\n";
101 FAIL() <<
"Did not throw exception as expected.\n";
106 std::this_thread::sleep_for(std::chrono::seconds(seconds));
112 for (
auto & class_ : classes) {
117 TEST(ClassLoaderUniquePtrTest, threadSafety) {
125 std::vector<std::thread> client_threads;
127 for (
size_t c = 0; c < 1000; c++) {
128 client_threads.emplace_back(std::bind(&
run, &loader1));
131 for (
auto & client_thread : client_threads) {
132 client_thread.join();
138 FAIL() <<
"Unexpected ClassLoaderException.";
140 FAIL() <<
"Unknown exception.";
144 TEST(ClassLoaderUniquePtrTest, loadRefCountingLazy) {
176 FAIL() <<
"Unexpected exception.\n";
178 FAIL() <<
"Unknown exception caught.\n";
181 FAIL() <<
"Did not throw exception as expected.\n";
190 for (
int i = 0; i < 2; ++i) {
196 FAIL() <<
"ClassLoaderException: " << e.what() <<
"\n";
202 TEST(MultiClassLoaderUniquePtrTest, lazyLoad) {
205 TEST(MultiClassLoaderUniquePtrTest, lazyLoadSecondTime) {
208 TEST(MultiClassLoaderUniquePtrTest, nonLazyLoad) {
211 TEST(MultiClassLoaderUniquePtrTest, noWarningOnLazyLoad) {
213 ClassLoader::UniquePtr<Base> cat =
nullptr, dog =
nullptr, rob =
nullptr;
227 FAIL() <<
"ClassLoaderException: " << e.what() <<
"\n";
234 int main(
int argc,
char ** argv)
236 testing::InitGoogleTest(&argc, argv);
237 return RUN_ALL_TESTS();
CLASS_LOADER_PUBLIC std::string systemLibraryFormat(const std::string &library_name)
Returns a platform specific version of a basic library name.
A ClassLoader that can bind more than one runtime library.
int main(int argc, char **argv)
const std::string LIBRARY_1
CLASS_LOADER_PUBLIC bool isLibraryLoadedByAnybody(const std::string &library_path)
Indicates if passed library has been loaded by ANY ClassLoader.
CLASS_LOADER_PUBLIC void loadLibrary()
Attempts to load a library on behalf of the ClassLoader. If the library is already opened,...
void loadLibrary(const std::string &library_path)
Loads a library into memory for this class loader.
CLASS_LOADER_PUBLIC int unloadLibrary()
Attempts to unload a library loaded within scope of the ClassLoader. If the library is not opened,...
This class allows loading and unloading of dynamically linked libraries which contain class definitio...
UniquePtr< Base > createUniqueInstance(const std::string &derived_class_name)
Generates an instance of loadable classes (i.e. class_loader).
TEST(ClassLoaderUniquePtrTest, basicLoad)
std::vector< std::string > getAvailableClasses()
Indicates which classes (i.e. class_loader) that can be loaded by this object.
ClassLoader::UniquePtr< Base > createUniqueInstance(const std::string &class_name)
Creates an instance of an object of given class name with ancestor class Base Same as createSharedIns...
virtual void saySomething()=0
void testMultiClassLoader(bool lazy)
An exception class thrown when class_loader is unable to create a plugin.
CLASS_LOADER_PUBLIC bool isLibraryLoaded()
Indicates if a library is loaded within the scope of this ClassLoader. Note that the library may alre...
const std::string LIBRARY_2
void run(ClassLoader *loader)
class_loader
Author(s): Mirza Shah, Steven! Ragnarök
autogenerated on Fri Jan 12 2024 04:01:32