4 #include <unordered_map>
7 #include <boost/throw_exception.hpp>
15 using Ptr = std::shared_ptr<IMatcher>;
23 ObjectMatcher(
const std::unordered_map<std::string, IMatcher::Ptr>& i_fields) : fields { i_fields } {};
25 virtual std::string
getJson()
const;
28 std::unordered_map<std::string, IMatcher::Ptr> fields;
37 virtual std::string
getJson()
const;
40 std::optional<long> value;
49 virtual std::string
getJson()
const;
52 std::optional<double> value;
60 virtual std::string
getJson()
const;
72 virtual std::string
getJson()
const;
75 std::optional<T> value;
83 virtual std::string
getJson()
const;
86 std::ostringstream stringStream;
87 stringStream << value;
88 return stringStream.str();
98 DateTimeMatcher(
const std::string& f,
const std::string& e) : format { f }, example { e } {};
100 virtual std::string
getJson()
const;
103 std::string format, example;
109 DateMatcher(
const std::string& f,
const std::string& e) : format { f }, example { e } {};
111 virtual std::string
getJson()
const;
114 std::string format, example;
120 TimeMatcher(
const std::string& f,
const std::string& e) : format { f }, example { e } {};
122 virtual std::string
getJson()
const;
125 std::string format, example;
131 RegexMatcher(
const std::string& r,
const std::string& e) : regex { r }, example { e } {};
133 virtual std::string
getJson()
const;
136 virtual std::string
as_regex()
const {
return regex; };
139 std::string regex, example;
149 virtual std::string
getJson()
const;
153 std::optional<int> min;
154 std::optional<int> max;
162 virtual std::string
getJson()
const;
165 std::vector<IMatcher::Ptr> variants;
173 virtual std::string
getJson()
const;
184 virtual std::string
getJson()
const;
195 virtual std::string
getJson()
const;
205 virtual std::string
getJson()
const;
213 virtual std::string
getJson()
const;
218 UrlMatcher(
const std::string& b,
const std::vector<IMatcher::Ptr>& f) : basePath { b }, pathFragments { f } {};
220 virtual std::string
getJson()
const;
223 std::string basePath;
224 std::vector<IMatcher::Ptr> pathFragments;
522 IMatcher::Ptr Url(
const std::string& basePath,
const std::vector<IMatcher::Ptr>& pathFragments);
Definition: matchers.h:158
ArrayContainsMatcher(const std::vector< IMatcher::Ptr > &i_variants)
Definition: matchers.h:160
virtual std::string getJson() const
Definition: matchers.cpp:537
Definition: matchers.h:106
DateMatcher(const std::string &f, const std::string &e)
Definition: matchers.h:109
virtual std::string getJson() const
Definition: matchers.cpp:312
DateMatcher(const std::string &f)
Definition: matchers.h:108
Definition: matchers.h:95
virtual std::string getJson() const
Definition: matchers.cpp:291
DateTimeMatcher(const std::string &f, const std::string &e)
Definition: matchers.h:98
DateTimeMatcher(const std::string &f)
Definition: matchers.h:97
Definition: matchers.h:43
DecimalMatcher(float v)
Definition: matchers.h:46
DecimalMatcher()
Definition: matchers.h:45
virtual std::string getJson() const
Definition: matchers.cpp:248
DecimalMatcher(double v)
Definition: matchers.h:47
Definition: matchers.h:142
EachlikeMatcher(int e, IMatcher::Ptr t)
Definition: matchers.h:145
virtual std::string getJson() const
Definition: matchers.cpp:382
EachlikeMatcher(int e, int m, IMatcher::Ptr t)
Definition: matchers.h:146
EachlikeMatcher(int e, int m, int mx, IMatcher::Ptr t)
Definition: matchers.h:147
EachlikeMatcher(IMatcher::Ptr t)
Definition: matchers.h:144
Definition: matchers.h:79
virtual std::string getJson() const
Definition: matchers.cpp:284
virtual std::string as_example() const
Definition: matchers.h:85
EqualsMatcher(T v)
Definition: matchers.h:81
Definition: matchers.h:168
HexadecimalMatcher(const std::string &hex)
Definition: matchers.h:171
HexadecimalMatcher()
Definition: matchers.h:170
virtual std::string getJson() const
Definition: matchers.cpp:414
Definition: matchers.h:13
std::shared_ptr< IMatcher > Ptr
Definition: matchers.h:15
virtual std::string getJson() const =0
virtual std::string as_example() const
Definition: matchers.h:17
virtual std::string as_regex() const
Definition: matchers.h:18
Definition: matchers.h:179
IPAddressMatcher(const std::string &address)
Definition: matchers.h:182
virtual std::string getJson() const
Definition: matchers.cpp:443
IPAddressMatcher()
Definition: matchers.h:181
Definition: matchers.h:201
IncludesMatcher(const std::string &v)
Definition: matchers.h:203
virtual std::string getJson() const
Definition: matchers.cpp:492
Definition: matchers.h:31
IntegerMatcher()
Definition: matchers.h:33
IntegerMatcher(int v)
Definition: matchers.h:35
IntegerMatcher(long v)
Definition: matchers.h:34
virtual std::string getJson() const
Definition: matchers.cpp:236
Definition: matchers.h:211
virtual std::string getJson() const
Definition: matchers.cpp:499
Definition: matchers.h:67
NumberMatcher()
Definition: matchers.h:69
NumberMatcher(T v)
Definition: matchers.h:70
virtual std::string getJson() const
Definition: matchers.cpp:270
Definition: matchers.h:21
ObjectMatcher(const std::unordered_map< std::string, IMatcher::Ptr > &i_fields)
Definition: matchers.h:23
virtual std::string getJson() const
Definition: matchers.cpp:226
Definition: matchers.h:128
RegexMatcher(const std::string &r, const std::string &e)
Definition: matchers.h:131
virtual std::string as_regex() const
Definition: matchers.h:136
RegexMatcher(const std::string &r)
Definition: matchers.h:130
virtual std::string as_example() const
Definition: matchers.h:135
virtual std::string getJson() const
Definition: matchers.cpp:354
Definition: matchers.h:117
TimeMatcher(const std::string &f)
Definition: matchers.h:119
virtual std::string getJson() const
Definition: matchers.cpp:333
TimeMatcher(const std::string &f, const std::string &e)
Definition: matchers.h:120
Definition: matchers.h:56
TypeMatcher(T v)
Definition: matchers.h:58
virtual std::string getJson() const
Definition: matchers.cpp:262
Definition: matchers.h:216
virtual std::string getJson() const
Definition: matchers.cpp:505
UrlMatcher(const std::string &b, const std::vector< IMatcher::Ptr > &f)
Definition: matchers.h:218
Definition: matchers.h:190
UuidMatcher()
Definition: matchers.h:192
UuidMatcher(const std::string &uuid)
Definition: matchers.h:193
virtual std::string getJson() const
Definition: matchers.cpp:472
Definition: matchers.cpp:8
IMatcher::Ptr NullValue()
Definition: matchers.cpp:210
IMatcher::Ptr MinArrayLike(int min, const IMatcher::Ptr obj)
Definition: matchers.cpp:162
IMatcher::Ptr Uuid(const std::string &example)
Definition: matchers.cpp:146
IMatcher::Ptr Date(const std::string &format, const std::string &example)
Definition: matchers.cpp:58
IMatcher::Ptr AtLeastOneLike(const IMatcher::Ptr obj)
Definition: matchers.cpp:90
IMatcher::Ptr Url(const std::string &basePath, const std::vector< IMatcher::Ptr > &pathFragments)
Definition: matchers.cpp:214
IMatcher::Ptr EachLike(const IMatcher::Ptr obj)
Definition: matchers.cpp:82
IMatcher::Ptr Like(long value)
Definition: matchers.cpp:26
IMatcher::Ptr Integer(long value)
Definition: matchers.cpp:14
IMatcher::Ptr IncludesStr(const std::string &value)
Definition: matchers.cpp:206
IMatcher::Ptr Time(const std::string &format, const std::string &example)
Definition: matchers.cpp:66
IMatcher::Ptr Numeric(int example)
Definition: matchers.cpp:114
IMatcher::Ptr HexValue(const std::string &example)
Definition: matchers.cpp:98
IMatcher::Ptr Object(const std::unordered_map< std::string, IMatcher::Ptr > &fields)
Definition: matchers.cpp:10
IMatcher::Ptr DateTime(const std::string &format, const std::string &example)
Definition: matchers.cpp:50
IMatcher::Ptr AtMostLike(int max, const IMatcher::Ptr obj)
Definition: matchers.cpp:154
IMatcher::Ptr ArrayContaining(const std::vector< IMatcher::Ptr > &variants)
Definition: matchers.cpp:222
IMatcher::Ptr ConstrainedArrayLike(int min, int max, const IMatcher::Ptr obj)
Definition: matchers.cpp:170
IMatcher::Ptr Matching(const std::string ®ex, const std::string &example)
Definition: matchers.cpp:74
IMatcher::Ptr IPAddress(const std::string &example)
Definition: matchers.cpp:106
IMatcher::Ptr Decimal(float example)
Definition: matchers.cpp:134
IMatcher::Ptr EqualTo(int value)
Definition: matchers.cpp:178