diff options
| author | 2026-06-12 10:05:25 +0000 | |
|---|---|---|
| committer | 2026-06-12 10:05:25 +0000 | |
| commit | 74399c78e79f59cdac36deac19e35c6ea7c0b77d (patch) | |
| tree | cb00b0597b86fda7e36dc221a4bdd9a03899dc0a /internal | |
| parent | internal/mru: Append keys before the survivors (diff) | |
internal/mru: Test that sync places new keys first
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/mru/order_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/mru/order_test.go b/internal/mru/order_test.go index 8b667e77..bf0d4f2e 100644 --- a/internal/mru/order_test.go +++ b/internal/mru/order_test.go @@ -58,6 +58,22 @@ func TestSyncDropsAbsentAndKeepsSurvivorOrder(t *testing.T) { } } +func TestSyncPlacesNewKeysFirst(t *testing.T) { + t.Parallel() + + order := mru.New[string]() + order.Sync(set("a", "b")) + + order.Touch("a") + order.Touch("b") + + order.Sync(set("a", "b", "z")) + + if got, want := order.Keys(), []string{"z", "b", "a"}; !slices.Equal(got, want) { + t.Fatalf("after Sync, order = %v, want %v", got, want) + } +} + func TestTouchAbsentIsNoOp(t *testing.T) { t.Parallel() |
