MCPcopy
hub / github.com/austingebauer/go-leetcode / TestLRUCache_7

Function TestLRUCache_7

lru_cache_146/solution_test.go:92–101  ·  view source on GitHub ↗

* ["LRUCache","get","put","get","put","put","get","get"] [[2],[2],[2,6],[1],[1,5],[1,2],[1],[2]] */

(t *testing.T)

Source from the content-addressed store, hash-verified

90[[2],[2],[2,6],[1],[1,5],[1,2],[1],[2]]
91*/
92func TestLRUCache_7(t *testing.T) {
93 cache := Constructor(2)
94 assert.Equal(t, -1, cache.Get(2))
95 cache.Put(2, 6)
96 assert.Equal(t, -1, cache.Get(1))
97 cache.Put(1, 5)
98 cache.Put(1, 2) // evicts 2->6
99 assert.Equal(t, 2, cache.Get(1))
100 assert.Equal(t, 6, cache.Get(2))
101}
102
103/*
104["LRUCache","put","put","put","put","get","get","get","get","put","get","get","get","get","get"]

Callers

nothing calls this directly

Calls 3

PutMethod · 0.80
ConstructorFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected