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/001_onemove.in | 1 + test/032_invertmoves/001_onemove.out | 1 + test/032_invertmoves/002_20moves.in | 1 + test/032_invertmoves/002_20moves.out | 1 + test/032_invertmoves/invertmoves_tests.c | 21 +++++++++++++++++++++ 5 files changed, 25 insertions(+) create mode 100644 test/032_invertmoves/001_onemove.in create mode 100644 test/032_invertmoves/001_onemove.out create mode 100644 test/032_invertmoves/002_20moves.in create mode 100644 test/032_invertmoves/002_20moves.out create mode 100644 test/032_invertmoves/invertmoves_tests.c (limited to 'test') diff --git a/test/032_invertmoves/001_onemove.in b/test/032_invertmoves/001_onemove.in new file mode 100644 index 0000000..cf84443 --- /dev/null +++ b/test/032_invertmoves/001_onemove.in @@ -0,0 +1 @@ +F diff --git a/test/032_invertmoves/001_onemove.out b/test/032_invertmoves/001_onemove.out new file mode 100644 index 0000000..6ab6e07 --- /dev/null +++ b/test/032_invertmoves/001_onemove.out @@ -0,0 +1 @@ +F' diff --git a/test/032_invertmoves/002_20moves.in b/test/032_invertmoves/002_20moves.in new file mode 100644 index 0000000..052ed94 --- /dev/null +++ b/test/032_invertmoves/002_20moves.in @@ -0,0 +1 @@ +B2 R D2 B2 R D2 F2 L2 F2 R' F2 D' L D2 L U2 L B2 F2 U diff --git a/test/032_invertmoves/002_20moves.out b/test/032_invertmoves/002_20moves.out new file mode 100644 index 0000000..bc6a079 --- /dev/null +++ b/test/032_invertmoves/002_20moves.out @@ -0,0 +1 @@ +U' F2 B2 L' U2 L' D2 L' D F2 R F2 L2 F2 D2 R' B2 D2 R' B2 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