X-Git-Url: https://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/b8d5c7bc17fcb037c23d323d4f8fbdbab9894d9d..a70b0ef8bf7cb26cc779e9b2da480295f5ebf2bd:/t/overlaygoal.c diff --git a/t/overlaygoal.c b/t/overlaygoal.c new file mode 100644 index 0000000..059e835 --- /dev/null +++ b/t/overlaygoal.c @@ -0,0 +1,61 @@ +/* + * Helper to test game_overlay_goal function. + * Copyright © 2023 Nick Bowler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include "game.h" + +#define X3(x) x x x + +static const char *progname = "overlaygoal"; + +int main(int argc, char **argv) +{ + struct board board; + int rc; + + if (argc > 0) + progname = argv[0]; + + while ((rc = scanf(X3("%" SCNxLEAST32) X3("%" SCNxLEAST16), + &board.game[0], &board.game[1], + &board.game[2], &board.goal[0], + &board.goal[1], &board.goal[2])) == 6) + { + uint_least32_t buf[3]; + + game_overlay_goal(&board, buf); + printf(X3(" %.7" PRIxLEAST32)"\n"+1, buf[0], buf[1], buf[2]); + } + + if (rc == EOF) { + if (ferror(stdin)) { + fprintf(stderr, "%s: read error: %s\n", progname, + strerror(errno)); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + } + + fprintf(stderr, "%s: invalid input sequence\n", progname); + return EXIT_FAILURE; +}