Hamcrest-Qt  0.0.1
Hamcrest matchers for C++/Qt
 All Classes Namespaces Functions
stringstartswith.h
1 #ifndef HAMCRESTQT_STRINGSTARTSWITH_H
2 #define HAMCRESTQT_STRINGSTARTSWITH_H
3 
4 #include <QSharedPointer>
5 
6 #include "matcher.h"
7 #include "substringmatcher.h"
8 
9 namespace HamcrestQt {
10 
15 {
16 public:
17  explicit StringStartsWith(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> > startsWith(const QString &prefix)
35 {
36  return QSharedPointer<Matcher<QString> >(new StringStartsWith(prefix));
37 }
38 
39 // template specialization for c-style string
40 inline QSharedPointer<Matcher<QString> > startsWith(const char *prefix)
41 {
42  return QSharedPointer<Matcher<QString> >(new StringStartsWith(QString(prefix)));
43 }
44 
45 } // namespace HamcrestQt
46 
47 #endif // HAMCRESTQT_STRINGSTARTSWITH
Tests if the argument is a string that starts with a substring.
Definition: stringstartswith.h:14
QSharedPointer< Matcher< QString > > startsWith(const QString &prefix)
Creates a matcher that matches if the examined QString starts with the specified QString.
Definition: stringstartswith.h:34
Definition: substringmatcher.h:9