1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
11 #include <boost/filesystem.hpp>
15 BOOST_AUTO_TEST_SUITE(RuntimeLibraryTest)
19 BOOST_CHECK_EQUAL(
true,
true);
20 std::string cc_filename_base =
"tests/unit/system/runtime_lib";
21 fs::path cc_filename {cc_filename_base +
".cc"};
22 BOOST_CHECK_EQUAL(
true,
true);
24 fs::ofstream file(cc_filename);
25 file <<
"#include <iostream>\n"
26 "extern \"C\" int forty_two() {\n"
30 "extern \"C\" int add(int a, int b) {\n"
34 BOOST_CHECK_EQUAL(
true,
true);
41 BOOST_CHECK_EQUAL(
true,
true);
47 "Compiling RuntimeLibrary test code",
50 BOOST_CHECK_EQUAL(
true,
true);
53 std::function<int()> forty_two = lib.
get_function<int()>(
"forty_two");
56 BOOST_CHECK_EQUAL(42, forty_two());
59 std::function<int(int, int)> add = lib.
get_function<int(
int,
int)>(
"add");
62 BOOST_CHECK_EQUAL(5, add(2, 3));
67 BOOST_CHECK_EQUAL(
true,
true);
71 BOOST_AUTO_TEST_SUITE_END()
static std::pair< std::string, std::string > default_cxxflags()
Default c++ compiler options.
std::string link_path(const fs::path &dir)
static std::pair< std::string, std::string > default_cxx()
Return default compiler.
Write, compile, load and use code at runtime.
static std::pair< fs::path, std::string > default_boost_libdir()
Return default libdir for boost.
static std::pair< std::string, std::string > default_soflags()
Default c++ compiler options.
std::function< Signature > get_function(std::string function_name) const
Obtain a function from the current library.
BOOST_AUTO_TEST_CASE(FunctionTest)
void rm()
Remove the current library and source code.