Hamcrest-Qt  0.0.1
Hamcrest matchers for C++/Qt
 All Classes Namespaces Functions
basematcher.h
1 #ifndef HAMCRESTQT_BASEMATCHER_H
2 #define HAMCRESTQT_BASEMATCHER_H
3 
4 #include "matcher.h"
5 
6 #include "description.h"
7 #include "stringdescription.h"
8 
9 namespace HamcrestQt {
10 
16 template <typename T>
17 class BaseMatcher : public Matcher<T>
18 {
19 public:
20  virtual void describeMismatch(const T &item, Description &description) const
21  {
22  description.appendText(QStringLiteral("was ")).appendValue(item);
23  }
24 
25  virtual QString toString() const
26  {
27  return StringDescription::toString(*this);
28  }
29 };
30 
31 } // namespace HamcrestQt
32 
33 #endif // HAMCRESTQT_BASEMATCHER_H
virtual QString toString() const
Returns the description as a string.
Definition: stringdescription.cpp:11
A description of a Matcher.
Definition: description.h:17
virtual void describeMismatch(const T &item, Description &description) const
Generate a description of why the matcher has not accepted the item.
Definition: basematcher.h:20
A matcher over acceptable values.
Definition: matcher.h:21
Description & appendValue(const T &value)
Appends an arbitrary value to the description.
Definition: description.h:90
BaseClass for all Matcher implementations.
Definition: basematcher.h:17
virtual Description & appendText(const QString &text)=0
Appends some plain text to the description.