File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1
1
SRC = \
2
2
call_graph_test_utils.cpp \
3
3
free_form_cmdline.cpp \
4
+ invariant.cpp \
4
5
message.cpp \
5
6
require_expr.cpp \
6
7
require_symbol.cpp \
Original file line number Diff line number Diff line change
1
+ // / Author: Diffblue Ltd.
2
+
3
+ #include " invariant.h"
4
+
5
+ #include < utility>
6
+
7
+ invariant_failure_containingt invariant_failure_containing (std::string expected)
8
+ {
9
+ return invariant_failure_containingt{std::move (expected)};
10
+ }
11
+
12
+ invariant_failure_containingt::invariant_failure_containingt (
13
+ std::string expected)
14
+ : expected{std::move (expected)}
15
+ {
16
+ }
17
+
18
+ bool invariant_failure_containingt::match (
19
+ const invariant_failedt &exception) const
20
+ {
21
+ const std::string what = exception.what ();
22
+ return what.find (expected) != std::string::npos;
23
+ }
24
+
25
+ std::string invariant_failure_containingt::describe () const
26
+ {
27
+ return std::string{" invariant_failedt with `.what' containing - \" " } +
28
+ expected + " \" " ;
29
+ }
Original file line number Diff line number Diff line change
1
+ // / Author: Diffblue Ltd.
2
+
3
+ #ifndef CPROVER_TESTING_UTILS_INVARIANT_H
4
+ #define CPROVER_TESTING_UTILS_INVARIANT_H
5
+
6
+ #include < testing-utils/use_catch.h>
7
+ #include < util/invariant.h>
8
+
9
+ #include < string>
10
+
11
+ class invariant_failure_containingt
12
+ : public Catch::MatcherBase<invariant_failedt>
13
+ {
14
+ public:
15
+ explicit invariant_failure_containingt (std::string expected);
16
+ bool match (const invariant_failedt &exception) const override ;
17
+ std::string describe () const override ;
18
+
19
+ private:
20
+ std::string expected;
21
+ };
22
+
23
+ // / Returns a matcher which matches an invariant_failedt exception, where the
24
+ // / `.what()` returns a string containing \p expected.
25
+ invariant_failure_containingt
26
+ invariant_failure_containing (std::string expected);
27
+
28
+ #endif // CPROVER_TESTING_UTILS_INVARIANT_H
You can’t perform that action at this time.
0 commit comments