mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
30 lines
748 B
Go
30 lines
748 B
Go
package bytesutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/v4/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)
|
|
}
|
|
}
|