Added basic support for boost unit testing
This commit is contained in:
parent
6d4ec204b0
commit
72ae292a43
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "boxed_value.hpp"
|
||||
#include "type_info.hpp"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define __type_info_hpp__
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
struct Type_Info
|
||||
{
|
||||
Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
|
||||
|
16
boxedcpp/unittest.cpp
Normal file
16
boxedcpp/unittest.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "boxedcpp.hpp"
|
||||
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MODULE boxedcpp_unittests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( add_operators )
|
||||
{
|
||||
BoxedCPP_System ss;
|
||||
bootstrap(ss);
|
||||
dump_system(ss);
|
||||
|
||||
BOOST_CHECK_EQUAL(Cast_Helper<int>()(dispatch(ss.get_function("+"), Param_List_Builder() << double(5.1) << double(10.3))), 15.4);
|
||||
|
||||
|
||||
}
|
@ -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)
|
||||
|
8
langkit/unittest.cpp
Normal file
8
langkit/unittest.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MODULE boxedcpp_unittests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( add_operators )
|
||||
{
|
||||
BOOST_CHECK_EQUAL(2, 2);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user