|
Porytiles
|
Testing implementation of UserDiagnostics that buffers all diagnostic output. More...
#include <buffered_user_diagnostics.hpp>
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. | |
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.
|
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.
| err | The proximate error to display |
Implements porytiles2::UserDiagnostics.
Definition at line 35 of file buffered_user_diagnostics.cpp.
|
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.
| err | The root cause error to display |
Implements porytiles2::UserDiagnostics.
Definition at line 47 of file buffered_user_diagnostics.cpp.
|
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.
| err | The step error to display |
Implements porytiles2::UserDiagnostics.
Definition at line 41 of file buffered_user_diagnostics.cpp.
|
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.
| tag | Categorization tag for the error |
| lines | Vector of strings representing each line of the error |
Implements porytiles2::UserDiagnostics.
Definition at line 29 of file buffered_user_diagnostics.cpp.
|
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.
Definition at line 197 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 98 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 113 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 141 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 127 of file buffered_user_diagnostics.hpp.
|
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.
| tag | Categorization tag for the note |
| lines | Vector of strings representing each line of the note |
Implements porytiles2::UserDiagnostics.
Definition at line 11 of file buffered_user_diagnostics.cpp.
|
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.
Definition at line 155 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 56 of file buffered_user_diagnostics.hpp.
|
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.
| tag | Categorization tag for the warning |
| lines | Vector of strings representing each line of the warning |
Implements porytiles2::UserDiagnostics.
Definition at line 23 of file buffered_user_diagnostics.cpp.
|
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.
| tag | Categorization tag for the warning note |
| lines | Vector of strings representing each line of the warning note |
Implements porytiles2::UserDiagnostics.
Definition at line 17 of file buffered_user_diagnostics.cpp.
|
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.
Definition at line 169 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 70 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 183 of file buffered_user_diagnostics.hpp.
|
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.
Definition at line 84 of file buffered_user_diagnostics.hpp.