22 lines
695 B
Go
22 lines
695 B
Go
package combatturns
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestExtractionResponseDecodingPreservesValidatorOwnedSemantics(t *testing.T) {
|
|
content := []byte(`{"combat_turns":[{"actor":"","turn_kind":"unsupported","source_refs":[{"start_unit_id":0,"end_unit_id":-1}]}]}`)
|
|
var response extractionResponse
|
|
if err := json.Unmarshal(content, &response); err != nil {
|
|
t.Fatalf("json.Unmarshal() error = %v", err)
|
|
}
|
|
turn := response.CombatTurns[0]
|
|
if turn.Actor != "" || turn.TurnKind != "unsupported" {
|
|
t.Fatalf("decoded turn = %#v", turn)
|
|
}
|
|
if turn.SourceRefs[0] != (combatSourceRefResponse{StartUnitID: 0, EndUnitID: -1}) {
|
|
t.Fatalf("decoded ref = %#v", turn.SourceRefs[0])
|
|
}
|
|
}
|