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

Function TestLRUCache_1

lru_cache_146/solution_test.go:8–21  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestLRUCache_1(t *testing.T) {
9 cache := Constructor(2)
10 cache.Put(1, 1)
11 cache.Put(2, 2)
12 assert.Equal(t, 1, cache.Get(1)) // returns 1
13
14 cache.Put(3, 3) // evicts key 2
15 assert.Equal(t, -1, cache.Get(2)) // returns -1 (not found)
16
17 cache.Put(4, 4) // evicts key 1
18 assert.Equal(t, -1, cache.Get(1)) // returns -1 (not found)
19 assert.Equal(t, 3, cache.Get(3)) // returns 3
20 assert.Equal(t, 4, cache.Get(4)) // returns 4
21}
22
23func TestLRUCache_2(t *testing.T) {
24 cache := Constructor(1)

Callers

nothing calls this directly

Calls 3

PutMethod · 0.80
ConstructorFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected