(t *testing.T)
| 264 | |
| 265 | } |
| 266 | func TestInMemStore_SetUint64(t *testing.T) { |
| 267 | ds := testMemoryDatastore() |
| 268 | type kv struct { |
| 269 | key string |
| 270 | val uint64 |
| 271 | } |
| 272 | type test struct { |
| 273 | input []kv |
| 274 | expectError bool |
| 275 | } |
| 276 | tests := []test{ |
| 277 | { |
| 278 | input: []kv{ |
| 279 | {key: "1", val: 2343}, |
| 280 | {key: "foo", val: 23}, |
| 281 | {key: "hello", val: 5645}, |
| 282 | }, |
| 283 | expectError: false, |
| 284 | }, |
| 285 | { |
| 286 | input: []kv{ |
| 287 | {key: "", val: 654}, |
| 288 | }, |
| 289 | expectError: true, |
| 290 | }, |
| 291 | } |
| 292 | for _, tc := range tests { |
| 293 | // set all inputs |
| 294 | for _, v := range tc.input { |
| 295 | err := ds.Set(stringToBytes(v.key), uint64ToBytes(v.val)) |
| 296 | if tc.expectError { |
| 297 | assert.NotNil(t, err) |
| 298 | } else { |
| 299 | assert.NoError(t, err) |
| 300 | } |
| 301 | } |
| 302 | // recall all inputs |
| 303 | for _, v := range tc.input { |
| 304 | val, err := ds.Get(stringToBytes(v.key)) |
| 305 | if tc.expectError { |
| 306 | assert.NotNil(t, err) |
| 307 | } else { |
| 308 | assert.NoError(t, err) |
| 309 | assert.Equal(t, v.val, bytesToUint64(val)) |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | } |
| 314 | |
| 315 | } |
| 316 | func TestInMemStore_GetUint64(t *testing.T) { |
| 317 | type kv struct { |
| 318 | key string |
nothing calls this directly
no test coverage detected