#include "hexagon.h" #include "ctap.h" void dcheck(int x1, int y1, int x2, int y2, int expect) { int dist; struct HL_hex from, to; from.x = x1; from.y = y1; to.x = x2; to.y = y2; dist = HL_distance(from,to); is_int(expect, dist, "distance from (%02d, %02d) to (%02d, %02d)", x1, y1, x2, y2); } int main(void) { plan(8); dcheck(1,1,2,1,1); dcheck(1,1,2,2,2); dcheck(2,2,2,1,1); dcheck(1,1,2,3,3); dcheck(3,3,3,3,0); dcheck(0,0,1,1,1); dcheck(-1,-1,1,2,4); dcheck(-1,-1,-1,-2,1); return 0; }