2019-12-03 14:05:06 +00:00
|
|
|
package opcode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-05-21 10:00:11 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-12-03 14:05:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Nothing more to test here, really.
|
|
|
|
func TestStringer(t *testing.T) {
|
|
|
|
tests := map[Opcode]string{
|
2020-05-06 12:54:18 +00:00
|
|
|
ADD: "ADD",
|
|
|
|
SUB: "SUB",
|
|
|
|
ASSERT: "ASSERT",
|
|
|
|
0xff: "Opcode(255)",
|
2019-12-03 14:05:06 +00:00
|
|
|
}
|
|
|
|
for o, s := range tests {
|
|
|
|
assert.Equal(t, s, o.String())
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 10:00:11 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|