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

Function TestLRUCache_5

lru_cache_146/solution_test.go:60–70  ·  view source on GitHub ↗

* ["LRUCache","put","put","put","put","get","get"] [[2],[2,1],[1,1],[2,3],[4,1],[1],[2]] Output: [null,null,null,null,null,1,-1] Expected: [null,null,null,null,null,-1,3] */

(t *testing.T)

Source from the content-addressed store, hash-verified

58Expected: [null,null,null,null,null,-1,3]
59*/
60func TestLRUCache_5(t *testing.T) {
61 cache := Constructor(2)
62 cache.Put(2, 1)
63 cache.Put(1, 1)
64 cache.Put(2, 3) // evict 2->1
65 cache.Put(4, 1) // evict 1->1
66
67 // left with: 2->3, 4->1
68 assert.Equal(t, -1, cache.Get(1))
69 assert.Equal(t, 3, cache.Get(2))
70}
71
72/*
73["LRUCache","put","put","get","put","put","get"]

Callers

nothing calls this directly

Calls 3

PutMethod · 0.80
ConstructorFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected