7 void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) {
10 from = HL_cantor_xy(x1,y1);
11 to = HL_cantor_xy(x2,y2);
18 dist = HL_findpath(p,0);
19 ok(p->error == 0, "found path from (%02d, %02d) to (%02d, %02d) with no error",
22 "found path from (%02d, %02d) to (%02d, %02d) path length = %d (expect %d)",
23 x1, y1, x2, y2, dist, expect);
26 /* make hex 55 missing */
27 int neighbor55(int hex, int dir) {
30 neighbor = HL_adjacent_hex(hex, dir);
31 if (neighbor == HL_cantor_xy(5,5)) {
45 ok(p != NULL, "allocated astar struct");
46 ok(p->malloced == 1, "allocated astar sets malloced");
47 ok(p->open == NULL, "initial open list empty");
48 ok(p->closed == NULL, "initial closed list empty");
50 p->start = HL_cantor_xy(1, 1);
51 p->goal = HL_cantor_xy(1, 2);
53 length = HL_findpath(p, 0);
54 ok(p->error == 0, "path finding returns no error");
56 pcheck(p, 1,1, 1,3, 2);
57 pcheck(p, 1,1, 2,1, 1);
58 pcheck(p, 1,1, 2,2, 2);
59 pcheck(p, 1,1, 3,1, 2);
60 pcheck(p, 1,1, 4,7, 8);
63 p->neighbor = neighbor55;