KiCad PCB EDA Suite
KI_TEST::WX_ASSERT_ERROR Class Reference

An exception class to represent a WX assertion. More...

#include <wx_assert.h>

Inheritance diagram for KI_TEST::WX_ASSERT_ERROR:

Public Member Functions

 WX_ASSERT_ERROR (const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
 
const char * what () const noexcept override
 

Public Attributes

std::string m_file
 
int m_line
 
std::string m_func
 
std::string m_cond
 
std::string m_msg
 
std::string m_format_msg
 

Detailed Description

An exception class to represent a WX assertion.

In normal programs, this is popped as a dialog, but in unit tests, it prints a fairly unhelpful stack trace and otherwise doesn't inform the test runner.

We want to raise a formal exception to allow us to catch it with things like BOOST_CHECK_THROW if expected, or for the test case to fail if not expected.

Definition at line 46 of file wx_assert.h.

Constructor & Destructor Documentation

◆ WX_ASSERT_ERROR()

KI_TEST::WX_ASSERT_ERROR::WX_ASSERT_ERROR ( const wxString &  aFile,
int  aLine,
const wxString &  aFunc,
const wxString &  aCond,
const wxString &  aMsg 
)

Definition at line 30 of file wx_assert.cpp.

32  : m_file( aFile ), m_line( aLine ), m_func( aFunc ), m_cond( aCond ), m_msg( aMsg )
33 {
34  std::ostringstream ss;
35 
36  ss << "WX assertion in " << m_file << ":" << m_line << "\n"
37  << "in function " << m_func << "\n"
38  << "failed condition: " << m_cond;
39 
40  if( m_msg.size() )
41  ss << "\n"
42  << "with message: " << m_msg;
43 
44  m_format_msg = ss.str();
45 }
std::string m_format_msg
Definition: wx_assert.h:62

References m_cond, m_file, m_format_msg, m_func, m_line, and m_msg.

Member Function Documentation

◆ what()

const char * KI_TEST::WX_ASSERT_ERROR::what ( ) const
overridenoexcept

Definition at line 47 of file wx_assert.cpp.

48 {
49  return m_format_msg.c_str();
50 }
std::string m_format_msg
Definition: wx_assert.h:62

References m_format_msg.

Member Data Documentation

◆ m_cond

std::string KI_TEST::WX_ASSERT_ERROR::m_cond

Definition at line 59 of file wx_assert.h.

Referenced by WX_ASSERT_ERROR().

◆ m_file

std::string KI_TEST::WX_ASSERT_ERROR::m_file

Definition at line 56 of file wx_assert.h.

Referenced by WX_ASSERT_ERROR().

◆ m_format_msg

std::string KI_TEST::WX_ASSERT_ERROR::m_format_msg

Definition at line 62 of file wx_assert.h.

Referenced by what(), and WX_ASSERT_ERROR().

◆ m_func

std::string KI_TEST::WX_ASSERT_ERROR::m_func

Definition at line 58 of file wx_assert.h.

Referenced by WX_ASSERT_ERROR().

◆ m_line

int KI_TEST::WX_ASSERT_ERROR::m_line

Definition at line 57 of file wx_assert.h.

Referenced by WX_ASSERT_ERROR().

◆ m_msg

std::string KI_TEST::WX_ASSERT_ERROR::m_msg

Definition at line 60 of file wx_assert.h.

Referenced by WX_ASSERT_ERROR().


The documentation for this class was generated from the following files: