github.com/aergoio/aergo@v1.3.1/internal/enc/bstr_test.go (about) 1 package enc 2 3 import ( 4 "bytes" 5 "testing" 6 ) 7 8 func TestToString(t *testing.T) { 9 type args struct { 10 b []byte 11 } 12 tests := []struct { 13 name string 14 args args 15 want string 16 wantInverse bool 17 }{ 18 {"TSingle", args{[]byte("A")},"28", true}, 19 {"TEmpty", args{make([]byte,0)},"", false}, 20 {"TNil", args{nil},"", false}, 21 // TODO: Add test cases. 22 } 23 for _, tt := range tests { 24 t.Run(tt.name, func(t *testing.T) { 25 got := ToString(tt.args.b) 26 if got != tt.want { 27 t.Errorf("ToString() = %v, want %v", got, tt.want) 28 } 29 30 if tt.wantInverse { 31 got2, err := ToBytes(got) 32 if err != nil { 33 t.Errorf("ToBytes() = <err> %s, want no err", err.Error()) 34 } 35 if !bytes.Equal(tt.args.b, got2) { 36 t.Errorf("ToString() = %v, want %v", got2, tt.args.b) 37 } 38 } 39 }) 40 } 41 }