| 135 | } |
| 136 | |
| 137 | func 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 | |
| 157 | func TestIncrementWithInt(t *testing.T) { |
| 158 | tc := New(DefaultExpiration, 0) |