From ce4fd67e5bfd07192ca5cb357798aaa3588512e4 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Wed, 13 Jun 2018 09:27:58 +0000 Subject: [PATCH] use ctap --- Makefile | 6 +++--- t/adjacency.c | 6 +++--- t/astar.c | 15 ++++++++++----- t/astarlg.c | 6 +++--- t/cantor.c | 6 +++--- t/center.c | 6 +++--- t/distance.c | 6 +++--- t/gridsize.c | 4 ++-- t/hexbin.c | 6 +++--- t/range.c | 6 +++--- t/within.c | 4 ++-- 11 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 1662968..0ae921c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CFLAGS= -Wall -Wno-parentheses $(ARCH) -I. -I.. OBJS= hexagon.o astar.o SRC=$(OBJS:.o=.c) TESTS= t/cantor.t t/distance.t t/adjacency.t t/range.t t/hexbin.t \ - t/gridsize.t t/center.t t/astar.t t/astarlg.t + t/gridsize.t t/center.t t/astar.t PREFIX=/usr/local all: libhexagon.a docs testfiles @@ -15,13 +15,13 @@ all: libhexagon.a docs testfiles clean: rm -f $(OBJS) libhexagon.a $(TESTS) -t/%.t: t/%.o t/tap.o $(OBJS) +t/%.t: t/%.o t/ctap.o $(OBJS) $(CC) -I.. -I. -o $@ $+ $(LDFLAGS) testfiles: $(TESTS) test: libhexagon.a $(TESTS) - @prove --exec '' 2>/dev/null + @prove --exec $(TESTS) '' 2>/dev/null libhexagon.a: $(OBJS) ar r $@ $+ diff --git a/t/adjacency.c b/t/adjacency.c index dc2c64f..4112288 100644 --- a/t/adjacency.c +++ b/t/adjacency.c @@ -1,12 +1,12 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int main(void) { int hex, start, dist; int x, y, i; - plan_tests(294); + plan(294); for (x = -3 ; x <= 3; x++) { for (y = -3 ; y <= 3; y++) { @@ -21,5 +21,5 @@ int main(void) { } } - return exit_status(); + return 0; } diff --git a/t/astar.c b/t/astar.c index cb7f043..729a7a8 100644 --- a/t/astar.c +++ b/t/astar.c @@ -2,7 +2,7 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) { int from, to, dist; @@ -10,7 +10,7 @@ void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) { from = HL_cantor_xy(x1,y1); to = HL_cantor_xy(x2,y2); - HL_astar_clear(p); +// HL_astar_clear(p); p->start = from; p->goal = to; @@ -37,7 +37,7 @@ int neighbor55(int hex, int dir) { int main(void) { struct HL_astar *p; - plan_tests(16); + plan(16); p = HL_astar_init(0); ok(p != NULL, "allocated astar struct"); @@ -46,16 +46,21 @@ int main(void) { ok(p->closed == NULL, "initial closed list empty"); pcheck(p, 1,1, 1,3, 2); + HL_astar_init(p); pcheck(p, 1,1, 2,1, 1); + HL_astar_init(p); pcheck(p, 1,1, 2,2, 2); + HL_astar_init(p); pcheck(p, 1,1, 3,1, 2); + HL_astar_init(p); pcheck(p, 1,1, 4,7, 8); - HL_astar_clear(p); + //HL_astar_clear(p); + HL_astar_init(p); p->neighbor = neighbor55; pcheck(p,5,4,5,6,3); HL_astar_free(p); - return exit_status(); + return 0; } diff --git a/t/astarlg.c b/t/astarlg.c index 7d2ef6b..4dcf582 100644 --- a/t/astarlg.c +++ b/t/astarlg.c @@ -2,7 +2,7 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) { int from, to, dist; @@ -40,7 +40,7 @@ int main(void) { int length; #endif - plan_tests(2); + plan(2); p = HL_astar_init(0); @@ -48,5 +48,5 @@ int main(void) { HL_astar_free(p); - return exit_status(); + return 0; } diff --git a/t/cantor.c b/t/cantor.c index e6ce28f..1e7dbf6 100644 --- a/t/cantor.c +++ b/t/cantor.c @@ -2,7 +2,7 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int main(void) { int xy[2]; @@ -10,7 +10,7 @@ int main(void) { int hex; int x, y; - plan_tests(81*4); + plan(81*4); for (x=-4;x<=4;x++) { for (y=-4;y<=4;y++) { @@ -23,5 +23,5 @@ int main(void) { } } - return exit_status(); + return 0; } diff --git a/t/center.c b/t/center.c index 72499a3..1c039c9 100644 --- a/t/center.c +++ b/t/center.c @@ -2,12 +2,12 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int main(void) { int start, x, y; - plan_tests(6); + plan(6); x = 0; y = 0; start = HL_cantor_xy(x,y); @@ -26,5 +26,5 @@ int main(void) { ok(HL_center_y(start) == 2.0, "%d %d center Y = %f", x, y, HL_center_y(start)); - return exit_status(); + return 0; } diff --git a/t/distance.c b/t/distance.c index c3ff1cc..0fa88f0 100644 --- a/t/distance.c +++ b/t/distance.c @@ -1,6 +1,6 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" void dcheck(int x1, int y1, int x2, int y2, int expect) { int from, to, dist; @@ -13,7 +13,7 @@ void dcheck(int x1, int y1, int x2, int y2, int expect) { } int main(void) { - plan_tests(8); + plan(8); dcheck(1,1,2,1,1); dcheck(1,1,2,2,2); @@ -24,5 +24,5 @@ int main(void) { dcheck(-1,-1,1,2,4); dcheck(-1,-1,-1,-2,1); - return exit_status(); + return 0; } diff --git a/t/gridsize.c b/t/gridsize.c index f4335fd..8b304ea 100644 --- a/t/gridsize.c +++ b/t/gridsize.c @@ -1,6 +1,6 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int searchbound(int low, int high) { int try; @@ -20,7 +20,7 @@ int main(void) { int start; int x; - plan_tests(2); + plan(2); x = 1; do { diff --git a/t/hexbin.c b/t/hexbin.c index 5fc504d..293d0f7 100644 --- a/t/hexbin.c +++ b/t/hexbin.c @@ -1,11 +1,11 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int main(void) { int x, y; - plan_tests(6); + plan(6); HL_hexbin(1.0, 0.444194, -4.639363, &x, &y); ok(x == 1 && y == 4, "hexbin 0.444194, 4.639363 = 1, 4, %d %d", x, y); @@ -21,5 +21,5 @@ int main(void) { ok(x == 9, "vertex bin X %d == 9", x); ok(y == -5, "vertex bin Y %d == -5", y); - return exit_status(); + return 0; } diff --git a/t/range.c b/t/range.c index b4a4125..783a089 100644 --- a/t/range.c +++ b/t/range.c @@ -6,7 +6,7 @@ #include "hexagon.h" -#include "tap.h" +#include "ctap.h" int icmp(const void *ap, const void *bp) { int a; @@ -28,7 +28,7 @@ int main(void) { int range[32]; int testrange[32]; - plan_tests(7+4); + plan(7+4); /* printf("range = 1 from 3,3\n"); */ start = HL_cantor_xy(3,3); @@ -63,5 +63,5 @@ int main(void) { count = HL_hexes_at_range(start, 2, range, 0); ok(count == 12, "6 hexes at range1 from 3,3"); - return exit_status(); + return 0; } diff --git a/t/within.c b/t/within.c index 9294b8b..4884309 100644 --- a/t/within.c +++ b/t/within.c @@ -9,11 +9,11 @@ int main(void) { int x, y, i, count; int range[32]; - plan_tests(1); + plan(1); start = HL_cantor_xy(3,3); count = HL_hexes_within_range(start, 2, range, 0); ok(count == 18, "18 hexes within 2 hexes of 3,3"); - return exit_status(); + return 0; } -- 2.40.0