17 #ifndef DynamicLib_cpp 18 #define DynamicLib_cpp 20 #include <cppunit/ui/text/TestRunner.h> 21 #include <cppunit/TextOutputter.h> 22 #include <cppunit/extensions/TestFactoryRegistry.h> 23 #include <cppunit/extensions/HelperMacros.h> 24 #include <cppunit/TestAssert.h> 26 #include <coil/DynamicLib.h> 34 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 36 const char *
LibName =
"DynamicLibTestDll.dll";
43 const char * LibName =
".libs/libDynamicLib.so";
46 const char * SymbolName =
"ForExternTest";
52 :
public CppUnit::TestFixture
110 CPPUNIT_ASSERT_EQUAL(0, result);
152 CPPUNIT_ASSERT_EQUAL(-1, result);
163 CPPUNIT_ASSERT_EQUAL(0, result);
180 CPPUNIT_ASSERT_EQUAL(0, result);
182 char * p = (
char *)dl1->
symbol(
"HogeHoge");
184 CPPUNIT_ASSERT(0 == p);
200 CPPUNIT_ASSERT_EQUAL(0, result);
202 typedef int (*exec)();
205 func = (exec)dl1->
symbol(SymbolName);
207 CPPUNIT_ASSERT(func);
211 CPPUNIT_ASSERT_EQUAL((
int)0xdeadbeef, ic);
228 CPPUNIT_ASSERT(!dl1->
error());
230 dl1->
symbol(
"HogeHogeHoge");
231 CPPUNIT_ASSERT(dl1->
error());
247 int main(
int argc,
char* argv[])
249 CppUnit::TextUi::TestRunner runner;
250 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
251 CppUnit::Outputter* outputter =
252 new CppUnit::TextOutputter(&runner.result(), std::cout);
253 runner.setOutputter(outputter);
258 #endif // DynamicLib_cpp int main(int argc, char **argv)
CPPUNIT_TEST_SUITE(DynamicLibTests)
void test_DynamicLib_error()
do error note エラー発生時にerror()が非0を返すこと
CPPUNIT_TEST(test_DynamicLib_1)
void * symbol(const char *symbol_name)
Return an address of the memory where a symbol was loaded.
void test_DynamicLib_3()
コンストラクタその3
void test_DynamicLib_1()
コンストラクタその1
CPPUNIT_TEST_SUITE_REGISTRATION(DynamicLib::DynamicLibTests)
virtual void setUp()
Test initialization.
void test_DynamicLib_symbol()
do symbol note 存在するシンボルを読み出す。
DynamicLibTests()
Constructor.
#define COIL_DEFAULT_DYNLIB_MODE
void test_DynamicLib_open_and_close()
Open and Close.
void test_DynamicLib_4()
コンストラクタその4
virtual void tearDown()
Test finalization.
~DynamicLibTests()
Destructor.
virtual int close(void)
Unload of the Dynamic link library.
void test_DynamicLib_symbol_failure()
do symbol note 存在しないシンボルを読み出す。
const char * error(void) const
Return the explanation message about the error.
void test_DynamicLib_open_failure()
Try to open nonExistence.
void test_DynamicLib_2()
コンストラクタその2
virtual int open(const char *dll_name, int open_mode=COIL_DEFAULT_DYNLIB_MODE, int close_handle_on_destruction=1)
Load of the Dynamic link library.