]> pd.if.org Git - hexagon/blob - t/distance.c
move astar to lib
[hexagon] / t / distance.c
1 #include "hexagon.h"
2
3 #include "ctap.h"
4
5 void dcheck(int x1, int y1, int x2, int y2, int expect) {
6         int dist;
7         struct HL_hex from, to;
8
9         from.x = x1;
10         from.y = y1;
11         to.x = x2;
12         to.y = y2;
13
14         dist = HL_distance(from,to);
15         is_int(expect, dist,
16                 "distance from (%02d, %02d) to (%02d, %02d)",
17                 x1, y1, x2, y2);
18 }
19
20 int main(void) {
21         plan(8);
22
23         dcheck(1,1,2,1,1);
24         dcheck(1,1,2,2,2);
25         dcheck(2,2,2,1,1);
26         dcheck(1,1,2,3,3);
27         dcheck(3,3,3,3,0);
28         dcheck(0,0,1,1,1);
29         dcheck(-1,-1,1,2,4);
30         dcheck(-1,-1,-1,-2,1);
31
32         return 0;
33 }