| 151 | } |
| 152 | |
| 153 | func TestStorePointerToStruct(t *testing.T) { |
| 154 | tc := New(DefaultExpiration, 0) |
| 155 | tc.Set("foo", &TestStruct{Num: 1}, DefaultExpiration) |
| 156 | x, found := tc.Get("foo") |
| 157 | if !found { |
| 158 | t.Fatal("*TestStruct was not found for foo") |
| 159 | } |
| 160 | foo := x.(*TestStruct) |
| 161 | foo.Num++ |
| 162 | |
| 163 | y, found := tc.Get("foo") |
| 164 | if !found { |
| 165 | t.Fatal("*TestStruct was not found for foo (second time)") |
| 166 | } |
| 167 | bar := y.(*TestStruct) |
| 168 | if bar.Num != 2 { |
| 169 | t.Fatal("TestStruct.Num is not 2") |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func TestIncrementWithInt(t *testing.T) { |
| 174 | tc := New(DefaultExpiration, 0) |