8
8
#include < random>
9
9
#include < string>
10
10
#include < map>
11
+ #include < set>
11
12
#include < variant>
12
13
#include < vector>
13
14
14
15
namespace antithesis {
15
- inline const char * SDK_VERSION = " 0.3.0 " ;
16
+ inline const char * SDK_VERSION = " 0.3.1 " ;
16
17
inline const char * PROTOCOL_VERSION = " 1.0.0" ;
17
18
18
19
struct LocalRandom {
@@ -436,6 +437,13 @@ namespace antithesis {
436
437
assert_impl (cond, message, details, location_info, hit, must_hit, assert_type, display_type, id);
437
438
}
438
439
440
+ typedef std::set<std::string> CatalogEntryTracker;
441
+
442
+ inline CatalogEntryTracker& get_catalog_entry_tracker () {
443
+ static CatalogEntryTracker catalog_entry_tracker;
444
+ return catalog_entry_tracker;
445
+ }
446
+
439
447
struct Assertion {
440
448
AssertionState state;
441
449
AssertionType type;
@@ -448,13 +456,17 @@ namespace antithesis {
448
456
}
449
457
450
458
void add_to_catalog () const {
451
- const bool condition = (type == REACHABLE_ASSERTION ? true : false );
452
- const bool hit = false ;
453
- const char * assert_type = get_assert_type_string (type);
454
- const bool must_hit = get_must_hit (type);
455
- const char * display_type = get_display_type_string (type);
456
459
std::string id = make_key (message, location);
457
- assert_impl (condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str ());
460
+ CatalogEntryTracker& tracker = get_catalog_entry_tracker ();
461
+ if (!tracker.contains (id)) {
462
+ tracker.insert (id);
463
+ const bool condition = (type == REACHABLE_ASSERTION ? true : false );
464
+ const bool hit = false ;
465
+ const char * assert_type = get_assert_type_string (type);
466
+ const bool must_hit = get_must_hit (type);
467
+ const char * display_type = get_display_type_string (type);
468
+ assert_impl (condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str ());
469
+ }
458
470
}
459
471
460
472
[[clang::always_inline]] inline void check_assertion (bool cond, const JSON& details) {
@@ -478,7 +490,7 @@ namespace antithesis {
478
490
emit = true ;
479
491
state.true_not_seen = false ; // TODO: is the race OK?
480
492
}
481
-
493
+
482
494
if (emit) {
483
495
const bool hit = true ;
484
496
const char * assert_type = get_assert_type_string (type);
0 commit comments