1 // Copyright 2011-2012 Renato Tegon Forti 2 // Copyright 2014 Renato Tegon Forti, Antony Polukhin. 3 // Copyright 2015-2020 Antony Polukhin. 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt 7 // or copy at http://www.boost.org/LICENSE_1_0.txt) 8 9 // For more information, see http://www.boost.org 10 11 #include "../example/b2_workarounds.hpp" 12 #include <boost/dll.hpp> 13 #include <boost/core/lightweight_test.hpp> 14 15 // Unit Tests 16 exef()17extern "C" void BOOST_SYMBOL_EXPORT exef() { 18 } 19 main(int argc,char * argv[])20int main(int argc, char* argv[]) 21 { 22 using namespace boost::dll; 23 24 boost::dll::fs::path shared_library_path = b2_workarounds::first_lib_from_argv(argc, argv); 25 BOOST_TEST(shared_library_path.string().find("test_library") != std::string::npos); 26 BOOST_TEST(b2_workarounds::is_shared_library(shared_library_path)); 27 std::cout << "Library: " << shared_library_path; 28 29 { 30 shared_library sl(shared_library_path); 31 BOOST_TEST(sl.has("say_hello")); 32 BOOST_TEST(sl.has("lib_version")); 33 BOOST_TEST(sl.has("integer_g")); 34 BOOST_TEST(sl.has(std::string("integer_g"))); 35 BOOST_TEST(!sl.has("i_do_not_exist")); 36 BOOST_TEST(!sl.has(std::string("i_do_not_exist"))); 37 } 38 39 { 40 shared_library sl(program_location()); 41 BOOST_TEST(sl.has("exef")); 42 BOOST_TEST(!sl.has("i_do_not_exist")); 43 } 44 45 46 exef(); // Make sure that this function still callable in traditional way 47 return boost::report_errors(); 48 } 49 50