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

Function TestStringGetBit

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

Source from the content-addressed store, hash-verified

640}
641
642func TestStringGetBit(t *testing.T) {
643 key := []byte("get-bits")
644 callFunc := func(txn *Transaction) {
645 s, err := GetString(txn, key)
646 assert.NoError(t, err)
647 s.SetBit(4, 1)
648 }
649 MockTest(t, callFunc)
650
651 type args struct {
652 off int
653 }
654 type want struct {
655 retval int
656 }
657 tests := []struct {
658 name string
659 args args
660 want want
661 }{
662 {
663 name: "one",
664 args: args{
665 off: 1,
666 },
667 want: want{
668 retval: 0,
669 },
670 },
671 {
672 name: "two",
673 args: args{
674 off: 100,
675 },
676 want: want{
677 retval: 0,
678 },
679 },
680 {
681 name: "three",
682 args: args{
683 off: 4,
684 },
685 want: want{
686 retval: 8,
687 },
688 },
689 }
690
691 for _, tt := range tests {
692 t.Run(tt.name, func(t *testing.T) {
693 callFunc := func(txn *Transaction) {
694 s, err := GetString(txn, key)
695 assert.NoError(t, err)
696 want, err := s.GetBit(tt.args.off)
697 assert.NoError(t, err)
698 assert.Equal(t, tt.want.retval, want)
699 }

Callers

nothing calls this directly

Calls 4

GetStringFunction · 0.85
MockTestFunction · 0.85
SetBitMethod · 0.80
GetBitMethod · 0.80

Tested by

no test coverage detected