Spit unit tests.
This commit is contained in:
@@ -37,17 +37,6 @@ struct test_fixture {
|
||||
test object;
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(string2type_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test1 )
|
||||
{
|
||||
int x = string2type::convert<int>("42");
|
||||
|
||||
BOOST_CHECK( x == 42 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE( test_suite, test_fixture )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -2,8 +2,10 @@ cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
add_executable(unittest unittest.cpp)
|
||||
add_executable(AttributesTest AttributesTest.cpp)
|
||||
target_link_libraries(AttributesTest ${Boost_LIBRARIES})
|
||||
add_test(AttributesTest AttributesTest)
|
||||
|
||||
target_link_libraries(unittest ${Boost_LIBRARIES})
|
||||
|
||||
add_test(unittest unittest)
|
||||
add_executable(String2typeTest String2typeTest.cpp)
|
||||
target_link_libraries(String2typeTest ${Boost_LIBRARIES})
|
||||
add_test(String2typeTest String2typeTest)
|
||||
|
||||
41
unittest/String2typeTest.cpp
Normal file
41
unittest/String2typeTest.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "string2type.hpp"
|
||||
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MODULE attributes_test
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace string2type {
|
||||
|
||||
template<>
|
||||
int convert<int>(const std::string &value) {
|
||||
return boost::lexical_cast<int>(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
double convert<double>(const std::string &value) {
|
||||
return boost::lexical_cast<double>(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(string2type_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test1 )
|
||||
{
|
||||
int x = string2type::convert<int>("42");
|
||||
|
||||
BOOST_CHECK( x == 42 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test2 )
|
||||
{
|
||||
double x = string2type::convert<double>("3.14");
|
||||
|
||||
BOOST_CHECK( x >= 3.14 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user