Hamcrest-Qt  0.0.1
Hamcrest matchers for C++/Qt
 All Classes Namespaces Functions
stringendswith.h
1 #ifndef HAMCRESTQT_STRINGENDSWITH_H
2 #define HAMCRESTQT_STRINGENDSWITH_H
3 
4 #include <QSharedPointer>
5 
6 #include "matcher.h"
7 #include "substringmatcher.h"
8 
9 namespace HamcrestQt {
10 
15 {
16 public:
17  explicit StringEndsWith(const QString &substring) : SubstringMatcher(substring) {}
18 
19 protected:
20  virtual bool evalSubstringOf(const QString &str) const;
21  virtual QString relationship() const;
22 };
23 
34 inline QSharedPointer<Matcher<QString> > endsWith(const QString &suffix)
35 {
36  return QSharedPointer<Matcher<QString> >(new StringEndsWith(suffix));
37 }
38 
39 // template specialization for c-style string
40 inline QSharedPointer<Matcher<QString> > endsWith(const char *suffix)
41 {
42  return QSharedPointer<Matcher<QString> >(new StringEndsWith(QString(suffix)));
43 }
44 
45 } // namespace HamcrestQt
46 
47 #endif // HAMCRESTQT_STRINGENDSWITH_H
Tests if the argument is a string that ends with a substring.
Definition: stringendswith.h:14
QSharedPointer< Matcher< QString > > endsWith(const QString &suffix)
Creates a matcher that matches if the examined QString ends with the specified QString.
Definition: stringendswith.h:34
Definition: substringmatcher.h:9