Skip to content

Hamcrest matchers for C++/Qt

License

Notifications You must be signed in to change notification settings

cloose/Hamcrest-Qt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hamcrest-Qt

Hamcrest matchers for C++/Qt

This is an attempt to port the Java Hamcrest library to C++/Qt and make it usable with Qt Test.

Like the original library, this code is licensed under BSD 3-Clause License.

EXPERIMENTAL

This code is pre-alpha quality. DO NOT USE IN PRODUCTION CODE.

Links

Homepage
API Documentation

Supported Matchers

allOf

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

ASSERT_THAT(QStringLiteral("myValue"), allOf(startsWith("my"), containsString("Val")));

anyOf

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

ASSERT_THAT(QStringLiteral("myValue"), anyOf(startsWith("foo"), containsString("Val")));

containsString

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

ASSERT_THAT(QStringLiteral("myStringOfNote"), containsString("ring"));

endsWith

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

ASSERT_THAT(QStringLiteral("myStringOfNote"), endsWith("Note"));

equalTo

Creates a matcher that matches when the examined object is logically equal to the specified operand, as determined by calling the operator==() method on the examined object.

ASSERT_THAT(QStringLiteral("foo"), equalTo("foo"));

is

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

ASSERT_THAT(cheese, is(equalTo(smelly)));

_not

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

ASSERT_THAT(cheese, is(_not(equalTo(smelly))));

startsWith

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

ASSERT_THAT(QStringLiteral("myStringOfNote"), startsWith("my"));

About

Hamcrest matchers for C++/Qt

http://cloose.github.io/Hamcrest-Qt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published