vm/tests: unmarshal action in JSON tests properly

This commit is contained in:
Evgenii Stratonikov 2020-05-20 16:07:37 +03:00
parent 7ddb23abe3
commit 128a99dec2

View file

@ -73,10 +73,10 @@ type stackItemAUX struct {
}
const (
vmExecute vmUTActionType = "Execute"
vmStepInto vmUTActionType = "StepInto"
vmStepOut vmUTActionType = "StepOut"
vmStepOver vmUTActionType = "StepOver"
vmExecute vmUTActionType = "execute"
vmStepInto vmUTActionType = "stepinto"
vmStepOut vmUTActionType = "stepout"
vmStepOver vmUTActionType = "stepover"
typeArray vmUTStackItemType = "array"
typeBoolean vmUTStackItemType = "boolean"
@ -271,7 +271,7 @@ func (v *vmUTStackItem) toStackItem() StackItem {
func execStep(t *testing.T, v *VM, step vmUTStep) {
for i, a := range step.Actions {
var err error
switch a {
switch a.toLower() {
case vmExecute:
err = v.Run()
case vmStepInto:
@ -338,6 +338,10 @@ func decodeSingle(s string) ([]byte, bool) {
return b, err == nil
}
func (v vmUTActionType) toLower() vmUTActionType {
return vmUTActionType(strings.ToLower(string(v)))
}
func (v *vmUTActionType) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, (*string)(v))
}