Qt-Mocks 0.8.0-alpha.9
Mocking library using Qt Test inspired by Google Test
 
Loading...
Searching...
No Matches
qt_mocks::common_matchers::Matcher< ValueType > Class Template Referenceabstract

Represents a base generic matcher for evaluating patterns or conditions against input values. More...

#include <Matchers.hpp>

Inheritance diagram for qt_mocks::common_matchers::Matcher< ValueType >:
Collaboration diagram for qt_mocks::common_matchers::Matcher< ValueType >:

Public Types

using MatcherValueType = ValueType
 The type of value to match against.
 

Public Member Functions

 Matcher (const ExpectedValue< ValueType > &value)
 Constructs the object with the given expected value.
 
 Matcher (const Matcher &other)
 Copy constructor that creates a new matcher by copying the state of another matcher.
 
 Matcher (Matcher &&other) noexcept
 Move constructor that initialises the object by transferring the state from another instance.
 
 Matcher (std::unique_ptr< ExpectedValue< ValueType > > expected)
 Constructs the object with the given the expected value object.
 
virtual ~Matcher ()=default
 
virtual bool compare (const ValueType &actual) const =0
 When implemented, compares the provided actual value against a predefined condition.
 
virtual::QString description (const ValueType &actual) const =0
 When implemented, provides a textual description of the current match result.
 
const ExpectedValue< ValueType > & expected () const noexcept
 Retrieves the expected value of the matcher.
 
bool hasExpected () const noexcept
 Checks if an expected value is set for the matcher.
 
Matcheroperator= (const Matcher &other)
 Move assignment that changes the object by transferring the state from another instance.
 
Matcheroperator= (Matcher &&other) noexcept
 Move assignment that changes the object by transferring the state from another instance.
 

Detailed Description

template<typename ValueType>
class qt_mocks::common_matchers::Matcher< ValueType >

Represents a base generic matcher for evaluating patterns or conditions against input values.

Template Parameters
ValueTypeThe type of value to match against.

Member Typedef Documentation

◆ MatcherValueType

template<typename ValueType>
using qt_mocks::common_matchers::Matcher< ValueType >::MatcherValueType = ValueType

The type of value to match against.

Constructor & Destructor Documentation

◆ Matcher() [1/4]

template<typename ValueType>
qt_mocks::common_matchers::Matcher< ValueType >::Matcher ( const ExpectedValue< ValueType > & value)
explicit

Constructs the object with the given expected value.

Parameters
valueThe expected value used to initialise the matcher.
Here is the caller graph for this function:

◆ Matcher() [2/4]

template<typename ValueType>
qt_mocks::common_matchers::Matcher< ValueType >::Matcher ( std::unique_ptr< ExpectedValue< ValueType > > expected)
explicit

Constructs the object with the given the expected value object.

Parameters
expectedThe expected value used to initialise the matcher.
Here is the call graph for this function:

◆ Matcher() [3/4]

template<typename ValueType>
qt_mocks::common_matchers::Matcher< ValueType >::Matcher ( const Matcher< ValueType > & other)

Copy constructor that creates a new matcher by copying the state of another matcher.

Parameters
otherThe matcher instance to copy.
Here is the call graph for this function:

◆ Matcher() [4/4]

template<typename ValueType>
qt_mocks::common_matchers::Matcher< ValueType >::Matcher ( Matcher< ValueType > && other)
noexcept

Move constructor that initialises the object by transferring the state from another instance.

Parameters
otherThe instance to be moved from. The object is left in an unspecified state.
Here is the call graph for this function:

◆ ~Matcher()

template<typename ValueType>
virtual qt_mocks::common_matchers::Matcher< ValueType >::~Matcher ( )
virtualdefault

Member Function Documentation

◆ compare()

template<typename ValueType>
virtual bool qt_mocks::common_matchers::Matcher< ValueType >::compare ( const ValueType & actual) const
nodiscardpure virtual

When implemented, compares the provided actual value against a predefined condition.

This method performs a comparison between the given value and the expected or predefined condition to determine if they match.

Parameters
actualThe value to compare against the predefined condition.
Returns
True if the comparison succeeds; otherwise, false.

Implemented in qt_mocks::common_matchers::AllOfMatcher< ValueType, MatcherTypes >, qt_mocks::common_matchers::AnyOfMatcher< ValueType, MatcherTypes >, qt_mocks::common_matchers::BetweenBeginInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenEndInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenExclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BooleanMatcher, qt_mocks::common_matchers::ContainsStringMatcher< ValueType >, qt_mocks::common_matchers::EqualMatcher< ValueType >, qt_mocks::common_matchers::EqualMatcher< double >, qt_mocks::common_matchers::EqualMatcher< double >, qt_mocks::common_matchers::EqualMatcher< float >, qt_mocks::common_matchers::EqualMatcher< float >, qt_mocks::common_matchers::EqualMatcher< long double >, qt_mocks::common_matchers::EqualMatcher< long double >, qt_mocks::common_matchers::EqualMatcher<::QString >, qt_mocks::common_matchers::EqualMatcher<::QString >, qt_mocks::common_matchers::GreaterThanEqualMatcher< ValueType >, qt_mocks::common_matchers::GreaterThanMatcher< ValueType >, qt_mocks::common_matchers::IsEmptyMatcher< Container >, qt_mocks::common_matchers::LessThanEqualMatcher< ValueType >, qt_mocks::common_matchers::LessThanMatcher< ValueType >, qt_mocks::common_matchers::MemberFunctionMatcher< ClassType, MemberFunctionType, MatcherType >, qt_mocks::common_matchers::MemberVariableMatcher< ClassType, MemberVariableType, MatcherType >, qt_mocks::common_matchers::NegationMatcher< ValueType >, qt_mocks::common_matchers::NotEqualMatcher< ValueType >, and qt_mocks::common_matchers::SizeIsMatcher< Container >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ description()

template<typename ValueType>
virtual::QString qt_mocks::common_matchers::Matcher< ValueType >::description ( const ValueType & actual) const
nodiscardpure virtual

When implemented, provides a textual description of the current match result.

It generates a human-readable description of the comparison between the expected and actual values, enabling easier debugging and clear understanding of matcher evaluations.

Parameters
actualThe actual value being matched against.
Returns
The detailed description of the match operation's expectation for successful pass.

Implemented in qt_mocks::common_matchers::AllOfMatcher< ValueType, MatcherTypes >, qt_mocks::common_matchers::AnyOfMatcher< ValueType, MatcherTypes >, qt_mocks::common_matchers::BetweenBeginInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenEndInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenExclusiveMatcher< ValueType >, qt_mocks::common_matchers::BetweenInclusiveMatcher< ValueType >, qt_mocks::common_matchers::BooleanMatcher, qt_mocks::common_matchers::ContainsStringMatcher< ValueType >, qt_mocks::common_matchers::EqualMatcher< ValueType >, qt_mocks::common_matchers::EqualMatcher< double >, qt_mocks::common_matchers::EqualMatcher< double >, qt_mocks::common_matchers::EqualMatcher< float >, qt_mocks::common_matchers::EqualMatcher< float >, qt_mocks::common_matchers::EqualMatcher< long double >, qt_mocks::common_matchers::EqualMatcher< long double >, qt_mocks::common_matchers::EqualMatcher<::QString >, qt_mocks::common_matchers::EqualMatcher<::QString >, qt_mocks::common_matchers::GreaterThanEqualMatcher< ValueType >, qt_mocks::common_matchers::GreaterThanMatcher< ValueType >, qt_mocks::common_matchers::IsEmptyMatcher< Container >, qt_mocks::common_matchers::LessThanEqualMatcher< ValueType >, qt_mocks::common_matchers::LessThanMatcher< ValueType >, qt_mocks::common_matchers::MemberFunctionMatcher< ClassType, MemberFunctionType, MatcherType >, qt_mocks::common_matchers::MemberVariableMatcher< ClassType, MemberVariableType, MatcherType >, qt_mocks::common_matchers::NegationMatcher< ValueType >, qt_mocks::common_matchers::NotEqualMatcher< ValueType >, and qt_mocks::common_matchers::SizeIsMatcher< Container >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expected()

template<typename ValueType>
const ExpectedValue< ValueType > & qt_mocks::common_matchers::Matcher< ValueType >::expected ( ) const
nodiscardnoexcept

Retrieves the expected value of the matcher.

Returns
The expected value.
Here is the caller graph for this function:

◆ hasExpected()

template<typename ValueType>
bool qt_mocks::common_matchers::Matcher< ValueType >::hasExpected ( ) const
nodiscardnoexcept

Checks if an expected value is set for the matcher.

Returns
True if the matcher has an expected value, otherwise false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename ValueType>
Matcher & qt_mocks::common_matchers::Matcher< ValueType >::operator= ( const Matcher< ValueType > & other)

Move assignment that changes the object by transferring the state from another instance.

Parameters
otherThe instance to be moved from.
Postcondition
The current instance now contains the values of the supplied object.
Here is the call graph for this function:

◆ operator=() [2/2]

template<typename ValueType>
Matcher & qt_mocks::common_matchers::Matcher< ValueType >::operator= ( Matcher< ValueType > && other)
noexcept

Move assignment that changes the object by transferring the state from another instance.

Parameters
otherThe instance to be moved from. The object is left in an unspecified state.
Postcondition
The current instance now owns the resources of the moved-from object.
Here is the call graph for this function: