forked from degauden/Elements
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModuleInfo_test.cpp
More file actions
128 lines (83 loc) · 4.29 KB
/
Copy pathModuleInfo_test.cpp
File metadata and controls
128 lines (83 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* @file ModuleInfo_test.cpp
*
* @date Jul 26, 2016
* @author Hubert Degaudenzi
*
* @copyright 2012-2020 Euclid Science Ground Segment
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "ElementsKernel/ModuleInfo.h"
#include <libgen.h> // for __xpg_basename, basename
#include <string> // for operator==, string
#include <boost/test/unit_test.hpp> // for BOOST_PP_IIF_1, BOOST_PP_IIF_0, BOOST_PP_BOOL_0, BOOST_PP_BOOL_1, BOOST_PP_EXPR_IIF_1, BOOST_PP_FOR_CHECK_BOOST_PP_NIL, operator<<, BOOST_PP_DEC_1, BOOST_PP_TUPLE_ELEM_O_3, BOOST_PP_VARIADIC_ELEM_3, BOOST_PP_BOOL_2, BOOST_PP_DEC_2, BOOST_PP_FOR_0, BOOST_PP_SEQ_ELEM_0, BOOST_PP_COMPL_0, BOOST_PP_NOT_EQUAL_1, BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_1, BOOST_AUTO_TEST_CASE, BOOST_PP_DEC_128, BOOST_PP_DEC_16, BOOST_PP_DEC_3, BOOST_PP_DEC_32, BOOST_PP_DEC_4, BOOST_PP_DEC_64, BOOST_PP_DEC_8, BOOST_PP_FOR_1, BOOST_PP_FOR_127, BOOST_PP_FOR_15, BOOST_PP_FOR_3, BOOST_PP_FOR_31, BOOST_PP_FOR_63, BOOST_PP_FOR_7, BOOST_PP_NODE_ENTRY_256, BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_2, BOOST_PP_SEQ_SIZE_BOOST_PP_SEQ_SIZE_3, BOOST_TEST_TOOL_PASS_ARGS0, BOOST_TEST_TOOL_PASS_PRED0, BOOST_CHECK_EQUAL, BOOST_CHECK, BOOST_TEST_TOOL_PASS_ARGS2, BOOST_TEST_TOOL_PASS_PRED2, BOOST_AUTO_TEST_SUITE, BOOST_AUTO_TEST_SUITE_END, BOOST_CHECK_NE
#include "ElementsKernel/ThisModule.h" // for getThisModuleInfo
using std::string;
namespace Elements {
BOOST_AUTO_TEST_SUITE(ModuleInfo_test)
//-----------------------------------------------------------------------------
struct ModuleInfo_Fixture {
ModuleInfo_Fixture() = default;
~ModuleInfo_Fixture() = default;
};
//-----------------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(GetExecutablePath_test) {
const auto exe_path = System::getExecutablePath();
BOOST_CHECK(exe_path.filename().string() == "ModuleInfo_test");
}
BOOST_AUTO_TEST_CASE(ExeName_test) {
const auto exe_path = System::getExecutablePath();
const string& name = System::exeName();
BOOST_CHECK_EQUAL(exe_path.string(), name);
}
BOOST_AUTO_TEST_CASE(SelfProc_test) {
const auto proc_path = System::getSelfProc();
BOOST_CHECK(not proc_path.empty());
}
BOOST_AUTO_TEST_CASE(libraryName_test) {
const System::ModuleInfo& info = System::getThisModuleInfo();
BOOST_CHECK_EQUAL(::basename(const_cast<char*>(info.libraryName().c_str())), "ModuleInfo_test");
}
BOOST_AUTO_TEST_CASE(addresse_test) {
const System::ModuleInfo& info = System::getThisModuleInfo();
BOOST_CHECK_EQUAL(info.addresse(), static_cast<void*>(nullptr));
}
BOOST_AUTO_TEST_CASE(moduleName_test) {
const auto& module_name = System::moduleName();
BOOST_CHECK_EQUAL(module_name, "libElementsKernel");
}
BOOST_AUTO_TEST_CASE(moduleNameFull_test) {
const auto& module_name_full = System::moduleNameFull();
string module = ::basename(const_cast<char*>(module_name_full.c_str()));
BOOST_CHECK_EQUAL(module.substr(0, module.find('.')), "libElementsKernel");
}
BOOST_AUTO_TEST_CASE(exeHandle_test) {
const auto exe_handle = System::exeHandle();
BOOST_CHECK_NE(exe_handle, static_cast<void*>(nullptr));
}
BOOST_AUTO_TEST_CASE(linkedModules_test) {
const auto linked_modules = System::linkedModules();
BOOST_CHECK(!linked_modules.empty());
}
BOOST_AUTO_TEST_CASE(linkedModulePaths_test) {
const auto linked_module_path = System::linkedModulePaths();
BOOST_CHECK(!linked_module_path.empty());
}
BOOST_AUTO_TEST_SUITE_END()
//-----------------------------------------------------------------------------
//
// End of the Boost tests
//
//-----------------------------------------------------------------------------
} // namespace Elements