20#include <boost/test/unit_test.hpp>
24#include <wx/textctrl.h>
25#include <wx/statusbr.h>
40 m_messages.push_back( std::make_pair( aText, aSeverity ) );
90 if( field >= 0 && field < (
int)
m_fields.size() )
95 if( field >= 0 && field < (
int)
m_fields.size() )
110 BOOST_CHECK( !
reporter.HasMessage() );
121 BOOST_CHECK(
reporter.HasMessage() );
125 const auto& messages =
reporter.GetMessages();
139 BOOST_CHECK(
reporter.HasMessage() );
154 BOOST_CHECK(
reporter.HasMessage() );
157 const auto& messages =
reporter.GetMessages();
168 BOOST_CHECK(
reporter.HasMessage() );
171 const auto& messages =
reporter.GetMessages();
182 BOOST_CHECK(
reporter.HasMessage() );
185 const auto& messages =
reporter.GetMessages();
196 BOOST_CHECK(
reporter.HasMessage() );
208 BOOST_CHECK(
reporter.HasMessage() );
214 BOOST_CHECK( !
reporter.HasMessage() );
245 BOOST_CHECK(
reporter.HasMessage() );
248 const auto& messages =
reporter.GetMessages();
255 wxString longMessage( 10000,
'A' );
259 BOOST_CHECK(
reporter.HasMessage() );
262 const auto& messages =
reporter.GetMessages();
270 BOOST_CHECK( !
reporter.HasMessage() );
274 BOOST_CHECK(
reporter.HasMessage() );
275 BOOST_CHECK( !
reporter.GetMessages().IsEmpty() );
276 BOOST_CHECK(
reporter.GetMessages().Contains( wxT(
"Test message") ) );
286 BOOST_CHECK(
reporter.HasMessage() );
288 const wxString& messages =
reporter.GetMessages();
289 BOOST_CHECK( messages.Contains( wxT(
"Message 1") ) );
290 BOOST_CHECK( messages.Contains( wxT(
"Message 2") ) );
298 BOOST_CHECK(
reporter.HasMessage() );
302 BOOST_CHECK( !
reporter.HasMessage() );
303 BOOST_CHECK(
reporter.GetMessages().IsEmpty() );
327 BOOST_CHECK(
reporter.HasMessage() );
328 const wxString& messages =
reporter.GetMessages();
329 BOOST_CHECK( messages.Contains( wxT(
"First") ) );
330 BOOST_CHECK( messages.Contains( wxT(
"Second") ) );
331 BOOST_CHECK( messages.Contains( wxT(
"Third") ) );
367 BOOST_CHECK( !
reporter.GetVerbose() );
373 bool originalState =
reporter.GetVerbose();
377 BOOST_CHECK(
reporter.GetVerbose() );
381 BOOST_CHECK( !
reporter.GetVerbose() );
384 reporter.SetVerbose( originalState );
408 std::vector<std::unique_ptr<REPORTER>> reporters;
409 reporters.push_back( std::make_unique<WX_STRING_REPORTER>() );
410 reporters.push_back( std::make_unique<TEST_REPORTER>() );
416 BOOST_CHECK(
reporter->HasMessage() );
430 BOOST_CHECK(
reporter.HasMessage() );
432 const wxString& messages =
reporter.GetMessages();
433 BOOST_CHECK( messages.Contains( wxT(
"First") ) );
434 BOOST_CHECK( messages.Contains( wxT(
"Head") ) );
435 BOOST_CHECK( messages.Contains( wxT(
"Tail") ) );
443 reporter.Report( wxT(
"Default severity") );
445 const auto& messages =
reporter.GetMessages();
469 BOOST_CHECK( !
reporter.GetVerbose() );
475 bool originalState =
reporter.GetVerbose();
479 BOOST_CHECK(
reporter.GetVerbose() );
483 BOOST_CHECK( !
reporter.GetVerbose() );
486 reporter.SetVerbose( originalState );
521 constexpr int threadCount = 8;
522 constexpr int perThread = 2000;
524 std::vector<std::thread> workers;
525 workers.reserve( threadCount );
527 for(
int t = 0; t < threadCount; ++t )
529 workers.emplace_back(
532 for(
int i = 0; i < perThread; ++i )
537 for( std::thread& worker : workers )
Reporter forwarding messages to stdout or stderr as appropriate.
static CLI_PROGRESS_REPORTER & GetInstance()
Reporter forwarding messages to stdout or stderr as appropriate.
static CLI_REPORTER & GetInstance()
void SetStatusText(const wxString &text, int field=0)
wxString GetStatusText(int field=0) const
std::vector< wxString > m_fields
void AppendText(const wxString &text)
void SetValue(const wxString &text)
wxString GetValue() const
static REPORTER & GetInstance()
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
static REPORTER & GetInstance()
A thread-safe REPORTER wrapper that serializes forwarding to an underlying reporter.
bool HasMessage() const override
Returns true if any messages were reported.
REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the beginning of the list for objects that support ordering.
bool HasMessageOfSeverity(int aSeverityMask) const override
Returns true if the reporter has one or more messages matching the specified severity mask.
REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the end of the list, for objects that support report ordering.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
std::vector< std::pair< wxString, SEVERITY > > m_messages
const std::vector< std::pair< wxString, SEVERITY > > & GetMessages() const
int GetMessageCount() const
bool HasMessage() const override
Returns true if any messages were reported.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
static REPORTER & GetInstance()
A wrapper for reporting to a wxString object.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
IbisParser parser & reporter
BOOST_AUTO_TEST_CASE(BaseReporter_Constructor)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")