From f85ac77efc0feeeab183e509a7baca1c507da3c5 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Sep 2024 17:52:41 +0200 Subject: Added test for invermoves and small refactor --- test/032_invertmoves/invertmoves_tests.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/032_invertmoves/invertmoves_tests.c (limited to 'test/032_invertmoves/invertmoves_tests.c') diff --git a/test/032_invertmoves/invertmoves_tests.c b/test/032_invertmoves/invertmoves_tests.c new file mode 100644 index 0000000..acb2adc --- /dev/null +++ b/test/032_invertmoves/invertmoves_tests.c @@ -0,0 +1,21 @@ +#include "../test.h" + +#define MAXMOVES 20 + +int64_t readmoves(const char *, int, uint8_t *); +void writemoves(uint8_t *, int, char *); +void invertmoves(uint8_t *, uint8_t, uint8_t *); + +void run(void) { + char movestr[STRLENMAX], outstr[STRLENMAX]; + uint8_t moves[MAXMOVES], ret[MAXMOVES]; + int c; + + fgets(movestr, STRLENMAX, stdin); + c = readmoves(movestr, MAXMOVES, moves); + + invertmoves(moves, c, ret); + writemoves(ret, c, outstr); + + printf("%s\n", outstr); +} -- cgit v1.3