Class Failure¶
Defined in File Failure.hpp
Inheritance Relationships¶
Derived Types¶
public mu::tiny::mock::Failure(Class Failure)public mu::tiny::test::ApproxEqualFailure< T >(Template Class ApproxEqualFailure)public mu::tiny::test::BinaryEqualFailure(Class BinaryEqualFailure)public mu::tiny::test::CheckEqualFailure(Class CheckEqualFailure)public mu::tiny::test::CheckFailure(Class CheckFailure)public mu::tiny::test::ComparisonFailure(Class ComparisonFailure)public mu::tiny::test::ContainsFailure(Class ContainsFailure)public mu::tiny::test::EqualsFailure(Class EqualsFailure)public mu::tiny::test::FailFailure(Class FailFailure)public mu::tiny::test::FeatureUnsupportedFailure(Class FeatureUnsupportedFailure)public mu::tiny::test::IntMaxEqualFailure(Class IntMaxEqualFailure)public mu::tiny::test::StringEqualFailure(Class StringEqualFailure)public mu::tiny::test::StringEqualNoCaseFailure(Class StringEqualNoCaseFailure)public mu::tiny::test::UintMaxEqualFailure(Class UintMaxEqualFailure)public mu::tiny::test::UnexpectedExceptionFailure(Class UnexpectedExceptionFailure)
Class Documentation¶
-
class Failure¶
[source] Holds location and message information for a single test failure.
Subclass Failure to provide richer diagnostic messages. The assertion macros construct the appropriate concrete subclass and pass it to Shell::add_failure().
Subclassed by mu::tiny::mock::Failure, mu::tiny::test::ApproxEqualFailure< T >, mu::tiny::test::BinaryEqualFailure, mu::tiny::test::CheckEqualFailure, mu::tiny::test::CheckFailure, mu::tiny::test::ComparisonFailure, mu::tiny::test::ContainsFailure, mu::tiny::test::EqualsFailure, mu::tiny::test::FailFailure, mu::tiny::test::FeatureUnsupportedFailure, mu::tiny::test::IntMaxEqualFailure, mu::tiny::test::StringEqualFailure, mu::tiny::test::StringEqualNoCaseFailure, mu::tiny::test::UintMaxEqualFailure, mu::tiny::test::UnexpectedExceptionFailure
Public Functions
-
Failure(Shell *test, const char *file_name, int_least32_t line_number, const String &the_message)¶
Construct with full location information and a message.
- Parameters:
test – The test shell in which the failure occurred.
file_name – Source file of the failing assertion.
line_number – Line number of the failing assertion.
the_message – Human-readable failure description.
-
Failure(Shell *test, const String &the_message)¶
Construct with a message but no assertion location (test-level error).
- Parameters:
test – The test shell in which the failure occurred.
the_message – Human-readable failure description.
-
Failure(Shell *test, const char *file_name, int_least32_t line_number)¶
Construct with a location but no message (location-only failure).
- Parameters:
test – The test shell in which the failure occurred.
file_name – Source file of the failing assertion.
line_number – Line number of the failing assertion.
-
virtual int_least32_t get_failure_line_number() const¶
- Returns:
Line number of the failing assertion.
-
virtual const String &get_test_file_name() const¶
- Returns:
Source file in which the test is defined.
-
virtual int_least32_t get_test_line_number() const¶
- Returns:
Line number of the TEST() macro for the failing test.
-
inline virtual bool is_error() const¶
- Returns:
true if this failure represents an error (e.g. unexpected exception) rather than a normal assertion failure.
-
bool is_outside_test_file() const¶
- Returns:
true if the failure originated outside the test’s source file.
-
bool is_in_helper_function() const¶
- Returns:
true if the failure originated in a helper function.
Protected Static Functions
-
static String create_but_was_string(const String &expected, const String &actual)¶
Format a
expected <X> but was <Y>string.- Parameters:
expected – Expected value as a string.
actual – Actual value as a string.
- Returns:
Formatted comparison string.
-
static String create_difference_at_pos_string(const String &actual, size_t offset, size_t reported_position)¶
Format a
difference starts at position Nstring.- Parameters:
actual – Actual string value.
offset – Byte offset where the difference starts.
reported_position – 1-based position to report to the user.
- Returns:
Formatted difference-position string.
-
Failure(Shell *test, const char *file_name, int_least32_t line_number, const String &the_message)¶