github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/cmd/ctool/core/bytes_utils_test.go (about) 1 package core 2 3 import ( 4 "fmt" 5 "github.com/PlatONnetwork/PlatON-Go/common" 6 "testing" 7 ) 8 9 func TestByteConvert(t *testing.T) { 10 //bytes, _ := hexutil.Decode("0x0c55699c") 11 hash := common.BytesToHash(Int32ToBytes(121)) 12 13 result := BytesConverter(hash.Bytes(), "int32") 14 fmt.Printf("\nresult: %v\n", result) 15 16 } 17 18 func TestStringConverter(t *testing.T) { 19 result, err := StringConverter("false", "bool") 20 fmt.Printf("\nresult: %v\n", result) 21 if err != nil { 22 fmt.Printf("\nerr: %v\n", err.Error()) 23 } 24 //buf := bytes.NewBuffer([]byte{}) 25 //binary.Write(buf, binary.BigEndian, "true") 26 //fmt.Println(buf.Bytes()) 27 //fmt.Println(len(buf.Bytes())) 28 29 //fmt.Printf("%v",i) 30 }