internal/testutil: Snake.String and HexBytes return "EMPTY" when input is empty
This commit is contained in:
parent
8f8cd91b5d
commit
dcf923b1f3
@ -64,6 +64,10 @@ func (sn Snake) Check(data []byte) (ok bool, n int) {
|
||||
}
|
||||
|
||||
func (sn Snake) String() string {
|
||||
if len(sn) == 0 || len(sn[0]) == 0 || len(sn[0][0]) == 0{
|
||||
return "EMPTY"
|
||||
}
|
||||
|
||||
out := strings.Builder { }
|
||||
for index, sector := range sn {
|
||||
if index > 0 { out.WriteString(" : ") }
|
||||
@ -81,6 +85,7 @@ func (sn Snake) String() string {
|
||||
|
||||
// HexBytes formats bytes into a hexadecimal string.
|
||||
func HexBytes(data []byte) string {
|
||||
if len(data) == 0 { return "EMPTY" }
|
||||
out := strings.Builder { }
|
||||
for _, byt := range data {
|
||||
fmt.Fprintf(&out, "%02x", byt)
|
||||
|
Loading…
Reference in New Issue
Block a user