在visual studio 2013上尝试使用boost::test
进行简单测试:
#define BOOST_LIB_TOOLSET "vc120"
#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(my_test)
{
BOOST_CHECK(1 == 2);
}
构建后,运行时,会因以下堆栈跟踪而失败。知道这里出了什么问题吗?
错误: Access violation reading location 0x00000000.
> OrderProxy.exe!std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > >::begin() Line 1121 C++
OrderProxy.exe!boost::unit_test::for_each::begin<std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > > >(const std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > > & t, boost::mpl::bool_<1> __formal) Line 107 C++
OrderProxy.exe!boost::runtime::cla::parser::operator[](boost::unit_test::basic_cstring<char const > string_id) Line 169 C++
OrderProxy.exe!boost::unit_test::runtime_config::`anonymous namespace'::retrieve_parameter<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >(boost::unit_test::basic_cstring<char const > parameter_name, const boost::runtime::cla::parser & s_cla_parser, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & default_value, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & optional_value) Line 216 C++
OrderProxy.exe!boost::unit_test::runtime_config::report_sink() Line 470 C++
OrderProxy.exe!boost::unit_test::results_reporter::`anonymous namespace'::results_reporter_impl::results_reporter_impl() Line 59 C++
OrderProxy.exe!boost::unit_test::results_reporter::`anonymous namespace'::s_rr_impl() Line 91 C++
OrderProxy.exe!boost::unit_test::results_reporter::get_stream() Line 120 C++
OrderProxy.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite * (int, char * *) * init_func, int argc, char * * argv) Line 207 C++
OrderProxy.exe!main(int argc, char * * argv) Line 237 C++
[External Code]
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
内部堆栈跟踪,从这里跳转:
int BOOST_TEST_DECL
unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
{
try {
framework::init( init_func, argc, argv );
if( !runtime_config::test_to_run().is_empty() ) {
test_case_filter filter( runtime_config::test_to_run() );
traverse_test_tree( framework::master_test_suite().p_id, filter );
}
framework::run();
results_reporter::make_report();
return runtime_config::no_result_code()
? boost::exit_success
: results_collector.results( framework::master_test_suite().p_id ).result_code();
}
catch( framework::nothing_to_test const& ) {
return boost::exit_success;
}
catch( framework::internal_error const& ex ) {
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
return boost::exit_exception_failure;
}
catch( framework::setup_error const& ex ) {
results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
return boost::exit_exception_failure;
}
catch( ... ) {
>>>>>>>>>>>> here >>>>>>> results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
return boost::exit_exception_failure;
}
}