void log_exception( std::ostream&, log_checkpoint_data const& cpd, const_string explanation ) { if( cpd.m_line_num >= 0 ) { char writeBuffer[1024]; sprintf( writeBuffer, "%d,%s,%s", cpd.m_line_num, cpd.m_file_name.begin(), explanation.begin() ); DWORD dwWrite; if( WriteFile( m_WritePipe, writeBuffer, 1024, &dwWrite, NULL ) == false || dwWrite != 1024 ) ExitProcess(-1); } }
void setup( const const_string& stream_name ) { if(stream_name.empty()) return; if( stream_name == "stderr" ) m_stream = &std::cerr; else if( stream_name == "stdout" ) m_stream = &std::cout; else { m_file = boost::make_shared<std::ofstream>(); m_file->open( std::string(stream_name.begin(), stream_name.end()).c_str() ); m_stream = m_file.get(); } }
EXPORT_C void exception_safety_tester::exception_point( const_string file, std::size_t line_num, const_string description ) { activity_guard ag( m_internal_activity ); if( ++m_exception_point_counter == m_forced_exception_point ) { m_execution_path.push_back( execution_path_point( EPP_EXCEPT, file, line_num ) ); m_execution_path.back().m_except.description = description.begin(); ++m_exec_path_point; failure_point(); } }
EXPORT_C unsigned exception_safety_tester::enter_scope( const_string file, std::size_t line_num, const_string scope_name ) { activity_guard ag( m_internal_activity ); if( m_exec_path_point < m_execution_path.size() ) { BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_SCOPE && m_execution_path[m_exec_path_point].m_file_name == file && m_execution_path[m_exec_path_point].m_line_num == line_num, "Function under test exibit non-deterministic behavior" ); } else { m_execution_path.push_back( execution_path_point( EPP_SCOPE, file, line_num ) ); } m_execution_path[m_exec_path_point].m_scope.size = 0; m_execution_path[m_exec_path_point].m_scope.name = scope_name.begin(); return m_exec_path_point++; }
IntType to_int(const const_string & input) { const char * m_firstc = input.begin(); const char * m_lastc = input.end() - 1; //TODO replace with a pow metafunction, if that's possible static IntType max_placeval = static_cast<IntType>(pow(10,std::numeric_limits<IntType>::digits10)); static IntType highest_digit = std::numeric_limits<IntType>::max() / max_placeval; IntType result = 0; IntType placeval = 1; bool signed_ = std::numeric_limits<IntType>::is_signed; bool minus = signed_ && *m_firstc == '-'; const_string::const_iterator firstc = m_firstc + minus; for(const_string::const_iterator i = m_lastc; i >= firstc; --i) { char c = i[0]; bool last = i == firstc; if(c < '0' || c > '9') throw std::bad_cast(); IntType digit = c - '0'; if(placeval == max_placeval && digit > highest_digit) throw std::bad_cast(); IntType tmp = placeval * digit; if( tmp > std::numeric_limits<IntType>::max() - result ) throw std::bad_cast(); result += tmp; if(placeval == max_placeval && !last) throw std::bad_cast(); placeval *= 10; } if(minus) result = -result; return result; }
setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
Player(const_string n, PlayerID i, std::unique_ptr<Controller> c) : name(n.begin(), n.end()), id(i), controller(std::move(c)) {}
std::string normalize_test_case_name(const_string name) { return ( name[0] == '&' ? std::string(name.begin()+1, name.size()-1) : std::string(name.begin(), name.size() )); }}}}
void log_entry_value( std::ostream&, const_string value ) { m_Log += value.begin(); }