diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test.c | 11 | ||||
-rw-r--r-- | test/test.h | 10 | ||||
-rw-r--r-- | test/test_gst.c | 53 | ||||
-rw-r--r-- | test/test_gst.h | 8 |
4 files changed, 82 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..81a5fc8 --- /dev/null +++ b/test/test.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +#include "test.h" +#include "test_gst.h" + + +int test_run (infos *info) { + int result = 0; + result += test_gst_run(info); + return result; +}
\ No newline at end of file diff --git a/test/test.h b/test/test.h new file mode 100644 index 0000000..a6524bc --- /dev/null +++ b/test/test.h @@ -0,0 +1,10 @@ +#ifndef TEST_H +#define TEST_H + +#include "../gst/info.h" + +#define TEST_VERBOSE 1 + +int test_run (infos *info); + +#endif
\ No newline at end of file diff --git a/test/test_gst.c b/test/test_gst.c new file mode 100644 index 0000000..75e2606 --- /dev/null +++ b/test/test_gst.c @@ -0,0 +1,53 @@ +#include <stdio.h> + +#include "test.h" + +#include "../gst/fxs.h" +#include "../gst/gst.h" + +int test_gst_mirror_match (infos *info, int n); + + +int test_gst_run (infos *info) { + int result = 0; + for (int i=0; i<1; i++) { + result += test_gst_mirror_match(info, i); + } + return result; +} + +int test_gst_mirror_match (infos *info, int n) { + if(TEST_VERBOSE) printf("test_gst: mirror match __test%d\n", n); + fxs fx; + fx_init(&fx); + gamestate gst; + gst_init(&gst); + + char name[64]; sprintf(name, "hidden/__test%d", n); + info_load_army(gst.army_bp+0, name); + info_load_army(gst.army_bp+1, name); + gst.playernum = 2; + gst_tobattle(&gst, info); + + float t = 0; int i=0; + for (; i < 2000; i++) { + gst_process(&gst, info, &fx, t); + t += gst.turnspeed; + if (gst.over == 1) { + break; + } + } + if (i < 2000) { + if(TEST_VERBOSE) printf("test_gst: %d turns\n", i); + int winner = gst_check_victory(&gst); + if (winner == -1) { + if(TEST_VERBOSE) printf("test_gst success: draw\n"); + } else { + printf("test_gst failed: not draw (%d)\n", winner); + return 1; + } + gst_destroy(&gst); + return 0; + } + return 1; +}
\ No newline at end of file diff --git a/test/test_gst.h b/test/test_gst.h new file mode 100644 index 0000000..4d14ee2 --- /dev/null +++ b/test/test_gst.h @@ -0,0 +1,8 @@ +#ifndef TEST_GST_H +#define TEST_GST_H + +#include "../gst/info.h" + +int test_gst_run (infos *info); + +#endif
\ No newline at end of file |