Qt-Mocks 0.8.0-alpha.9
Mocking library using Qt Test inspired by Google Test
 
Loading...
Searching...
No Matches
qt_mocks::ValueGenerator< ReturnType > Class Template Referencefinal

Encapsulates a value to be generated by a mocked function. More...

#include <Expectation.hpp>

Collaboration diagram for qt_mocks::ValueGenerator< ReturnType >:

Public Member Functions

 ValueGenerator (std::function< ReturnType()> generator)
 Full initialisation constructor that initialises the functor that generates a value for a mocked function.
 
ReturnType operator() () const
 

Detailed Description

template<typename ReturnType>
class qt_mocks::ValueGenerator< ReturnType >

Encapsulates a value to be generated by a mocked function.

Template Parameters
ReturnTypeThe type of the value to be generated.

Constructor & Destructor Documentation

◆ ValueGenerator()

template<typename ReturnType>
qt_mocks::ValueGenerator< ReturnType >::ValueGenerator ( std::function< ReturnType()> generator)
explicit

Full initialisation constructor that initialises the functor that generates a value for a mocked function.

Parameters
generatorThe functor that creates the desired return value upon each invocation.

Member Function Documentation

◆ operator()()

template<typename ReturnType>
ReturnType qt_mocks::ValueGenerator< ReturnType >::operator() ( ) const

Invokes the value generator and returns a generated value.

Returns
A generated value of the specified ReturnType.