diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-17 17:42:43 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-17 17:42:43 +0200 |
| commit | 1809d7b212128fcdcb481002a17db5dc97a15e03 (patch) | |
| tree | 4e045b4fefc5e229969891b0e1963dd683bd46ad /test | |
| parent | d26d9e46d305b3ab3c6ae3b55f1859cf413a1c94 (diff) | |
| download | nissy-core-1809d7b212128fcdcb481002a17db5dc97a15e03.tar.gz nissy-core-1809d7b212128fcdcb481002a17db5dc97a15e03.zip | |
Added inverse eo and copy_{edges,corners}
Diffstat (limited to '')
| -rw-r--r-- | test/075_set_eo/00_solved_0.in | 2 | ||||
| -rw-r--r-- | test/075_set_eo/00_solved_0.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/01_solved_1.in | 2 | ||||
| -rw-r--r-- | test/075_set_eo/01_solved_1.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/02_solved_other.in | 2 | ||||
| -rw-r--r-- | test/075_set_eo/02_solved_other.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/03_solved_firstlast.in | 2 | ||||
| -rw-r--r-- | test/075_set_eo/03_solved_firstlast.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/10_scrambled_0.in | 4 | ||||
| -rw-r--r-- | test/075_set_eo/10_scrambled_0.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/11_scrambled_1.in | 4 | ||||
| -rw-r--r-- | test/075_set_eo/11_scrambled_1.out | 1 | ||||
| -rw-r--r-- | test/075_set_eo/set_eo_tests.c | 38 | ||||
| -rw-r--r-- | test/076_copy_corners/00_solved_scrambled.in | 2 | ||||
| -rw-r--r-- | test/076_copy_corners/00_solved_scrambled.out | 1 | ||||
| -rw-r--r-- | test/076_copy_corners/copy_corners_tests.c | 33 | ||||
| -rw-r--r-- | test/077_copy_edges/00_solved_scrambled.in | 2 | ||||
| -rw-r--r-- | test/077_copy_edges/00_solved_scrambled.out | 1 | ||||
| -rw-r--r-- | test/077_copy_edges/copy_edges_tests.c | 33 | ||||
| -rwxr-xr-x | test/test | 41 | ||||
| -rw-r--r-- | test/test.h | 1 |
21 files changed, 174 insertions, 0 deletions
diff --git a/test/075_set_eo/00_solved_0.in b/test/075_set_eo/00_solved_0.in new file mode 100644 index 0000000..55bb6bf --- /dev/null +++ b/test/075_set_eo/00_solved_0.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | 0 | ||
diff --git a/test/075_set_eo/00_solved_0.out b/test/075_set_eo/00_solved_0.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/075_set_eo/00_solved_0.out | |||
| @@ -0,0 +1 @@ | |||
| UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/075_set_eo/01_solved_1.in b/test/075_set_eo/01_solved_1.in new file mode 100644 index 0000000..edd864e --- /dev/null +++ b/test/075_set_eo/01_solved_1.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | 2047 | ||
diff --git a/test/075_set_eo/01_solved_1.out b/test/075_set_eo/01_solved_1.out new file mode 100644 index 0000000..ec7594a --- /dev/null +++ b/test/075_set_eo/01_solved_1.out | |||
| @@ -0,0 +1 @@ | |||
| UF1 UB1 DB1 DF1 UR1 UL1 DL1 DR1 FR1 FL1 BL1 BR1 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/075_set_eo/02_solved_other.in b/test/075_set_eo/02_solved_other.in new file mode 100644 index 0000000..17e9b02 --- /dev/null +++ b/test/075_set_eo/02_solved_other.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | 20 | ||
diff --git a/test/075_set_eo/02_solved_other.out b/test/075_set_eo/02_solved_other.out new file mode 100644 index 0000000..df73ef8 --- /dev/null +++ b/test/075_set_eo/02_solved_other.out | |||
| @@ -0,0 +1 @@ | |||
| UF0 UB0 DB0 DF1 UR0 UL1 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/075_set_eo/03_solved_firstlast.in b/test/075_set_eo/03_solved_firstlast.in new file mode 100644 index 0000000..a16a192 --- /dev/null +++ b/test/075_set_eo/03_solved_firstlast.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | 1024 | ||
diff --git a/test/075_set_eo/03_solved_firstlast.out b/test/075_set_eo/03_solved_firstlast.out new file mode 100644 index 0000000..8679be3 --- /dev/null +++ b/test/075_set_eo/03_solved_firstlast.out | |||
| @@ -0,0 +1 @@ | |||
| UF1 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR1 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/075_set_eo/10_scrambled_0.in b/test/075_set_eo/10_scrambled_0.in new file mode 100644 index 0000000..55dccca --- /dev/null +++ b/test/075_set_eo/10_scrambled_0.in | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | ||
| 2 | 0 | ||
| 3 | |||
| 4 | // Scramble: U R D' L D' F L2 D L F B D2 B' L2 F U2 L2 D2 R2 L2 B' | ||
diff --git a/test/075_set_eo/10_scrambled_0.out b/test/075_set_eo/10_scrambled_0.out new file mode 100644 index 0000000..0eabd6e --- /dev/null +++ b/test/075_set_eo/10_scrambled_0.out | |||
| @@ -0,0 +1 @@ | |||
| UL0 BL0 BR0 DL0 FR0 DF0 DB0 DR0 UB0 FL0 UF0 UR0 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | |||
diff --git a/test/075_set_eo/11_scrambled_1.in b/test/075_set_eo/11_scrambled_1.in new file mode 100644 index 0000000..0037a04 --- /dev/null +++ b/test/075_set_eo/11_scrambled_1.in | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | ||
| 2 | 2047 | ||
| 3 | |||
| 4 | // Scramble: U R D' L D' F L2 D L F B D2 B' L2 F U2 L2 D2 R2 L2 B' | ||
diff --git a/test/075_set_eo/11_scrambled_1.out b/test/075_set_eo/11_scrambled_1.out new file mode 100644 index 0000000..843df0d --- /dev/null +++ b/test/075_set_eo/11_scrambled_1.out | |||
| @@ -0,0 +1 @@ | |||
| UL1 BL1 BR1 DL1 FR1 DF1 DB1 DR1 UB1 FL1 UF1 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | |||
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c new file mode 100644 index 0000000..ef7215a --- /dev/null +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | int64_t coord_fast_eo(cube_fast_t); | ||
| 4 | void set_eo_fast(cube_fast_t *, int64_t); | ||
| 5 | cube_fast_t cubetofast(cube_t); | ||
| 6 | cube_t fasttocube(cube_fast_t); | ||
| 7 | |||
| 8 | int main(void) { | ||
| 9 | char str[STRLENMAX]; | ||
| 10 | cube_t cube; | ||
| 11 | cube_fast_t fast; | ||
| 12 | int64_t eo; | ||
| 13 | |||
| 14 | fgets(str, STRLENMAX, stdin); | ||
| 15 | cube = readcube("H48", str); | ||
| 16 | fast = cubetofast(cube); | ||
| 17 | fgets(str, STRLENMAX, stdin); | ||
| 18 | eo = atoi(str); | ||
| 19 | |||
| 20 | set_eo_fast(&fast, eo); | ||
| 21 | |||
| 22 | cube = fasttocube(fast); | ||
| 23 | if (iserror(cube)) { | ||
| 24 | printf("Error setting EO\n"); | ||
| 25 | } else if (!isconsistent(cube)) { | ||
| 26 | fprintf(stderr, "edges: "); | ||
| 27 | for (int i = 0; i < 12; i++) fprintf(stderr, "%d ", cube.edge[i]); | ||
| 28 | fprintf(stderr, "\n"); | ||
| 29 | for (int i = 0; i < 8; i++) fprintf(stderr, "%d ", cube.corner[i]); | ||
| 30 | fprintf(stderr, "\n"); | ||
| 31 | printf("Setting EO resulted in inconsistent cube\n"); | ||
| 32 | } else { | ||
| 33 | writecube("H48", cube, str); | ||
| 34 | printf("%s\n", str); | ||
| 35 | } | ||
| 36 | |||
| 37 | return 0; | ||
| 38 | } | ||
diff --git a/test/076_copy_corners/00_solved_scrambled.in b/test/076_copy_corners/00_solved_scrambled.in new file mode 100644 index 0000000..2ff0e6a --- /dev/null +++ b/test/076_copy_corners/00_solved_scrambled.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | ||
diff --git a/test/076_copy_corners/00_solved_scrambled.out b/test/076_copy_corners/00_solved_scrambled.out new file mode 100644 index 0000000..9c53bcc --- /dev/null +++ b/test/076_copy_corners/00_solved_scrambled.out | |||
| @@ -0,0 +1 @@ | |||
| UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | |||
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c new file mode 100644 index 0000000..fecf14a --- /dev/null +++ b/test/076_copy_corners/copy_corners_tests.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | void copy_corners_fast(cube_fast_t *, cube_fast_t); | ||
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | cube_t fasttocube(cube_fast_t); | ||
| 6 | |||
| 7 | int main(void) { | ||
| 8 | char str[STRLENMAX]; | ||
| 9 | cube_t c1, c2; | ||
| 10 | cube_fast_t f1, f2; | ||
| 11 | |||
| 12 | fgets(str, STRLENMAX, stdin); | ||
| 13 | c1 = readcube("H48", str); | ||
| 14 | f1 = cubetofast(c1); | ||
| 15 | |||
| 16 | fgets(str, STRLENMAX, stdin); | ||
| 17 | c2 = readcube("H48", str); | ||
| 18 | f2 = cubetofast(c2); | ||
| 19 | |||
| 20 | copy_corners_fast(&f1, f2); | ||
| 21 | |||
| 22 | c1 = fasttocube(f1); | ||
| 23 | if (iserror(c1)) { | ||
| 24 | printf("Error setting EO\n"); | ||
| 25 | } else if (!isconsistent(c1)) { | ||
| 26 | printf("Setting EO resulted in inconsistent cube\n"); | ||
| 27 | } else { | ||
| 28 | writecube("H48", c1, str); | ||
| 29 | printf("%s\n", str); | ||
| 30 | } | ||
| 31 | |||
| 32 | return 0; | ||
| 33 | } | ||
diff --git a/test/077_copy_edges/00_solved_scrambled.in b/test/077_copy_edges/00_solved_scrambled.in new file mode 100644 index 0000000..2ff0e6a --- /dev/null +++ b/test/077_copy_edges/00_solved_scrambled.in | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | ||
diff --git a/test/077_copy_edges/00_solved_scrambled.out b/test/077_copy_edges/00_solved_scrambled.out new file mode 100644 index 0000000..3af84f4 --- /dev/null +++ b/test/077_copy_edges/00_solved_scrambled.out | |||
| @@ -0,0 +1 @@ | |||
| UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c new file mode 100644 index 0000000..c3e70a3 --- /dev/null +++ b/test/077_copy_edges/copy_edges_tests.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | void copy_edges_fast(cube_fast_t *, cube_fast_t); | ||
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | cube_t fasttocube(cube_fast_t); | ||
| 6 | |||
| 7 | int main(void) { | ||
| 8 | char str[STRLENMAX]; | ||
| 9 | cube_t c1, c2; | ||
| 10 | cube_fast_t f1, f2; | ||
| 11 | |||
| 12 | fgets(str, STRLENMAX, stdin); | ||
| 13 | c1 = readcube("H48", str); | ||
| 14 | f1 = cubetofast(c1); | ||
| 15 | |||
| 16 | fgets(str, STRLENMAX, stdin); | ||
| 17 | c2 = readcube("H48", str); | ||
| 18 | f2 = cubetofast(c2); | ||
| 19 | |||
| 20 | copy_edges_fast(&f1, f2); | ||
| 21 | |||
| 22 | c1 = fasttocube(f1); | ||
| 23 | if (iserror(c1)) { | ||
| 24 | printf("Error setting EO\n"); | ||
| 25 | } else if (!isconsistent(c1)) { | ||
| 26 | printf("Setting EO resulted in inconsistent cube\n"); | ||
| 27 | } else { | ||
| 28 | writecube("H48", c1, str); | ||
| 29 | printf("%s\n", str); | ||
| 30 | } | ||
| 31 | |||
| 32 | return 0; | ||
| 33 | } | ||
diff --git a/test/test b/test/test new file mode 100755 index 0000000..3adee3a --- /dev/null +++ b/test/test | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | |||
| 5 | re="${TEST:-$@}" | ||
| 6 | |||
| 7 | CC="cc -DDEBUG -std=c99 -pedantic -Wall -Wextra \ | ||
| 8 | -Wno-unused-parameter -Wno-unused-function -g3 -D$CUBETYPE" | ||
| 9 | |||
| 10 | [ "$CUBETYPE" = "CUBE_AVX2" ] && CC="$CC -mavx2" | ||
| 11 | [ -n "$(detectsan address)" ] && CC="$CC -fsanitize=address" | ||
| 12 | [ -n "$(detectsan undefined)" ] && CC="$CC -fsanitize=undefined" | ||
| 13 | |||
| 14 | TESTBIN="test/run" | ||
| 15 | TESTOUT="test/last.out" | ||
| 16 | TESTERR="test/last.err" | ||
| 17 | CUBEOBJ="debugcube.o" | ||
| 18 | |||
| 19 | for t in test/*; do | ||
| 20 | if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then | ||
| 21 | continue | ||
| 22 | fi | ||
| 23 | if [ ! -d $t ]; then continue; fi | ||
| 24 | $CC -o $TESTBIN $t/*.c $CUBEOBJ || exit 1; | ||
| 25 | for cin in $t/*.in; do | ||
| 26 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 27 | cout=$c.out | ||
| 28 | printf "$c: " | ||
| 29 | $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR | ||
| 30 | if diff $cout $TESTOUT; then | ||
| 31 | printf "OK\n" | ||
| 32 | else | ||
| 33 | printf "Test failed! stderr:\n" | ||
| 34 | cat $TESTERR | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | done | ||
| 38 | done | ||
| 39 | |||
| 40 | echo "All tests passed!" | ||
| 41 | rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ | ||
diff --git a/test/test.h b/test/test.h index 3cbfd10..2086283 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -21,6 +21,7 @@ typedef cube_t cube_fast_t; | |||
| 21 | /* Basic functions used in most tests */ | 21 | /* Basic functions used in most tests */ |
| 22 | cube_t solvedcube(void); | 22 | cube_t solvedcube(void); |
| 23 | bool iserror(cube_t); | 23 | bool iserror(cube_t); |
| 24 | bool isconsistent(cube_t); | ||
| 24 | bool issolvable(cube_t); | 25 | bool issolvable(cube_t); |
| 25 | bool issolved(cube_t); | 26 | bool issolved(cube_t); |
| 26 | cube_t readcube(char *, char *); | 27 | cube_t readcube(char *, char *); |
