FC Updates from BitShares and myself #21
1 changed files with 38 additions and 0 deletions
|
|
@ -1,9 +1,15 @@
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <fc/stacktrace.hpp>
|
#include <fc/stacktrace.hpp>
|
||||||
|
#include <fc/static_variant.hpp>
|
||||||
#include <fc/thread/thread.hpp>
|
#include <fc/thread/thread.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(fc_stacktrace)
|
BOOST_AUTO_TEST_SUITE(fc_stacktrace)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(stacktrace_test)
|
BOOST_AUTO_TEST_CASE(stacktrace_test)
|
||||||
|
|
@ -40,6 +46,38 @@ BOOST_AUTO_TEST_CASE(threaded_stacktrace_test)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOST_VERSION / 100000 >= 1 && ((BOOST_VERSION / 100) % 1000) >= 65
|
||||||
|
class _svdt_visitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::string result_type;
|
||||||
|
std::string operator()( int64_t i )const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
fc::print_stacktrace(ss);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
std::string operator()( T i )const { return "Unexpected!"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(static_variant_depth_test)
|
||||||
|
{
|
||||||
|
int64_t i = 1;
|
||||||
|
fc::static_variant<uint8_t,uint16_t,uint32_t,uint64_t,int8_t,int16_t,int32_t,int64_t> test(i);
|
||||||
|
|
||||||
|
std::string stacktrace = test.visit( _svdt_visitor() );
|
||||||
|
//std::cerr << stacktrace << "\n";
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
boost::split( lines, stacktrace, boost::is_any_of("\n") );
|
||||||
|
int count = 0;
|
||||||
|
for( const auto& line : lines )
|
||||||
|
if( line.find("_svdt_visitor") != std::string::npos ) count++;
|
||||||
|
BOOST_CHECK_LT( 3, count ); // test.visit(), static_variant::visit, function object, visitor
|
||||||
|
BOOST_CHECK_GT( 8, count ); // some is implementation-dependent
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* this test causes a segfault on purpose to test the event handler
|
/* this test causes a segfault on purpose to test the event handler
|
||||||
BOOST_AUTO_TEST_CASE(cause_segfault)
|
BOOST_AUTO_TEST_CASE(cause_segfault)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue