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