mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
a94ccf9236
Close #2470.
37 lines
717 B
Go
37 lines
717 B
Go
package opcode
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// Nothing more to test here, really.
|
|
func TestStringer(t *testing.T) {
|
|
tests := map[Opcode]string{
|
|
ADD: "ADD",
|
|
SUB: "SUB",
|
|
ASSERT: "ASSERT",
|
|
0xff: "Opcode(255)",
|
|
}
|
|
for o, s := range tests {
|
|
assert.Equal(t, s, o.String())
|
|
}
|
|
}
|
|
|
|
func TestFromString(t *testing.T) {
|
|
_, err := FromString("abcdef")
|
|
require.Error(t, err)
|
|
|
|
op, err := FromString(MUL.String())
|
|
require.NoError(t, err)
|
|
require.Equal(t, MUL, op)
|
|
}
|
|
|
|
func TestIsValid(t *testing.T) {
|
|
require.True(t, IsValid(ADD))
|
|
require.True(t, IsValid(CONVERT))
|
|
require.False(t, IsValid(0xff))
|
|
require.False(t, IsValid(0xa7))
|
|
}
|