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