MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestInMemStore_SetUint64

Function TestInMemStore_SetUint64

lib/datastore/inmem_test.go:266–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

264
265}
266func 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}
316func TestInMemStore_GetUint64(t *testing.T) {
317 type kv struct {
318 key string

Callers

nothing calls this directly

Calls 6

testMemoryDatastoreFunction · 0.85
stringToBytesFunction · 0.85
uint64ToBytesFunction · 0.85
bytesToUint64Function · 0.85
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected