MCPcopy Create free account
hub / github.com/allegro/bigcache / TestEncodeDecode

Function TestEncodeDecode

encoding_test.go:8–25  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestEncodeDecode(t *testing.T) {
9 // given
10 now := uint64(time.Now().Unix())
11 hash := uint64(42)
12 key := "key"
13 data := []byte("data")
14 buffer := make([]byte, 100)
15
16 // when
17 wrapped := wrapEntry(now, hash, key, data, &buffer)
18
19 // then
20 assertEqual(t, key, readKeyFromEntry(wrapped))
21 assertEqual(t, hash, readHashFromEntry(wrapped))
22 assertEqual(t, now, readTimestampFromEntry(wrapped))
23 assertEqual(t, data, readEntry(wrapped))
24 assertEqual(t, 100, len(buffer))
25}
26
27func TestAllocateBiggerBuffer(t *testing.T) {
28 //given

Callers

nothing calls this directly

Calls 6

wrapEntryFunction · 0.85
readKeyFromEntryFunction · 0.85
readHashFromEntryFunction · 0.85
readTimestampFromEntryFunction · 0.85
readEntryFunction · 0.85
assertEqualFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…