Lolly 1.4.28
Loading...
Searching...
No Matches
shared_lib_test.cpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : shared_lib_test.cpp
4 * DESCRIPTION: tests on dynamic library loading
5 * COPYRIGHT : (C) 2024 jingkaimori
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#include "a_lolly_test.hpp"
14#include "sys_utils.hpp"
15
16#ifndef OS_WASM
18using lolly::system::shared_lib;
19#endif
20
21TEST_CASE ("load_shared_library") {
22#ifndef OS_WASM
24 if (os_win ()) {
25 lib_path= url_pwd () * "example_dynamic_library.dll";
26 }
27 else if (os_macos ()) {
28 lib_path= url_pwd () * "libexample_dynamic_library.dylib";
29 }
30 else {
31 lib_path= url_pwd () * "libexample_dynamic_library.so";
32 }
33 shared_lib lib= load_shared_library ("example_dynamic_library", lib_path);
34 double (*func) (int)= lib->get_function<double, int> ("square_div_2");
35 double res = func (5);
36 CHECK_EQ (res, 12.5);
37#endif
38}
The list class represents a linked list.
Definition list.hpp:48
Definition url.hpp:37
shared_lib load_shared_library(string name, url path)
TEST_CASE("test for operator+= and advance()")
bool os_macos()
bool os_win()
Definition sys_utils.cpp:94
url url_pwd()
Definition url.cpp:326