test.c
Raw
1#include "simple-go.h"
2#include "simple-gtp.h"
3
4void test1(void)
5{
6 puts("test1 running");
7 go_board* test_board = create_board(5);
8
9 set_board_at(test_board, 2, 2, WHITE);
10 set_board_at(test_board, 2, 3, WHITE);
11 set_board_at(test_board, 1, 3, WHITE);
12 set_board_at(test_board, 3, 3, WHITE);
13 set_board_at(test_board, 4, 4, WHITE);
14 set_board_at(test_board, 3, 1, WHITE);
15 set_board_at(test_board, 3, 2, BLACK);
16
17 print_board(test_board);
18 putchar('\n');
19
20 go_board* test_overlay = create_board(5);
21 find_group(test_board, test_overlay, 2, 2);
22
23 print_board(test_overlay);
24
25 printf("liberties: %ld\n", count_liberties(test_board,test_overlay));
26
27 kill_group(test_board, test_overlay);
28
29 print_board(test_board);
30
31 delete_board(test_board);
32 delete_board(test_overlay);
33 puts("test1 finished");
34}
35
36void test2(void)
37{
38 puts("test2 running");
39 game_state* test_game = create_game(5, 0);
40 go_board* test_board = test_game->board;
41 set_board_at(test_board, 2, 3, WHITE);
42 set_board_at(test_board, 3, 2, WHITE);
43 set_board_at(test_board, 1, 2, WHITE);
44 set_board_at(test_board, 2, 1, WHITE);
45 set_board_at(test_board, 1, 1, BLACK);
46
47 play_at(test_game, 2, 2);
48 print_board(test_game->board);
49
50 set_board_at(test_board, 2, 1, EMPTY);
51
52 play_at(test_game, 2, 2);
53 print_board(test_game->board);
54
55
56 play_at(test_game, 2, 1);
57 print_board(test_game->board);
58
59 delete_game(test_game);
60 puts("test2 finished");
61}
62
63void test3(void)
64{
65 puts("test2 running");
66
67 game_state* test_game = create_game(11, 0);
68
69 char* ret =handle_gtp_cmd("play white a9", test_game);
70 printf("%s\n", ret);
71 print_board(test_game->board);
72
73 free(ret);
74 delete_game(test_game);
75
76 puts("test2 finished");
77}
78
79
80int main(int argc, char** argv)
81{
82 test1();
83 test2();
84 test3();
85
86}
87