]> pd.if.org Git - hexagon/blobdiff - t/astar.c
minor cleanup and refactor
[hexagon] / t / astar.c
index af88268d4212af1c23484843108e5aeeb4144d81..cb7f0434711c71dd59947a3fbc8e8d94d59351ee 100644 (file)
--- a/t/astar.c
+++ b/t/astar.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 
-#include "hexmap.h"
+#include "hexagon.h"
 
 #include "tap.h"
 
@@ -27,19 +27,17 @@ void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) {
 int neighbor55(int hex, int dir) {
        int neighbor;
 
-       neighbor = HL_adjacent_hex(hex, dir);
-       if (neighbor == HL_cantor_xy(5,5)) {
-               return -1;
-       }
+       do {
+               neighbor = HL_adjacent_hex(hex, dir++);
+       } while (neighbor == HL_cantor_xy(5,5));
 
        return neighbor;
 }
 
 int main(void) {
        struct HL_astar *p;
-       int length;
 
-       plan_tests(17);
+       plan_tests(16);
 
        p = HL_astar_init(0);
        ok(p != NULL, "allocated astar struct");
@@ -47,12 +45,6 @@ int main(void) {
        ok(p->open == NULL, "initial open list empty");
        ok(p->closed == NULL, "initial closed list empty");
 
-       p->start = HL_cantor_xy(1, 1);
-       p->goal = HL_cantor_xy(1, 2);
-       
-       length = HL_findpath(p, 0);
-       ok(p->error == 0, "path finding returns no error");
-
        pcheck(p, 1,1, 1,3, 2);
        pcheck(p, 1,1, 2,1, 1);
        pcheck(p, 1,1, 2,2, 2);