MCPcopy Create free account
hub / github.com/distributedio/titan / TestStringSetRange

Function TestStringSetRange

db/string_test.go:452–496  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

450}
451
452func TestStringSetRange(t *testing.T) {
453 setValue(t, []byte("SetRangeExistKey"), value)
454 type args struct {
455 offset int64
456 value []byte
457 }
458
459 tests := []struct {
460 name string
461 args args
462 key []byte
463 want []byte
464 }{
465 {
466 name: "SetRange_ExistKey",
467 args: args{
468 offset: 6,
469 value: []byte("lllll"),
470 },
471 key: []byte("SetRangeExistKey"),
472 want: []byte("Stringlllll"),
473 },
474 {
475 name: "SetRange_NoExistKey",
476 args: args{
477 offset: 6,
478 value: []byte("lllll"),
479 },
480 key: []byte("SetRangeNoExistKey"),
481 want: []byte("\x00\x00\x00\x00\x00\x00lllll"),
482 },
483 }
484 for _, tt := range tests {
485 t.Run(tt.name, func(t *testing.T) {
486 callFunc := func(txn *Transaction) {
487 s, err := GetString(txn, tt.key)
488 assert.NoError(t, err)
489 got, err := s.SetRange(tt.args.offset, tt.args.value)
490 assert.NoError(t, err)
491 assert.Equal(t, tt.want, got)
492 }
493 MockTest(t, callFunc)
494 })
495 }
496}
497
498func TestStringIncr(t *testing.T) {
499 type args struct {

Callers

nothing calls this directly

Calls 4

setValueFunction · 0.85
GetStringFunction · 0.85
MockTestFunction · 0.85
SetRangeMethod · 0.80

Tested by

no test coverage detected