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 {
|
func (sn Snake) String() string {
|
||||||
|
if len(sn) == 0 || len(sn[0]) == 0 || len(sn[0][0]) == 0{
|
||||||
|
return "EMPTY"
|
||||||
|
}
|
||||||
|
|
||||||
out := strings.Builder { }
|
out := strings.Builder { }
|
||||||
for index, sector := range sn {
|
for index, sector := range sn {
|
||||||
if index > 0 { out.WriteString(" : ") }
|
if index > 0 { out.WriteString(" : ") }
|
||||||
@ -81,6 +85,7 @@ func (sn Snake) String() string {
|
|||||||
|
|
||||||
// HexBytes formats bytes into a hexadecimal string.
|
// HexBytes formats bytes into a hexadecimal string.
|
||||||
func HexBytes(data []byte) string {
|
func HexBytes(data []byte) string {
|
||||||
|
if len(data) == 0 { return "EMPTY" }
|
||||||
out := strings.Builder { }
|
out := strings.Builder { }
|
||||||
for _, byt := range data {
|
for _, byt := range data {
|
||||||
fmt.Fprintf(&out, "%02x", byt)
|
fmt.Fprintf(&out, "%02x", byt)
|
||||||
|
Loading…
Reference in New Issue
Block a user