MCPcopy Create free account
hub / github.com/patrickmn/go-cache / TestStorePointerToStruct

Function TestStorePointerToStruct

cache_test.go:137–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

135}
136
137func TestStorePointerToStruct(t *testing.T) {
138 tc := New(DefaultExpiration, 0)
139 tc.Set("foo", &TestStruct{Num: 1}, DefaultExpiration)
140 x, found := tc.Get("foo")
141 if !found {
142 t.Fatal("*TestStruct was not found for foo")
143 }
144 foo := x.(*TestStruct)
145 foo.Num++
146
147 y, found := tc.Get("foo")
148 if !found {
149 t.Fatal("*TestStruct was not found for foo (second time)")
150 }
151 bar := y.(*TestStruct)
152 if bar.Num != 2 {
153 t.Fatal("TestStruct.Num is not 2")
154 }
155}
156
157func TestIncrementWithInt(t *testing.T) {
158 tc := New(DefaultExpiration, 0)

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…