File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,9 @@ CBMC_NORETURN void report_invariant_failure(
514514#define DATA_INVARIANT_STRUCTURED (CONDITION, TYPENAME, ...) \
515515 EXPAND_MACRO (INVARIANT_STRUCTURED(CONDITION, TYPENAME, __VA_ARGS__))
516516
517+ #define UNIMPLEMENTED_FEATURE (FEATURE ) \
518+ INVARIANT (false , std::string{" Reached unimplemented " } + (FEATURE))
519+
517520// Legacy annotations
518521
519522// The following should not be used in new code and are only intended
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ SRC += analyses/ai/ai.cpp \
114114 util/interval_union.cpp \
115115 util/irep.cpp \
116116 util/irep_sharing.cpp \
117+ util/invariant.cpp \
117118 util/json_array.cpp \
118119 util/json_object.cpp \
119120 util/lazy.cpp \
Original file line number Diff line number Diff line change 1+ // Author: Diffblue Ltd.
2+
3+ // / \file Tests for macros in src/util/invariant.h
4+
5+ #include < testing-utils/invariant.h>
6+ #include < testing-utils/use_catch.h>
7+
8+ #include < util/invariant.h>
9+
10+ TEST_CASE (" Using the UNIMPLEMENTED macro" , " [invariant]" )
11+ {
12+ cbmc_invariants_should_throwt invariants_throw;
13+ REQUIRE_THROWS_MATCHES (
14+ []() { UNIMPLEMENTED; }(),
15+ invariant_failedt,
16+ invariant_failure_containing (" Reason: Unimplemented" ));
17+ }
18+
19+ TEST_CASE (" Using the UNIMPLEMENTED_FEATURE macro" , " [invariant]" )
20+ {
21+ cbmc_invariants_should_throwt invariants_throw;
22+ REQUIRE_THROWS_MATCHES (
23+ []() { UNIMPLEMENTED_FEATURE (" example" ); }(),
24+ invariant_failedt,
25+ invariant_failure_containing (" Reason: Reached unimplemented example" ));
26+ }
You can’t perform that action at this time.
0 commit comments