7 void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) {
8 struct HL_hex from, to;
11 from = HL_hex_xy(x1,y1);
12 to = HL_hex_xy(x2,y2);
19 dist = HL_findpath(p,0);
20 ok(p->error == 0, "found path from (%02d, %02d) to (%02d, %02d) with no error",
23 "found path from (%02d, %02d) to (%02d, %02d) path length = %d (expect %d)",
24 x1, y1, x2, y2, dist, expect);
27 /* make hex 55 missing */
28 int neighbor55(struct HL_hex hex, int dir, struct HL_hex *n) {
32 valid = HL_adjhexp(hex, dir, &nh);
33 if (valid && nh.x == 5 && nh.y == 5) {
51 ok(p != NULL, "allocated astar struct");
52 ok(p->malloced == 1, "allocated astar sets malloced");
53 ok(p->open == NULL, "initial open list empty");
54 ok(p->closed == NULL, "initial closed list empty");
56 pcheck(p, 1,1, 1,3, 2);
58 pcheck(p, 1,1, 2,1, 1);
60 pcheck(p, 1,1, 2,2, 2);
62 pcheck(p, 1,1, 3,1, 2);
64 pcheck(p, 1,1, 4,7, 8);
68 p->neighbor = neighbor55;