Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

engine_test.gno

0.91 Kb · 33 lines
 1package engine
 2
 3import "testing"
 4
 5func TestResolveMatchesModel(t *testing.T) {
 6	rs := ProofOfConcept()
 7	for i, tc := range resolveCases {
 8		a, okA := rs.PlanOf(tc.A...)
 9		b, okB := rs.PlanOf(tc.B...)
10		if !okA || !okB {
11			t.Fatalf("case %d: unknown card in %v or %v", i, tc.A, tc.B)
12		}
13		s := State{Round: tc.Round}
14		for side := 0; side < 2; side++ {
15			s.Gnomes[side] = Gnome{HP: tc.Start[side][0], Vulnerable: tc.Start[side][1], Strength: tc.Start[side][2]}
16		}
17		o := rs.Resolve(s, a, b)
18		if o.Result != tc.Result {
19			t.Errorf("case %d (%v vs %v): result %d, want %d", i, tc.A, tc.B, o.Result, tc.Result)
20			continue
21		}
22		if tc.End == ([2][3]int{}) {
23			continue
24		}
25		for side := 0; side < 2; side++ {
26			g := o.State.Gnomes[side]
27			got := [3]int{g.HP, g.Vulnerable, g.Strength}
28			if got != tc.End[side] {
29				t.Errorf("case %d (%v vs %v): side %d ends %v, want %v", i, tc.A, tc.B, side, got, tc.End[side])
30			}
31		}
32	}
33}