Porytiles
Loading...
Searching...
No Matches
porytiles2::BufferedUserDiagnostics Class Referencefinal

Testing implementation of UserDiagnostics that buffers all diagnostic output. More...

#include <buffered_user_diagnostics.hpp>

Inheritance diagram for porytiles2::BufferedUserDiagnostics:
[legend]
Collaboration diagram for porytiles2::BufferedUserDiagnostics:
[legend]

Public Member Functions

void note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged informational note message.
 
void warn_note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged warning note message.
 
void warn (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged warning message.
 
void err (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged error message.
 
void emit_fatal_proximate (const Error &err) const override
 Emit the proximate (immediate) error in a fatal error chain.
 
void emit_fatal_step (const Error &err) const override
 Emit an intermediate step error in a fatal error chain.
 
void emit_fatal_root (const Error &err) const override
 Emit the root cause error in a fatal error chain.
 
const std::vector< std::vector< std::string > > & notes () const
 Get the buffered note messages.
 
const std::vector< std::vector< std::string > > & warn_notes () const
 Get the buffered warning note messages.
 
const std::vector< std::vector< std::string > > & warnings () const
 Get the buffered warning messages.
 
const std::vector< std::vector< std::string > > & errors () const
 Get the buffered error messages.
 
const std::vector< std::vector< std::string > > & fatal_proximates () const
 Get the buffered fatal proximate error messages.
 
const std::vector< std::vector< std::string > > & fatal_steps () const
 Get the buffered fatal step error messages.
 
const std::vector< std::vector< std::string > > & fatal_roots () const
 Get the buffered fatal root error messages.
 
const std::map< std::string, size_t > & note_tag_counts () const
 Get the count of note messages by tag.
 
const std::map< std::string, size_t > & warn_note_tag_counts () const
 Get the count of warning note messages by tag.
 
const std::map< std::string, size_t > & warning_tag_counts () const
 Get the count of warning messages by tag.
 
const std::map< std::string, size_t > & error_tag_counts () const
 Get the count of error messages by tag.
 
- Public Member Functions inherited from porytiles2::UserDiagnostics
virtual ~UserDiagnostics ()=default
 
void note (const std::string &tag, const std::string &msg) const
 Display a tagged informational note message.
 
void warn_note (const std::string &tag, const std::string &msg) const
 Display a note message with a warning tag.
 
void warn (const std::string &tag, const std::string &msg) const
 Display a tagged warning message.
 
void err (const std::string &tag, const std::string &msg) const
 Display a tagged error message.
 
template<typename T , typename E >
void fatal (const ChainableResult< T, E > &result) const
 Display a fatal error with complete error chain visualization.
 

Detailed Description

Testing implementation of UserDiagnostics that buffers all diagnostic output.

BufferedUserDiagnostics provides a test-friendly implementation of the UserDiagnostics interface that stores all diagnostic messages in memory buffers instead of outputting them. This enables unit tests to verify that appropriate diagnostic messages were generated during execution.

Each diagnostic type (notes, warnings, errors, etc.) is stored in its own dedicated buffer as a vector of message lines. Tests can access these buffers to verify both the presence and content of diagnostic messages.

In addition to storing the full diagnostic messages, this class maintains count maps that track how many times each tag was used for each diagnostic type. This allows tests to quickly verify that the expected number of diagnostics with specific tags were emitted, without needing to iterate through all buffered messages. For example, tests can check that exactly 3 errors with tag "INVALID_INPUT" were generated by accessing the error_tag_counts() map.

This implementation is intended exclusively for testing scenarios where diagnostic output needs to be captured and inspected programmatically.

Definition at line 31 of file buffered_user_diagnostics.hpp.

Member Function Documentation

◆ emit_fatal_proximate()

void porytiles2::BufferedUserDiagnostics::emit_fatal_proximate ( const Error err) const
overridevirtual

Emit the proximate (immediate) error in a fatal error chain.

Virtual method for displaying the most immediate error in a fatal error chain. This is typically the first error encountered and is displayed with the highest visual prominence.

Parameters
errThe proximate error to display

Implements porytiles2::UserDiagnostics.

Definition at line 35 of file buffered_user_diagnostics.cpp.

◆ emit_fatal_root()

void porytiles2::BufferedUserDiagnostics::emit_fatal_root ( const Error err) const
overridevirtual

Emit the root cause error in a fatal error chain.

Virtual method for displaying the root cause error in a fatal error chain. This represents the original underlying cause of the failure and is typically displayed as the final item in the error hierarchy.

Parameters
errThe root cause error to display

Implements porytiles2::UserDiagnostics.

Definition at line 47 of file buffered_user_diagnostics.cpp.

◆ emit_fatal_step()

void porytiles2::BufferedUserDiagnostics::emit_fatal_step ( const Error err) const
overridevirtual

Emit an intermediate step error in a fatal error chain.

Virtual method for displaying intermediate errors in a fatal error chain. These are errors that occurred between the proximate and root causes, typically displayed with tree-like formatting to show the error hierarchy.

Parameters
errThe step error to display

Implements porytiles2::UserDiagnostics.

Definition at line 41 of file buffered_user_diagnostics.cpp.

◆ err()

void porytiles2::BufferedUserDiagnostics::err ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged error message.

Virtual method for displaying multi-line error messages. Implementations typically format the first line with an "error:" prefix and subsequent lines with appropriate indentation.

Parameters
tagCategorization tag for the error
linesVector of strings representing each line of the error

Implements porytiles2::UserDiagnostics.

Definition at line 29 of file buffered_user_diagnostics.cpp.

◆ error_tag_counts()

const std::map< std::string, size_t > & porytiles2::BufferedUserDiagnostics::error_tag_counts ( ) const
inline

Get the count of error messages by tag.

Returns a reference to a map that tracks how many times each tag was used in calls to err(). The keys are tag strings and the values are the number of times each tag appeared.

Returns
Reference to the error tag count map

Definition at line 197 of file buffered_user_diagnostics.hpp.

◆ errors()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::errors ( ) const
inline

Get the buffered error messages.

Returns a reference to the vector containing all error messages that were passed to err(). Each element represents one call to err(), stored as a vector of lines.

Returns
Reference to the error buffer

Definition at line 98 of file buffered_user_diagnostics.hpp.

◆ fatal_proximates()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::fatal_proximates ( ) const
inline

Get the buffered fatal proximate error messages.

Returns a reference to the vector containing all fatal proximate error messages that were passed to emit_fatal_proximate(). Each element represents one call to emit_fatal_proximate(), stored as a vector of message lines.

Returns
Reference to the fatal proximate buffer

Definition at line 113 of file buffered_user_diagnostics.hpp.

◆ fatal_roots()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::fatal_roots ( ) const
inline

Get the buffered fatal root error messages.

Returns a reference to the vector containing all fatal root error messages that were passed to emit_fatal_root(). Each element represents one call to emit_fatal_root(), stored as a vector of message lines.

Returns
Reference to the fatal root buffer

Definition at line 141 of file buffered_user_diagnostics.hpp.

◆ fatal_steps()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::fatal_steps ( ) const
inline

Get the buffered fatal step error messages.

Returns a reference to the vector containing all fatal step error messages that were passed to emit_fatal_step(). Each element represents one call to emit_fatal_step(), stored as a vector of message lines.

Returns
Reference to the fatal step buffer

Definition at line 127 of file buffered_user_diagnostics.hpp.

◆ note()

void porytiles2::BufferedUserDiagnostics::note ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged informational note message.

Virtual method for displaying multi-line informational messages. Implementations typically format the first line with a "note:" prefix and subsequent lines with appropriate indentation.

Parameters
tagCategorization tag for the note
linesVector of strings representing each line of the note

Implements porytiles2::UserDiagnostics.

Definition at line 11 of file buffered_user_diagnostics.cpp.

◆ note_tag_counts()

const std::map< std::string, size_t > & porytiles2::BufferedUserDiagnostics::note_tag_counts ( ) const
inline

Get the count of note messages by tag.

Returns a reference to a map that tracks how many times each tag was used in calls to note(). The keys are tag strings and the values are the number of times each tag appeared.

Returns
Reference to the note tag count map

Definition at line 155 of file buffered_user_diagnostics.hpp.

◆ notes()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::notes ( ) const
inline

Get the buffered note messages.

Returns a reference to the vector containing all note messages that were passed to note(). Each element represents one call to note(), stored as a vector of lines.

Returns
Reference to the note buffer

Definition at line 56 of file buffered_user_diagnostics.hpp.

◆ warn()

void porytiles2::BufferedUserDiagnostics::warn ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged warning message.

Virtual method for displaying multi-line warnings with categorization. Implementations typically format the first line with a "warning:" prefix and the tag, with subsequent lines appropriately indented.

Parameters
tagCategorization tag for the warning
linesVector of strings representing each line of the warning

Implements porytiles2::UserDiagnostics.

Definition at line 23 of file buffered_user_diagnostics.cpp.

◆ warn_note()

void porytiles2::BufferedUserDiagnostics::warn_note ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged warning note message.

Virtual method for displaying multi-line warning notes with categorization. Implementations typically format these with note-style prefixes but include the tag for categorization purposes.

Parameters
tagCategorization tag for the warning note
linesVector of strings representing each line of the warning note

Implements porytiles2::UserDiagnostics.

Definition at line 17 of file buffered_user_diagnostics.cpp.

◆ warn_note_tag_counts()

const std::map< std::string, size_t > & porytiles2::BufferedUserDiagnostics::warn_note_tag_counts ( ) const
inline

Get the count of warning note messages by tag.

Returns a reference to a map that tracks how many times each tag was used in calls to warn_note(). The keys are tag strings and the values are the number of times each tag appeared.

Returns
Reference to the warning note tag count map

Definition at line 169 of file buffered_user_diagnostics.hpp.

◆ warn_notes()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::warn_notes ( ) const
inline

Get the buffered warning note messages.

Returns a reference to the vector containing all warning note messages that were passed to warn_note(). Each element represents one call to warn_note(), stored as a vector of lines.

Returns
Reference to the warning note buffer

Definition at line 70 of file buffered_user_diagnostics.hpp.

◆ warning_tag_counts()

const std::map< std::string, size_t > & porytiles2::BufferedUserDiagnostics::warning_tag_counts ( ) const
inline

Get the count of warning messages by tag.

Returns a reference to a map that tracks how many times each tag was used in calls to warn(). The keys are tag strings and the values are the number of times each tag appeared.

Returns
Reference to the warning tag count map

Definition at line 183 of file buffered_user_diagnostics.hpp.

◆ warnings()

const std::vector< std::vector< std::string > > & porytiles2::BufferedUserDiagnostics::warnings ( ) const
inline

Get the buffered warning messages.

Returns a reference to the vector containing all warning messages that were passed to warn(). Each element represents one call to warn(), stored as a vector of lines.

Returns
Reference to the warning buffer

Definition at line 84 of file buffered_user_diagnostics.hpp.


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