1 /*	Public domain	*/
2 /*
3  * This test ensures Agar can be destroyed and re-initialized.
4  */
5 
6 #include <agar/core.h>
7 #include <agar/gui.h>
8 
9 int
main(int argc,char * argv[])10 main(int argc, char *argv[])
11 {
12 	AG_Window *win;
13 	char *driverSpec = NULL, *optArg;
14 	int i, c;
15 
16 	while ((c = AG_Getopt(argc, argv, "?hd:", &optArg, NULL)) != -1) {
17 		switch (c) {
18 		case 'd':
19 			driverSpec = optArg;
20 			break;
21 		case '?':
22 		case 'h':
23 		default:
24 			printf("Usage: agarreinit [-d agar-driver-spec]\n");
25 			return (1);
26 		}
27 	}
28 
29 	for (i = 0; i < 25; i++) {
30 		printf("Test %d/25:\n", i);
31 		printf("\tInitCore()\n");
32 		if (AG_InitCore(NULL, 0) == -1) {
33 			printf("AG_InitCore(%d): %s\n", i, AG_GetError());
34 			exit(1);
35 		}
36 		printf("\tInitGraphics()\n");
37 		if (AG_InitGraphics(driverSpec) == -1) {
38 			printf("AG_InitGraphics(%d): %s\n", i, AG_GetError());
39 			exit(1);
40 		}
41 		printf("\tCreate Window\n");
42 		win = AG_WindowNew(0);
43 		AG_WindowSetCaption(win, "foo");
44 		AG_WindowShow(win);
45 		printf("\tDestroyVideo()\n");
46 		AG_DestroyVideo();
47 		printf("\tDestroy()\n");
48 		AG_Destroy();
49 		AG_Delay(100);
50 	}
51 	printf("Test successful\n");
52 	return (0);
53 }
54