Hamcrest-Qt  0.0.1
Hamcrest matchers for C++/Qt
 All Classes Namespaces Functions
Classes | Functions
HamcrestQt Namespace Reference

Hamcrest-Qt is a library of matchers, which can be combined in to create flexible expressions of intent in tests. More...

Classes

class  BaseDescription
 A Description that is stored as a string. More...
 
class  BaseMatcher
 BaseClass for all Matcher implementations. More...
 
class  Description
 A description of a Matcher. More...
 
class  DiagnosingMatcher
 
class  AllOf
 Calculates the logical conjunction of multiple matchers. More...
 
class  AnyOf
 Calculates the logical disjunction of multiple matchers. More...
 
class  Is
 Decorates another Matcher, retaining the behaviour but allowing tests to be slightly more expressive. More...
 
class  IsEqual
 Is the value equal to another value, as tested by the operator==() method? More...
 
class  IsNot
 Calculates the logical negation of a matcher. More...
 
class  ShortcutCombination
 
class  StringContains
 Tests if the argument is a string that contains a substring. More...
 
class  StringEndsWith
 Tests if the argument is a string that ends with a substring. More...
 
class  StringStartsWith
 Tests if the argument is a string that starts with a substring. More...
 
class  SubstringMatcher
 
class  Matcher
 A matcher over acceptable values. More...
 
class  MatcherAssert
 
class  SelfDescribing
 The ability of an object to describe itself. More...
 
class  StringDescription
 A Description that is stored as a string. More...
 

Functions

template<typename T >
QSharedPointer< Matcher< T > > allOf (const QList< QSharedPointer< Matcher< T > > > &matchers)
 Creates a matcher that matches if the examined object matches ALL of the specified matchers. More...
 
template<typename T >
QSharedPointer< Matcher< T > > allOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second)
 
template<typename T >
QSharedPointer< Matcher< T > > allOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third)
 
template<typename T >
QSharedPointer< Matcher< T > > allOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth)
 
template<typename T >
QSharedPointer< Matcher< T > > allOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth, const QSharedPointer< Matcher< T > > &fifth)
 
template<typename T >
QSharedPointer< Matcher< T > > allOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth, const QSharedPointer< Matcher< T > > &fifth, const QSharedPointer< Matcher< T > > &sixth)
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QList< QSharedPointer< Matcher< T > > > &matchers)
 Creates a matcher that matches if the examined object matches ANY of the specified matchers. More...
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second)
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third)
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth)
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth, const QSharedPointer< Matcher< T > > &fifth)
 
template<typename T >
QSharedPointer< Matcher< T > > anyOf (const QSharedPointer< Matcher< T > > &first, const QSharedPointer< Matcher< T > > &second, const QSharedPointer< Matcher< T > > &third, const QSharedPointer< Matcher< T > > &fourth, const QSharedPointer< Matcher< T > > &fifth, const QSharedPointer< Matcher< T > > &sixth)
 
template<typename T >
bool AreEqual (const T &actual, const T &expected)
 
bool AreEqual (const char *actual, const char *expected)
 
template<typename T >
QSharedPointer< Matcher< T > > is (const QSharedPointer< Matcher< T > > &matcher)
 Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive. More...
 
template<typename T >
QSharedPointer< Matcher< T > > is (const T &operand)
 
QSharedPointer< Matcher< const
char * > > 
is (const char *operand)
 
template<typename T >
QSharedPointer< Matcher< T > > equalTo (const T &operand)
 
QSharedPointer< Matcher< const
char * > > 
equalTo (const char operand[])
 
template<typename T >
QSharedPointer< Matcher< T > > _not (const QSharedPointer< Matcher< T > > &matcher)
 Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match. More...
 
template<typename T >
QSharedPointer< Matcher< T > > _not (const T &operand)
 A shortcut to the frequently used not(equalTo(x)). More...
 
QSharedPointer< Matcher< const
char * > > 
_not (const char *operand)
 
QSharedPointer< Matcher
< QString > > 
containsString (const QString &substring)
 Creates a matcher that matches if the examined QString contains the specified QString anywhere. More...
 
QSharedPointer< Matcher
< QString > > 
containsString (const char *substring)
 
QSharedPointer< Matcher
< QString > > 
endsWith (const QString &suffix)
 Creates a matcher that matches if the examined QString ends with the specified QString. More...
 
QSharedPointer< Matcher
< QString > > 
endsWith (const char *suffix)
 
QSharedPointer< Matcher
< QString > > 
startsWith (const QString &prefix)
 Creates a matcher that matches if the examined QString starts with the specified QString. More...
 
QSharedPointer< Matcher
< QString > > 
startsWith (const char *prefix)
 

Detailed Description

Hamcrest-Qt is a library of matchers, which can be combined in to create flexible expressions of intent in tests.

Function Documentation

template<typename T >
QSharedPointer<Matcher<T> > HamcrestQt::_not ( const QSharedPointer< Matcher< T > > &  matcher)

Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.

For example:

assertThat(cheese, is(not(equalTo(smelly))))
Parameters
matcherthe matcher whose sense should be inverted
template<typename T >
QSharedPointer<Matcher<T> > HamcrestQt::_not ( const T &  operand)

A shortcut to the frequently used not(equalTo(x)).

For example:

assertThat(cheese, is(not(smelly)))

instead of:

assertThat(cheese, is(not(equalTo(smelly))))
Parameters
valuethe value that any examined object should not equal
template<typename T >
QSharedPointer<Matcher<T> > HamcrestQt::allOf ( const QList< QSharedPointer< Matcher< T > > > &  matchers)

Creates a matcher that matches if the examined object matches ALL of the specified matchers.

For example:

assertThat("myValue", allOf(startsWith("my"), containsString("Val")))
template<typename T >
QSharedPointer<Matcher<T> > HamcrestQt::anyOf ( const QList< QSharedPointer< Matcher< T > > > &  matchers)

Creates a matcher that matches if the examined object matches ANY of the specified matchers.

For example:

assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))
QSharedPointer<Matcher<QString> > HamcrestQt::containsString ( const QString &  substring)
inline

Creates a matcher that matches if the examined QString contains the specified QString anywhere.

For example:

ASSERT_THAT("myStringOfNote", containsString("ring"));
Parameters
substringthe substring that the returned matcher will expect to find within any examined string
QSharedPointer<Matcher<QString> > HamcrestQt::endsWith ( const QString &  suffix)
inline

Creates a matcher that matches if the examined QString ends with the specified QString.

For example:

assertThat("myStringOfNote", endsWith("Note"))
Parameters
suffixthe substring that the returned matcher will expect at the end of any examined string
template<typename T >
QSharedPointer<Matcher<T> > HamcrestQt::is ( const QSharedPointer< Matcher< T > > &  matcher)

Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.

For example:

assertThat(cheese, is(equalTo(smelly)))

instead of:

assertThat(cheese, equalTo(smelly))
QSharedPointer<Matcher<QString> > HamcrestQt::startsWith ( const QString &  prefix)
inline

Creates a matcher that matches if the examined QString starts with the specified QString.

For example:

assertThat("myStringOfNote", startsWith("my"))
Parameters
prefixthe substring that the returned matcher will expect at the start of any examined string