Skip to content

Commit a02c9f4

Browse files
Copilotachamayou
andcommitted
Restore retract_to(max_index()) test in retract.cpp with corrected assertion
Restore the deleted test lines that verify retract_to(max_index()) is a no-op. The original code had a buggy assertion (comparing max_index() against loop index i, which could diverge due to prior retractions) and a missing throw keyword. Fix both: save max_index before the call and verify it's unchanged after. Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
1 parent e10837a commit a02c9f4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/retract.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ int main()
5151
mt.retract_to(mt.max_index() - 1);
5252
total_retractions++;
5353
mt.insert(hashes[i]);
54+
const auto max_before = mt.max_index();
55+
mt.retract_to(mt.max_index());
56+
if (mt.max_index() != max_before)
57+
{
58+
throw std::runtime_error("retract_to(max_index()) changed max_index");
59+
}
5460
}
5561

5662
if ((std::rand() / (double)RAND_MAX) > 0.95)

0 commit comments

Comments
 (0)