27 lines
874 B
Go
27 lines
874 B
Go
|
|
package xmlres
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestMoveUnmarshalJSONAcceptsNumericName(t *testing.T) {
|
||
|
|
var move Move
|
||
|
|
if err := json.Unmarshal([]byte(`{"ID":10001,"Name":1,"Category":1,"Type":8,"Power":35,"MaxPP":35,"Accuracy":95}`), &move); err != nil {
|
||
|
|
t.Fatalf("unmarshal move failed: %v", err)
|
||
|
|
}
|
||
|
|
if move.Name != "1" {
|
||
|
|
t.Fatalf("expected numeric name to convert to string, got %q", move.Name)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestEffectArgUnmarshalJSONAcceptsNumericSideEffectArg(t *testing.T) {
|
||
|
|
var cfg EffectArg
|
||
|
|
if err := json.Unmarshal([]byte(`{"SideEffects":{"SideEffect":[{"ID":1,"SideEffectArgcount":1,"SideEffectArg":3}]}}`), &cfg); err != nil {
|
||
|
|
t.Fatalf("unmarshal effect arg failed: %v", err)
|
||
|
|
}
|
||
|
|
if got := string(cfg.SideEffects.SideEffect[0].SideEffectArg); got != "3" {
|
||
|
|
t.Fatalf("expected numeric side effect arg to convert to string, got %q", got)
|
||
|
|
}
|
||
|
|
}
|