aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/075_set_eo/00_solved_0.in2
-rw-r--r--test/075_set_eo/00_solved_0.out1
-rw-r--r--test/075_set_eo/01_solved_1.in2
-rw-r--r--test/075_set_eo/01_solved_1.out1
-rw-r--r--test/075_set_eo/02_solved_other.in2
-rw-r--r--test/075_set_eo/02_solved_other.out1
-rw-r--r--test/075_set_eo/03_solved_firstlast.in2
-rw-r--r--test/075_set_eo/03_solved_firstlast.out1
-rw-r--r--test/075_set_eo/10_scrambled_0.in4
-rw-r--r--test/075_set_eo/10_scrambled_0.out1
-rw-r--r--test/075_set_eo/11_scrambled_1.in4
-rw-r--r--test/075_set_eo/11_scrambled_1.out1
-rw-r--r--test/075_set_eo/set_eo_tests.c38
-rw-r--r--test/076_copy_corners/00_solved_scrambled.in2
-rw-r--r--test/076_copy_corners/00_solved_scrambled.out1
-rw-r--r--test/076_copy_corners/copy_corners_tests.c33
-rw-r--r--test/077_copy_edges/00_solved_scrambled.in2
-rw-r--r--test/077_copy_edges/00_solved_scrambled.out1
-rw-r--r--test/077_copy_edges/copy_edges_tests.c33
-rwxr-xr-xtest/test41
-rw-r--r--test/test.h1
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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
20
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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
22047
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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
220
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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
21024
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 @@
1UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2
20
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 @@
1UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2
22047
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
3int64_t coord_fast_eo(cube_fast_t);
4void set_eo_fast(cube_fast_t *, int64_t);
5cube_fast_t cubetofast(cube_t);
6cube_t fasttocube(cube_fast_t);
7
8int 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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
2UL0 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
3void copy_corners_fast(cube_fast_t *, cube_fast_t);
4cube_fast_t cubetofast(cube_t);
5cube_t fasttocube(cube_fast_t);
6
7int 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 @@
1UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
2UL0 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
3void copy_edges_fast(cube_fast_t *, cube_fast_t);
4cube_fast_t cubetofast(cube_t);
5cube_t fasttocube(cube_fast_t);
6
7int 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
3detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; }
4
5re="${TEST:-$@}"
6
7CC="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
14TESTBIN="test/run"
15TESTOUT="test/last.out"
16TESTERR="test/last.err"
17CUBEOBJ="debugcube.o"
18
19for 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
38done
39
40echo "All tests passed!"
41rm -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 */
22cube_t solvedcube(void); 22cube_t solvedcube(void);
23bool iserror(cube_t); 23bool iserror(cube_t);
24bool isconsistent(cube_t);
24bool issolvable(cube_t); 25bool issolvable(cube_t);
25bool issolved(cube_t); 26bool issolved(cube_t);
26cube_t readcube(char *, char *); 27cube_t readcube(char *, char *);

Generated with cgit - Back to sebastiano.tronto.net