@@ -156,6 +156,10 @@ TEST_CASE("Sharing map interface", "[core][util]")
156
156
REQUIRE (sm.has_key (" i" ));
157
157
REQUIRE (sm.has_key (" j" ));
158
158
REQUIRE (!sm.has_key (" k" ));
159
+
160
+ cbmc_invariants_should_throwt invariants_throw;
161
+
162
+ REQUIRE_THROWS (sm.insert (" i" , " 4" ));
159
163
}
160
164
161
165
SECTION (" Replace and update elements" )
@@ -172,17 +176,36 @@ TEST_CASE("Sharing map interface", "[core][util]")
172
176
auto r2 = sm.find (" i" );
173
177
REQUIRE (r2);
174
178
REQUIRE (r2->get () == " 90" );
179
+ }
180
+
181
+ SECTION (" Replace and update elements errors" )
182
+ {
183
+ sharing_map_standardt sm;
184
+ fill (sm);
185
+
186
+ sharing_map_error_checkt debug_sm;
187
+ fill (debug_sm);
175
188
189
+ cbmc_invariants_should_throwt invariants_throw;
190
+
191
+ SECTION (" Replace non-existing" )
176
192
{
177
- cbmc_invariants_should_throwt invariants_throw;
178
- sharing_map_error_checkt debug_sm;
179
- fill (debug_sm);
180
- REQUIRE_NOTHROW (
181
- debug_sm.update (" i" , [](std::string &str) { str += " 1" ; }));
182
- REQUIRE_THROWS (debug_sm.update (" i" , [](std::string &str) {}));
193
+ REQUIRE_THROWS (sm.replace (" x" , " 0" ));
194
+ }
183
195
184
- REQUIRE_NOTHROW (debug_sm.replace (" i" , " abc" ));
185
- REQUIRE_THROWS (debug_sm.replace (" i" , " abc" ));
196
+ SECTION (" Update non-existing" )
197
+ {
198
+ REQUIRE_THROWS (sm.update (" x" , [](std::string &str) {}));
199
+ }
200
+
201
+ SECTION (" Replace with equal" )
202
+ {
203
+ REQUIRE_THROWS (debug_sm.replace (" i" , " 0" ));
204
+ }
205
+
206
+ SECTION (" Update with equal" )
207
+ {
208
+ REQUIRE_THROWS (debug_sm.update (" i" , [](std::string &str) {}));
186
209
}
187
210
}
188
211
@@ -246,6 +269,10 @@ TEST_CASE("Sharing map interface", "[core][util]")
246
269
247
270
sm3.erase (" i" );
248
271
REQUIRE (!sm3.has_key (" i" ));
272
+
273
+ cbmc_invariants_should_throwt invariants_throw;
274
+
275
+ REQUIRE_THROWS (sm3.erase (" x" ));
249
276
}
250
277
}
251
278
@@ -621,35 +648,3 @@ TEST_CASE("Sharing map sharing stats", "[core][util]")
621
648
}
622
649
#endif
623
650
}
624
-
625
- TEST_CASE (" Sharing map replace non-existing" , " [.]" )
626
- {
627
- sharing_map_standardt sm;
628
- fill (sm);
629
-
630
- sm.replace (" x" , " 0" );
631
- }
632
-
633
- TEST_CASE (" Sharing map replace with equal value" , " [.]" )
634
- {
635
- sharing_map_error_checkt sm;
636
-
637
- sm.insert (" i" , " 0" );
638
- sm.replace (" i" , " 0" );
639
- }
640
-
641
- TEST_CASE (" Sharing map insert existing" , " [.]" )
642
- {
643
- sharing_map_standardt sm;
644
- fill (sm);
645
-
646
- sm.insert (" i" , " 4" );
647
- }
648
-
649
- TEST_CASE (" Sharing map erase non-existing" , " [.]" )
650
- {
651
- sharing_map_standardt sm;
652
- fill (sm);
653
-
654
- sm.erase (" x" );
655
- }
0 commit comments