diff --git a/CMakeLists.txt b/CMakeLists.txt index 27aca73..a17d5d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,5 +6,5 @@ SET (CMAKE_BUILD_TYPE gdb) SET (CMAKE_C_FLAGS_GDB " -Wall -ggdb") SET (CMAKE_CXX_FLAGS_GDB " -Wall -ggdb") -add_subdirectory(langkit bin) -add_subdirectory(boxedcpp bin) +add_subdirectory(langkit bin/langkit) +add_subdirectory(boxedcpp bin/boxedcpp) diff --git a/boxedcpp/CMakeLists.txt b/boxedcpp/CMakeLists.txt index 2ed93fe..39d5e17 100644 --- a/boxedcpp/CMakeLists.txt +++ b/boxedcpp/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 2.6) +enable_testing() + + project(boxedcpp) @@ -6,10 +9,17 @@ SET (CMAKE_BUILD_TYPE gdb) SET (CMAKE_C_FLAGS_GDB " -Wall -ggdb") SET (CMAKE_CXX_FLAGS_GDB " -Wall -ggdb") -find_package( Boost 1.36.0 COMPONENTS regex) +find_package( Boost 1.36.0 COMPONENTS regex unit_test_framework) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) - include_directories(.) + include_directories(.) - add_executable(boxedcpp_test test.cpp) + add_executable(boxedcpp_test test.cpp) + + add_executable(boxedcpp_unittest unittest.cpp) + + target_link_libraries(boxedcpp_unittest ${Boost_LIBRARIES}) + endif() + +add_test(boxedcpp_unittest boxedcpp_unittest) diff --git a/boxedcpp/boxedcpp.hpp b/boxedcpp/boxedcpp.hpp index d5bbc80..48297eb 100644 --- a/boxedcpp/boxedcpp.hpp +++ b/boxedcpp/boxedcpp.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "boxed_value.hpp" #include "type_info.hpp" diff --git a/boxedcpp/type_info.hpp b/boxedcpp/type_info.hpp index a196da5..6135cdc 100644 --- a/boxedcpp/type_info.hpp +++ b/boxedcpp/type_info.hpp @@ -2,7 +2,7 @@ #define __type_info_hpp__ #include - +#include struct Type_Info { Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, diff --git a/boxedcpp/unittest.cpp b/boxedcpp/unittest.cpp new file mode 100644 index 0000000..ec2aafa --- /dev/null +++ b/boxedcpp/unittest.cpp @@ -0,0 +1,16 @@ +#include "boxedcpp.hpp" + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE boxedcpp_unittests +#include + +BOOST_AUTO_TEST_CASE( add_operators ) +{ + BoxedCPP_System ss; + bootstrap(ss); + dump_system(ss); + + BOOST_CHECK_EQUAL(Cast_Helper()(dispatch(ss.get_function("+"), Param_List_Builder() << double(5.1) << double(10.3))), 15.4); + + +} diff --git a/langkit/CMakeLists.txt b/langkit/CMakeLists.txt index 2ec9f85..f95ee99 100644 --- a/langkit/CMakeLists.txt +++ b/langkit/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 2.6) +enable_testing() + project(langkit) @@ -6,10 +8,16 @@ SET (CMAKE_BUILD_TYPE gdb) SET (CMAKE_C_FLAGS_GDB " -Wall -ggdb") SET (CMAKE_CXX_FLAGS_GDB " -Wall -ggdb") -find_package( Boost 1.36.0 COMPONENTS regex) +find_package( Boost 1.36.0 COMPONENTS regex unit_test_framework) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_executable(langkit_test main.cpp langkit_lexer.cpp langkit_parser.cpp) target_link_libraries(langkit_test ${Boost_LIBRARIES}) + + + add_executable(langkit_unittest unittest.cpp) + target_link_libraries(langkit_unittest ${Boost_LIBRARIES}) endif() + +add_test(langkit_unittest langkit_unittest) diff --git a/langkit/unittest.cpp b/langkit/unittest.cpp new file mode 100644 index 0000000..4e2dda7 --- /dev/null +++ b/langkit/unittest.cpp @@ -0,0 +1,8 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE boxedcpp_unittests +#include + +BOOST_AUTO_TEST_CASE( add_operators ) +{ + BOOST_CHECK_EQUAL(2, 2); +}