mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
1e3a55c6a6
* Refactor bytes.go and bytes_test.go to smaller files, introduce go1.17 and go1.20 style of array copy * rename bytes_go17.go to reflect that it works on any version 1.19 and below * fix PadTo when len is exactly the size * Add go1.20 style conversions * Forgot another int method Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
30 lines
748 B
Go
30 lines
748 B
Go
package bytesutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
|
)
|
|
|
|
func TestIsHex(t *testing.T) {
|
|
tests := []struct {
|
|
a []byte
|
|
b bool
|
|
}{
|
|
{nil, false},
|
|
{[]byte(""), false},
|
|
{[]byte("0x"), false},
|
|
{[]byte("0x0"), true},
|
|
{[]byte("foo"), false},
|
|
{[]byte("1234567890abcDEF"), false},
|
|
{[]byte("XYZ4567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), false},
|
|
{[]byte("0x1234567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), true},
|
|
{[]byte("1234567890abcDEF1234567890abcDEF1234567890abcDEF1234567890abcDEF"), false},
|
|
}
|
|
for _, tt := range tests {
|
|
isHex := bytesutil.IsHex(tt.a)
|
|
assert.Equal(t, tt.b, isHex)
|
|
}
|
|
}
|