GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tests/gatecore_cpp_test/test_libraries.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 13 14 92.9%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 #include "gate/tests.hpp"
2 #include "gate/libraries.hpp"
3
4 using namespace gate;
5
6 static StaticString const invlid_lib = "non-sense-lib-name";
7
8 #if defined(GATE_SYS_WIN)
9 # define SYSLIB_NAME "kernel32"
10 # define SYSLIB_FUNC "OpenProcess"
11
12 #elif defined(GATE_SYS_DARWIN)
13 # define SYSLIB_NAME "libz.dylib"
14 # define SYSLIB_FUNC "deflate"
15
16 #elif defined(GATE_SYS_POSIX)
17 # define SYSLIB_NAME "libz.so"
18 # define SYSLIB_FUNC "deflate"
19
20 #endif
21
22
23 3 GATEXX_TEST_UNIT(Libraries)
24 {
25
26 2 GATEXX_TEST_CHECK_THROW(Library(invlid_lib, 0));
27
28 1 if (!Library::isDynamicLoadingSupported())
29 {
30 /* is dyn loading is not support, further tests are meaningless */
31 return;
32 }
33
34 #if defined(SYSLIB_NAME)
35 1 static StaticString const syslib_name = SYSLIB_NAME;
36 2 Library syslib(syslib_name);
37
38 1 static StaticString const unknown_data_name = "gate_test_some_thing_unknown";
39 1 static StaticString const known_func_name = SYSLIB_FUNC;
40
41 1 GATEXX_TEST_CHECK(!syslib.hasData(unknown_data_name));
42 2 GATEXX_TEST_CHECK_THROW(syslib.getData(unknown_data_name));
43
44 1 Library::function_t myfunc = NULL;
45 1 GATEXX_TEST_CHECK(syslib.hasFunction(known_func_name, &myfunc));
46
47 1 myfunc = syslib.getFunction(known_func_name);
48 1 GATEXX_TEST_CHECK_NOT_EQUAL(myfunc, NULL);
49 #endif
50 }
51
52