fix: same-slot reorder is a no-op; WM_DESTROY clears card drag state; fix card_meta.h ms-rounding comment

This commit is contained in:
2026-07-27 02:47:29 -04:00
parent 439bb44e0d
commit 1585f0bbe6
4 changed files with 29 additions and 1 deletions
+23
View File
@@ -973,6 +973,28 @@ static void testReorderSampleRejectsUnknown() {
CHECK(book.pool().slots.slotOf("id-r1") == 0); // unchanged
}
// Same-slot reorder is a true no-op: returns false, no undo point triggered,
// JSON byte-identical before/after (the invariant that blocks spurious dirty-state).
static void testReorderSampleSameSlotIsNoOp() {
BankBook book;
CHECK(book.pool().index.add(sampleWith("a")) == AddResult::Added);
CHECK(book.pool().index.add(sampleWith("b")) == AddResult::Added);
CHECK(book.pool().index.add(sampleWith("c")) == AddResult::Added);
book.reconcileSlots(); // a@0, b@1, c@2
const std::string jsonBefore = book.serialize();
// Drop each card onto its own current slot — must return false every time.
CHECK(!book.reorderSample("id-a", kPoolBankId, 0));
CHECK(!book.reorderSample("id-b", kPoolBankId, 1));
CHECK(!book.reorderSample("id-c", kPoolBankId, 2));
// Slots and JSON are byte-identical — no mutation occurred.
CHECK(book.pool().slots.slotOf("id-a") == 0);
CHECK(book.pool().slots.slotOf("id-b") == 1);
CHECK(book.pool().slots.slotOf("id-c") == 2);
CHECK(book.serialize() == jsonBefore);
}
// --- BankBook L7: Alt-replace mutator ----------------------------------------
static void testReplaceSampleTakesSlotAndRemovesOccupant() {
@@ -1090,6 +1112,7 @@ int main() {
testMigrationDefaultsToInsertionOrderDense();
testOrderedSampleIdsReconcilesLazily();
testReorderSampleRejectsUnknown();
testReorderSampleSameSlotIsNoOp();
testReplaceSampleTakesSlotAndRemovesOccupant();
testReplaceSampleNonDestructiveFileStays();
testReplaceSampleRejectionsNoMutation();