aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/000_basic/basic_tests.c16
-rw-r--r--test/001_pieces/pieces_tests.c4
-rw-r--r--test/020_io_cube_read_write/01_solved_oriented.in (renamed from test/020_io_cube_read_write/01_solved_oneline.in)0
-rw-r--r--test/020_io_cube_read_write/01_solved_oriented.out (renamed from test/020_io_cube_read_write/01_solved_oneline.out)0
-rw-r--r--test/020_io_cube_read_write/02_solve_misoriented.in1
-rw-r--r--test/020_io_cube_read_write/02_solve_misoriented.out1
-rw-r--r--test/020_io_cube_read_write/io_cube_tests.c2
-rw-r--r--test/030_move/move_tests.c4
-rw-r--r--test/031_premove/premove_tests.c4
-rw-r--r--test/040_inverse_cube/inverse_tests.c7
-rw-r--r--test/050_compose/compose_tests.c7
-rw-r--r--test/060_transform/transform_tests.c4
-rw-r--r--test/061_inverse_trans/inverse_trans_tests.c6
-rw-r--r--test/062_transform_move/transform_move_tests.c6
-rw-r--r--test/063_symmetry_mask/symmetry_mask_tests.c4
-rw-r--r--test/071_coord_eo/coord_eo_tests.c4
-rw-r--r--test/072_coord_co/coord_co_tests.c4
-rw-r--r--test/073_coord_csep/coord_csep_tests.c4
-rw-r--r--test/074_coord_esep/coord_esep_tests.c4
-rw-r--r--test/075_set_eo/set_eo_tests.c6
-rw-r--r--test/076_copy_corners/copy_corners_tests.c4
-rw-r--r--test/077_copy_edges/copy_edges_tests.c4
-rw-r--r--test/078_invcoord_esep/invcoord_esep_tests.c8
-rw-r--r--test/079_invcoord_co/invcoord_co_tests.c8
-rw-r--r--test/081_getcube/getcube_tests.c7
-rw-r--r--test/101_cocsep_transform_invariant/cocsep_transform_invariant.c7
-rw-r--r--test/102_cocsep_selfsim/cocsep_selfsim_tests.c5
-rw-r--r--test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c9
-rw-r--r--test/121_coorddata_dr/coorddata_dr.c7
-rw-r--r--test/122_coorddata_dreo/coorddata_dreo.c7
-rw-r--r--test/test.h15
31 files changed, 97 insertions, 72 deletions
diff --git a/test/000_basic/basic_tests.c b/test/000_basic/basic_tests.c
index accde66..df38e88 100644
--- a/test/000_basic/basic_tests.c
+++ b/test/000_basic/basic_tests.c
@@ -1,27 +1,29 @@
1#include "../test.h" 1#include "../test.h"
2 2
3bool issolved(cube_t); 3bool issolved(oriented_cube_t);
4bool equal(cube_t, cube_t); 4bool equal(cube_t, cube_t);
5 5
6void 6void
7check(cube_t cube, char *name) 7check(oriented_cube_t cube, char *name)
8{ 8{
9 printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT"); 9 printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT");
10 printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT"); 10 printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT");
11} 11}
12 12
13void 13void
14check2(cube_t cube1, char *name1, cube_t cube2, char *name2) 14check2(oriented_cube_t cube1, char *name1, oriented_cube_t cube2, char *name2)
15{ 15{
16 printf("%s and %s are%s equal\n", name1, name2, 16 bool eq = equal(cube1.cube, cube2.cube) &&
17 equal(cube1, cube2) ? "" : " NOT"); 17 cube1.orientation == cube2.orientation;
18 printf("%s and %s are%s equal\n", name1, name2, eq ? "" : " NOT");
18} 19}
19 20
20void run(void) { 21void run(void) {
21 cube_t zero, solved; 22 oriented_cube_t zero, solved;
22 23
23 memset(&zero, 0, sizeof(cube_t)); 24 memset(&zero, 0, sizeof(oriented_cube_t));
24 solved = solvedcube(); 25 solved = solvedcube();
26
25 check(solved, "Solved"); 27 check(solved, "Solved");
26 check(zero, "Zero"); 28 check(zero, "Zero");
27 29
diff --git a/test/001_pieces/pieces_tests.c b/test/001_pieces/pieces_tests.c
index 452a11b..f46a143 100644
--- a/test/001_pieces/pieces_tests.c
+++ b/test/001_pieces/pieces_tests.c
@@ -6,7 +6,7 @@ void run(void) {
6 int i; 6 int i;
7 uint8_t corner[8], edge[12]; 7 uint8_t corner[8], edge[12];
8 char str[STRLENMAX], *aux; 8 char str[STRLENMAX], *aux;
9 cube_t cube; 9 oriented_cube_t cube;
10 10
11 aux = str; 11 aux = str;
12 while (fgets(aux, STRLENMAX, stdin) != NULL) 12 while (fgets(aux, STRLENMAX, stdin) != NULL)
@@ -14,7 +14,7 @@ void run(void) {
14 aux++; 14 aux++;
15 15
16 cube = readcube(str); 16 cube = readcube(str);
17 pieces(&cube, corner, edge); 17 pieces(&cube.cube, corner, edge);
18 18
19 for (i = 0; i < 8; i++) 19 for (i = 0; i < 8; i++)
20 printf("%" PRIu8 " ", corner[i]); 20 printf("%" PRIu8 " ", corner[i]);
diff --git a/test/020_io_cube_read_write/01_solved_oneline.in b/test/020_io_cube_read_write/01_solved_oriented.in
index 5aa6ba7..5aa6ba7 100644
--- a/test/020_io_cube_read_write/01_solved_oneline.in
+++ b/test/020_io_cube_read_write/01_solved_oriented.in
diff --git a/test/020_io_cube_read_write/01_solved_oneline.out b/test/020_io_cube_read_write/01_solved_oriented.out
index 5aa6ba7..5aa6ba7 100644
--- a/test/020_io_cube_read_write/01_solved_oneline.out
+++ b/test/020_io_cube_read_write/01_solved_oriented.out
diff --git a/test/020_io_cube_read_write/02_solve_misoriented.in b/test/020_io_cube_read_write/02_solve_misoriented.in
new file mode 100644
index 0000000..f3279c5
--- /dev/null
+++ b/test/020_io_cube_read_write/02_solve_misoriented.in
@@ -0,0 +1 @@
ABCDEFGH=ABCDEFGHIJKL=L
diff --git a/test/020_io_cube_read_write/02_solve_misoriented.out b/test/020_io_cube_read_write/02_solve_misoriented.out
new file mode 100644
index 0000000..f3279c5
--- /dev/null
+++ b/test/020_io_cube_read_write/02_solve_misoriented.out
@@ -0,0 +1 @@
ABCDEFGH=ABCDEFGHIJKL=L
diff --git a/test/020_io_cube_read_write/io_cube_tests.c b/test/020_io_cube_read_write/io_cube_tests.c
index c9df1a9..3d7601c 100644
--- a/test/020_io_cube_read_write/io_cube_tests.c
+++ b/test/020_io_cube_read_write/io_cube_tests.c
@@ -2,7 +2,7 @@
2 2
3void run(void) { 3void run(void) {
4 char str[STRLENMAX], *aux; 4 char str[STRLENMAX], *aux;
5 cube_t cube; 5 oriented_cube_t cube;
6 6
7 aux = str; 7 aux = str;
8 while (fgets(aux, STRLENMAX, stdin) != NULL) 8 while (fgets(aux, STRLENMAX, stdin) != NULL)
diff --git a/test/030_move/move_tests.c b/test/030_move/move_tests.c
index e5aed44..98c9592 100644
--- a/test/030_move/move_tests.c
+++ b/test/030_move/move_tests.c
@@ -1,10 +1,10 @@
1#include "../test.h" 1#include "../test.h"
2 2
3cube_t applymoves(cube_t, char *); 3oriented_cube_t applymoves(oriented_cube_t, char *);
4 4
5void run(void) { 5void run(void) {
6 char movestr[STRLENMAX], cubestr[STRLENMAX]; 6 char movestr[STRLENMAX], cubestr[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 8
9 fgets(movestr, STRLENMAX, stdin); 9 fgets(movestr, STRLENMAX, stdin);
10 fgets(cubestr, STRLENMAX, stdin); 10 fgets(cubestr, STRLENMAX, stdin);
diff --git a/test/031_premove/premove_tests.c b/test/031_premove/premove_tests.c
index 24773cd..10bed92 100644
--- a/test/031_premove/premove_tests.c
+++ b/test/031_premove/premove_tests.c
@@ -7,14 +7,14 @@ cube_t premove(cube_t, uint8_t);
7void run(void) { 7void run(void) {
8 char movestr[STRLENMAX], cubestr[STRLENMAX]; 8 char movestr[STRLENMAX], cubestr[STRLENMAX];
9 uint8_t move; 9 uint8_t move;
10 cube_t cube; 10 oriented_cube_t cube;
11 11
12 fgets(movestr, STRLENMAX, stdin); 12 fgets(movestr, STRLENMAX, stdin);
13 move = readmove(movestr[0]) + readmodifier(movestr[1]); 13 move = readmove(movestr[0]) + readmodifier(movestr[1]);
14 fgets(cubestr, STRLENMAX, stdin); 14 fgets(cubestr, STRLENMAX, stdin);
15 cube = readcube(cubestr); 15 cube = readcube(cubestr);
16 16
17 cube = premove(cube, move); 17 cube.cube = premove(cube.cube, move);
18 18
19 if (iserror(cube)) { 19 if (iserror(cube)) {
20 printf("Error moving cube\n"); 20 printf("Error moving cube\n");
diff --git a/test/040_inverse_cube/inverse_tests.c b/test/040_inverse_cube/inverse_tests.c
index 9e8925a..f0401ea 100644
--- a/test/040_inverse_cube/inverse_tests.c
+++ b/test/040_inverse_cube/inverse_tests.c
@@ -4,11 +4,14 @@ cube_t inverse(cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube, inv; 7 oriented_cube_t cube, inv;
8 8
9 fgets(str, STRLENMAX, stdin); 9 fgets(str, STRLENMAX, stdin);
10 cube = readcube(str); 10 cube = readcube(str);
11 inv = inverse(cube); 11 inv = (oriented_cube_t) {
12 .cube = inverse(cube.cube),
13 .orientation = cube.orientation
14 };
12 15
13 if (iserror(inv)) { 16 if (iserror(inv)) {
14 printf("Error inverting cube\n"); 17 printf("Error inverting cube\n");
diff --git a/test/050_compose/compose_tests.c b/test/050_compose/compose_tests.c
index c61775f..3dea055 100644
--- a/test/050_compose/compose_tests.c
+++ b/test/050_compose/compose_tests.c
@@ -4,14 +4,17 @@ cube_t compose(cube_t, cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t c1, c2, c3; 7 oriented_cube_t c1, c2, c3;
8 8
9 fgets(str, STRLENMAX, stdin); 9 fgets(str, STRLENMAX, stdin);
10 c1 = readcube(str); 10 c1 = readcube(str);
11 fgets(str, STRLENMAX, stdin); 11 fgets(str, STRLENMAX, stdin);
12 c2 = readcube(str); 12 c2 = readcube(str);
13 13
14 c3 = compose(c1, c2); 14 c3 = (oriented_cube_t) {
15 .cube = compose(c1.cube, c2.cube),
16 .orientation = c1.orientation
17 };
15 18
16 if (iserror(c3)) { 19 if (iserror(c3)) {
17 printf("Error composing cubes\n"); 20 printf("Error composing cubes\n");
diff --git a/test/060_transform/transform_tests.c b/test/060_transform/transform_tests.c
index 4ae161c..82694b2 100644
--- a/test/060_transform/transform_tests.c
+++ b/test/060_transform/transform_tests.c
@@ -1,10 +1,10 @@
1#include "../test.h" 1#include "../test.h"
2 2
3cube_t applytrans(cube_t, char *); 3oriented_cube_t applytrans(oriented_cube_t, char *);
4 4
5void run(void) { 5void run(void) {
6 char cubestr[STRLENMAX], transtr[STRLENMAX]; 6 char cubestr[STRLENMAX], transtr[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 8
9 fgets(transtr, STRLENMAX, stdin); 9 fgets(transtr, STRLENMAX, stdin);
10 fgets(cubestr, STRLENMAX, stdin); 10 fgets(cubestr, STRLENMAX, stdin);
diff --git a/test/061_inverse_trans/inverse_trans_tests.c b/test/061_inverse_trans/inverse_trans_tests.c
index 441fef8..bad39fa 100644
--- a/test/061_inverse_trans/inverse_trans_tests.c
+++ b/test/061_inverse_trans/inverse_trans_tests.c
@@ -2,13 +2,13 @@
2 2
3uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]); 3uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]);
4uint8_t inverse_trans(uint8_t); 4uint8_t inverse_trans(uint8_t);
5cube_t applymoves(cube_t, char *); 5oriented_cube_t applymoves(oriented_cube_t, char *);
6cube_t applytrans(cube_t, char *); 6oriented_cube_t applytrans(oriented_cube_t, char *);
7extern char *transstr[]; 7extern char *transstr[];
8 8
9void run(void) { 9void run(void) {
10 uint8_t t, tinv; 10 uint8_t t, tinv;
11 cube_t cube; 11 oriented_cube_t cube;
12 12
13 for (t = 0; t < 48; t++) { 13 for (t = 0; t < 48; t++) {
14 cube = solvedcube(); 14 cube = solvedcube();
diff --git a/test/062_transform_move/transform_move_tests.c b/test/062_transform_move/transform_move_tests.c
index 66889f9..4f554c7 100644
--- a/test/062_transform_move/transform_move_tests.c
+++ b/test/062_transform_move/transform_move_tests.c
@@ -6,14 +6,14 @@ cube_t applytrans(cube_t, const char *);
6uint8_t transform_move(uint8_t, uint8_t); 6uint8_t transform_move(uint8_t, uint8_t);
7int64_t readmoves(const char *, size_t n, uint8_t [n]); 7int64_t readmoves(const char *, size_t n, uint8_t [n]);
8cube_t move(cube_t, uint8_t); 8cube_t move(cube_t, uint8_t);
9cube_t applymoves(cube_t, const char *); 9oriented_cube_t applymoves(oriented_cube_t, const char *);
10uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); 10uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]);
11 11
12void run(void) { 12void run(void) {
13 char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; 13 char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX];
14 uint8_t t, moves[MAXMOVES]; 14 uint8_t t, moves[MAXMOVES];
15 int i, n; 15 int i, n;
16 cube_t cube; 16 oriented_cube_t cube;
17 17
18 fgets(transtr, STRLENMAX, stdin); 18 fgets(transtr, STRLENMAX, stdin);
19 fgets(movestr, STRLENMAX, stdin); 19 fgets(movestr, STRLENMAX, stdin);
@@ -22,7 +22,7 @@ void run(void) {
22 n = readmoves(movestr, MAXMOVES, moves); 22 n = readmoves(movestr, MAXMOVES, moves);
23 t = readtrans(transtr); 23 t = readtrans(transtr);
24 for (i = 0; i < n; i++) 24 for (i = 0; i < n; i++)
25 cube = move(cube, transform_move(moves[i], t)); 25 cube.cube = move(cube.cube, transform_move(moves[i], t));
26 26
27 writecube(cube, STRLENMAX, cubestr); 27 writecube(cube, STRLENMAX, cubestr);
28 printf("%s\n", cubestr); 28 printf("%s\n", cubestr);
diff --git a/test/063_symmetry_mask/symmetry_mask_tests.c b/test/063_symmetry_mask/symmetry_mask_tests.c
index c14fd14..e717b12 100644
--- a/test/063_symmetry_mask/symmetry_mask_tests.c
+++ b/test/063_symmetry_mask/symmetry_mask_tests.c
@@ -5,11 +5,11 @@ uint64_t symmetry_mask(cube_t);
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 uint64_t i, result; 7 uint64_t i, result;
8 cube_t cube; 8 oriented_cube_t cube;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 cube = readcube(str); 11 cube = readcube(str);
12 result = symmetry_mask(cube); 12 result = symmetry_mask(cube.cube);
13 13
14 for (i = 0; i < 48; result >>= 1, i++) 14 for (i = 0; i < 48; result >>= 1, i++)
15 printf("%" PRIu64, result % UINT64_C(2)); 15 printf("%" PRIu64, result % UINT64_C(2));
diff --git a/test/071_coord_eo/coord_eo_tests.c b/test/071_coord_eo/coord_eo_tests.c
index 11a8ac3..360720e 100644
--- a/test/071_coord_eo/coord_eo_tests.c
+++ b/test/071_coord_eo/coord_eo_tests.c
@@ -4,13 +4,13 @@ int64_t coord_eo(cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 int64_t result; 8 int64_t result;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 cube = readcube(str); 11 cube = readcube(str);
12 12
13 result = coord_eo(cube); 13 result = coord_eo(cube.cube);
14 14
15 printf("%" PRId64 "\n", result); 15 printf("%" PRId64 "\n", result);
16} 16}
diff --git a/test/072_coord_co/coord_co_tests.c b/test/072_coord_co/coord_co_tests.c
index b1de223..440ad2e 100644
--- a/test/072_coord_co/coord_co_tests.c
+++ b/test/072_coord_co/coord_co_tests.c
@@ -4,13 +4,13 @@ int64_t coord_co(cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 int64_t result; 8 int64_t result;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 cube = readcube(str); 11 cube = readcube(str);
12 12
13 result = coord_co(cube); 13 result = coord_co(cube.cube);
14 14
15 printf("%" PRId64 "\n", result); 15 printf("%" PRId64 "\n", result);
16} 16}
diff --git a/test/073_coord_csep/coord_csep_tests.c b/test/073_coord_csep/coord_csep_tests.c
index 6fe16b2..21a3b3a 100644
--- a/test/073_coord_csep/coord_csep_tests.c
+++ b/test/073_coord_csep/coord_csep_tests.c
@@ -4,13 +4,13 @@ int64_t coord_csep(cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 int64_t result; 8 int64_t result;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 cube = readcube(str); 11 cube = readcube(str);
12 12
13 result = coord_csep(cube); 13 result = coord_csep(cube.cube);
14 14
15 printf("%" PRId64 "\n", result); 15 printf("%" PRId64 "\n", result);
16} 16}
diff --git a/test/074_coord_esep/coord_esep_tests.c b/test/074_coord_esep/coord_esep_tests.c
index 7c53c9a..679e1c6 100644
--- a/test/074_coord_esep/coord_esep_tests.c
+++ b/test/074_coord_esep/coord_esep_tests.c
@@ -4,13 +4,13 @@ int64_t coord_esep(cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 int64_t result; 8 int64_t result;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 cube = readcube(str); 11 cube = readcube(str);
12 12
13 result = coord_esep(cube); 13 result = coord_esep(cube.cube);
14 14
15 printf("%" PRId64 "\n", result); 15 printf("%" PRId64 "\n", result);
16} 16}
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c
index 2e05e9a..ef2156d 100644
--- a/test/075_set_eo/set_eo_tests.c
+++ b/test/075_set_eo/set_eo_tests.c
@@ -6,7 +6,7 @@ void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
6 6
7void run(void) { 7void run(void) {
8 char str[STRLENMAX]; 8 char str[STRLENMAX];
9 cube_t cube; 9 oriented_cube_t cube;
10 uint8_t edge[12], corner[8]; 10 uint8_t edge[12], corner[8];
11 int64_t eo; 11 int64_t eo;
12 12
@@ -15,12 +15,12 @@ void run(void) {
15 fgets(str, STRLENMAX, stdin); 15 fgets(str, STRLENMAX, stdin);
16 eo = atoi(str); 16 eo = atoi(str);
17 17
18 set_eo(&cube, eo); 18 set_eo(&cube.cube, eo);
19 19
20 if (iserror(cube)) { 20 if (iserror(cube)) {
21 printf("Error setting EO\n"); 21 printf("Error setting EO\n");
22 } else if (!isconsistent(cube)) { 22 } else if (!isconsistent(cube)) {
23 pieces(&cube, corner, edge); 23 pieces(&cube.cube, corner, edge);
24 fprintf(stderr, "edges: "); 24 fprintf(stderr, "edges: ");
25 for (int i = 0; i < 12; i++) 25 for (int i = 0; i < 12; i++)
26 fprintf(stderr, "%d ", edge[i]); 26 fprintf(stderr, "%d ", edge[i]);
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c
index 94e2a2a..02e949b 100644
--- a/test/076_copy_corners/copy_corners_tests.c
+++ b/test/076_copy_corners/copy_corners_tests.c
@@ -4,7 +4,7 @@ void copy_corners(cube_t *, cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t c1, c2; 7 oriented_cube_t c1, c2;
8 8
9 fgets(str, STRLENMAX, stdin); 9 fgets(str, STRLENMAX, stdin);
10 c1 = readcube(str); 10 c1 = readcube(str);
@@ -12,7 +12,7 @@ void run(void) {
12 fgets(str, STRLENMAX, stdin); 12 fgets(str, STRLENMAX, stdin);
13 c2 = readcube(str); 13 c2 = readcube(str);
14 14
15 copy_corners(&c1, c2); 15 copy_corners(&c1.cube, c2.cube);
16 16
17 if (iserror(c1)) { 17 if (iserror(c1)) {
18 printf("Error setting EO\n"); 18 printf("Error setting EO\n");
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c
index 36e32af..f3b0589 100644
--- a/test/077_copy_edges/copy_edges_tests.c
+++ b/test/077_copy_edges/copy_edges_tests.c
@@ -4,7 +4,7 @@ void copy_edges(cube_t *, cube_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t c1, c2; 7 oriented_cube_t c1, c2;
8 8
9 fgets(str, STRLENMAX, stdin); 9 fgets(str, STRLENMAX, stdin);
10 c1 = readcube(str); 10 c1 = readcube(str);
@@ -12,7 +12,7 @@ void run(void) {
12 fgets(str, STRLENMAX, stdin); 12 fgets(str, STRLENMAX, stdin);
13 c2 = readcube(str); 13 c2 = readcube(str);
14 14
15 copy_edges(&c1, c2); 15 copy_edges(&c1.cube, c2.cube);
16 16
17 if (iserror(c1)) { 17 if (iserror(c1)) {
18 printf("Error setting EO\n"); 18 printf("Error setting EO\n");
diff --git a/test/078_invcoord_esep/invcoord_esep_tests.c b/test/078_invcoord_esep/invcoord_esep_tests.c
index ebf35b0..9945e77 100644
--- a/test/078_invcoord_esep/invcoord_esep_tests.c
+++ b/test/078_invcoord_esep/invcoord_esep_tests.c
@@ -5,15 +5,15 @@ cube_t invcoord_esep(int64_t);
5 5
6void run(void) { 6void run(void) {
7 char str[STRLENMAX]; 7 char str[STRLENMAX];
8 cube_t cube; 8 oriented_cube_t cube;
9 int64_t i; 9 int64_t i;
10 10
11 fgets(str, STRLENMAX, stdin); 11 fgets(str, STRLENMAX, stdin);
12 cube = readcube(str); 12 cube = readcube(str);
13 13
14 i = coord_esep(cube); 14 i = coord_esep(cube.cube);
15 cube = invcoord_esep(i); 15 cube.cube = invcoord_esep(i);
16 i = coord_esep(cube); 16 i = coord_esep(cube.cube);
17 17
18 printf("%" PRId64 "\n", i); 18 printf("%" PRId64 "\n", i);
19} 19}
diff --git a/test/079_invcoord_co/invcoord_co_tests.c b/test/079_invcoord_co/invcoord_co_tests.c
index 9f7c3d5..fcd68d0 100644
--- a/test/079_invcoord_co/invcoord_co_tests.c
+++ b/test/079_invcoord_co/invcoord_co_tests.c
@@ -6,12 +6,14 @@ int64_t coord_co(cube_t);
6cube_t invcoord_co(int64_t); 6cube_t invcoord_co(int64_t);
7 7
8void run(void) { 8void run(void) {
9 cube_t cube; 9 oriented_cube_t cube;
10 int64_t coord, coord2; 10 int64_t coord, coord2;
11 11
12 cube.orientation = 0;
13
12 /* Test all possible values for CO coordinate */ 14 /* Test all possible values for CO coordinate */
13 for (coord = 0; coord < POW_3_7; coord++) { 15 for (coord = 0; coord < POW_3_7; coord++) {
14 cube = invcoord_co(coord); 16 cube.cube = invcoord_co(coord);
15 17
16 if (!isconsistent(cube)) { 18 if (!isconsistent(cube)) {
17 printf("Not consistent\n"); 19 printf("Not consistent\n");
@@ -22,7 +24,7 @@ void run(void) {
22 return; 24 return;
23 } 25 }
24 26
25 coord2 = coord_co(cube); 27 coord2 = coord_co(cube.cube);
26 if (coord != coord2) { 28 if (coord != coord2) {
27 printf("Error: invcoord of %" PRId64 29 printf("Error: invcoord of %" PRId64
28 " returns %" PRId64 "\n", coord, coord2); 30 " returns %" PRId64 "\n", coord, coord2);
diff --git a/test/081_getcube/getcube_tests.c b/test/081_getcube/getcube_tests.c
index 916c42b..07e621e 100644
--- a/test/081_getcube/getcube_tests.c
+++ b/test/081_getcube/getcube_tests.c
@@ -4,7 +4,7 @@ cube_t getcube(int64_t, int64_t, int64_t, int64_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 cube_t cube; 7 oriented_cube_t cube;
8 int64_t ep, eo, cp, co; 8 int64_t ep, eo, cp, co;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
@@ -16,7 +16,10 @@ void run(void) {
16 fgets(str, STRLENMAX, stdin); 16 fgets(str, STRLENMAX, stdin);
17 co = atoll(str); 17 co = atoll(str);
18 18
19 cube = getcube(ep, eo, cp, co); 19 cube = (oriented_cube_t) {
20 .cube = getcube(ep, eo, cp, co),
21 .orientation = 0
22 };
20 23
21 if (iserror(cube)) { 24 if (iserror(cube)) {
22 printf("Error cube\n"); 25 printf("Error cube\n");
diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
index 7ded2e9..5553fd1 100644
--- a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
+++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
@@ -11,7 +11,8 @@ void run(void) {
11 uint64_t selfsim[COCSEP_CLASSES]; 11 uint64_t selfsim[COCSEP_CLASSES];
12 int64_t coord, tcoord; 12 int64_t coord, tcoord;
13 char str[STRLENMAX]; 13 char str[STRLENMAX];
14 cube_t cube, transd, rep[COCSEP_CLASSES]; 14 oriented_cube_t cube;
15 cube_t rep[COCSEP_CLASSES], transd;
15 16
16 fgets(str, STRLENMAX, stdin); 17 fgets(str, STRLENMAX, stdin);
17 cube = readcube(str); 18 cube = readcube(str);
@@ -19,9 +20,9 @@ void run(void) {
19 gendata_cocsep(buf, selfsim, rep); 20 gendata_cocsep(buf, selfsim, rep);
20 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); 21 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
21 22
22 coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube)]); 23 coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube.cube)]);
23 for (t = 0; t < 48; t++) { 24 for (t = 0; t < 48; t++) {
24 transd = transform(cube, t); 25 transd = transform(cube.cube, t);
25 tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]); 26 tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]);
26 if (coord != tcoord) 27 if (coord != tcoord)
27 printf("Error: expected %" PRId64 28 printf("Error: expected %" PRId64
diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
index 9966321..1a1c6f2 100644
--- a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
+++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
@@ -16,7 +16,8 @@ void run(void) {
16 uint32_t *cocsepdata, data; 16 uint32_t *cocsepdata, data;
17 int64_t coord, coclass; 17 int64_t coord, coclass;
18 uint64_t selfsim[COCSEP_CLASSES], sim, t; 18 uint64_t selfsim[COCSEP_CLASSES], sim, t;
19 cube_t cube, rep[COCSEP_CLASSES]; 19 oriented_cube_t cube;
20 cube_t rep[COCSEP_CLASSES];
20 21
21 gendata_cocsep(buf, selfsim, rep); 22 gendata_cocsep(buf, selfsim, rep);
22 cocsepdata = (uint32_t *)(buf + INFOSIZE); 23 cocsepdata = (uint32_t *)(buf + INFOSIZE);
@@ -25,7 +26,7 @@ void run(void) {
25 26
26 while (fgets(str, STRLENMAX, stdin) != NULL) { 27 while (fgets(str, STRLENMAX, stdin) != NULL) {
27 cube = readcube(str); 28 cube = readcube(str);
28 coord = coord_cocsep(cube); 29 coord = coord_cocsep(cube.cube);
29 data = cocsepdata[coord]; 30 data = cocsepdata[coord];
30 coclass = (data & (0xFFFU << 16)) >> 16; 31 coclass = (data & (0xFFFU << 16)) >> 16;
31 sim = selfsim[coclass]; 32 sim = selfsim[coclass];
diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
index 458ad31..0333f27 100644
--- a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
+++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
@@ -14,7 +14,8 @@ void run(void) {
14 uint32_t *cocsepdata; 14 uint32_t *cocsepdata;
15 uint64_t selfsim[COCSEP_CLASSES]; 15 uint64_t selfsim[COCSEP_CLASSES];
16 int64_t c, cc; 16 int64_t c, cc;
17 cube_t cube, invc, rep[COCSEP_CLASSES]; 17 oriented_cube_t cube;
18 cube_t invc, rep[COCSEP_CLASSES];
18 19
19 gendata_cocsep(buf, selfsim, rep); 20 gendata_cocsep(buf, selfsim, rep);
20 cocsepdata = (uint32_t *)(buf + INFOSIZE); 21 cocsepdata = (uint32_t *)(buf + INFOSIZE);
@@ -23,11 +24,11 @@ void run(void) {
23 h = 11; 24 h = 11;
24 while (fgets(str, STRLENMAX, stdin) != NULL) { 25 while (fgets(str, STRLENMAX, stdin) != NULL) {
25 cube = readcube(str); 26 cube = readcube(str);
26 c = coord_h48(cube, cocsepdata, h); 27 c = coord_h48(cube.cube, cocsepdata, h);
27 invc = invcoord_h48(c, rep, h); 28 invc = invcoord_h48(c, rep, h);
28 for (t = 0, found = false; t < 48; t++) { 29 for (t = 0, found = false; t < 48; t++) {
29 cube = transform(invc, t); 30 cube.cube = transform(invc, t);
30 cc = coord_h48(cube, cocsepdata, h); 31 cc = coord_h48(cube.cube, cocsepdata, h);
31 found = found || cc == c; 32 found = found || cc == c;
32 } 33 }
33 printf("%d %s\n", i, found ? "ok" : "ERROR"); 34 printf("%d %s\n", i, found ? "ok" : "ERROR");
diff --git a/test/121_coorddata_dr/coorddata_dr.c b/test/121_coorddata_dr/coorddata_dr.c
index d7efcfb..e8407c8 100644
--- a/test/121_coorddata_dr/coorddata_dr.c
+++ b/test/121_coorddata_dr/coorddata_dr.c
@@ -16,6 +16,7 @@ void run(void) {
16 unsigned char *data; 16 unsigned char *data;
17 size_t size; 17 size_t size;
18 cube_t cube; 18 cube_t cube;
19 oriented_cube_t oc;
19 uint64_t coord, coord2; 20 uint64_t coord, coord2;
20 21
21 size = coordinate_dr_gendata(NULL); 22 size = coordinate_dr_gendata(NULL);
@@ -25,7 +26,8 @@ void run(void) {
25 for (coord = 0; coord < BOUND; coord++) { 26 for (coord = 0; coord < BOUND; coord++) {
26 cube = coordinate_dr_cube(coord, data); 27 cube = coordinate_dr_cube(coord, data);
27 28
28 if (!isconsistent(cube)) { 29 oc = (oriented_cube_t) { .cube = cube, .orientation = 0 };
30 if (!isconsistent(oc)) {
29 printf("Error: invcoord of %" PRId64 31 printf("Error: invcoord of %" PRId64
30 " is not consistent\n", coord); 32 " is not consistent\n", coord);
31 goto cleanup; 33 goto cleanup;
@@ -43,9 +45,10 @@ void run(void) {
43 } 45 }
44 46
45 if (!found) { 47 if (!found) {
48 oc = (oriented_cube_t){.cube = cube, .orientation = 0};
46 printf("Error: invcoord of %" PRId64 " returns %" 49 printf("Error: invcoord of %" PRId64 " returns %"
47 PRId64 " with cube:\n", coord, coord2); 50 PRId64 " with cube:\n", coord, coord2);
48 writecube(cube, STRLENMAX, str); 51 writecube(oc, STRLENMAX, str);
49 printf("%s\n", str); 52 printf("%s\n", str);
50 goto cleanup; 53 goto cleanup;
51 } 54 }
diff --git a/test/122_coorddata_dreo/coorddata_dreo.c b/test/122_coorddata_dreo/coorddata_dreo.c
index 98c954d..942e837 100644
--- a/test/122_coorddata_dreo/coorddata_dreo.c
+++ b/test/122_coorddata_dreo/coorddata_dreo.c
@@ -16,6 +16,7 @@ void run(void) {
16 unsigned char *data; 16 unsigned char *data;
17 size_t size; 17 size_t size;
18 cube_t cube; 18 cube_t cube;
19 oriented_cube_t oc;
19 uint64_t coord, coord2; 20 uint64_t coord, coord2;
20 21
21 size = coordinate_dreo_gendata(NULL); 22 size = coordinate_dreo_gendata(NULL);
@@ -25,7 +26,8 @@ void run(void) {
25 for (coord = 0; coord < BOUND; coord++) { 26 for (coord = 0; coord < BOUND; coord++) {
26 cube = coordinate_dreo_cube(coord, data); 27 cube = coordinate_dreo_cube(coord, data);
27 28
28 if (!isconsistent(cube)) { 29 oc = (oriented_cube_t) { .cube = cube, .orientation = 0 };
30 if (!isconsistent(oc)) {
29 printf("Error: invcoord of %" PRId64 31 printf("Error: invcoord of %" PRId64
30 " is not consistent\n", coord); 32 " is not consistent\n", coord);
31 goto cleanup; 33 goto cleanup;
@@ -43,9 +45,10 @@ void run(void) {
43 } 45 }
44 46
45 if (!found) { 47 if (!found) {
48 oc = (oriented_cube_t){.cube = cube, .orientation = 0};
46 printf("Error: invcoord of %" PRId64 " returns %" 49 printf("Error: invcoord of %" PRId64 " returns %"
47 PRId64 " with cube:\n", coord, coord2); 50 PRId64 " with cube:\n", coord, coord2);
48 writecube(cube, STRLENMAX, str); 51 writecube(oc, STRLENMAX, str);
49 printf("%s\n", str); 52 printf("%s\n", str);
50 goto cleanup; 53 goto cleanup;
51 } 54 }
diff --git a/test/test.h b/test/test.h
index 78a3fd9..6230f36 100644
--- a/test/test.h
+++ b/test/test.h
@@ -10,6 +10,7 @@
10 10
11#include "../src/nissy.h" 11#include "../src/nissy.h"
12#include "../src/arch/arch.h" 12#include "../src/arch/arch.h"
13#include "../src/core/core_types.h"
13#include "../src/solvers/solutions_types_macros.h" 14#include "../src/solvers/solutions_types_macros.h"
14#include "../src/solvers/tables_types_macros.h" 15#include "../src/solvers/tables_types_macros.h"
15#include "../src/solvers/h48/coordinate_types_macros.h" 16#include "../src/solvers/h48/coordinate_types_macros.h"
@@ -20,13 +21,13 @@
20#define STRLENMAX 10000 21#define STRLENMAX 10000
21 22
22/* Basic functions used in most tests */ 23/* Basic functions used in most tests */
23cube_t solvedcube(void); 24oriented_cube_t solvedcube(void);
24bool iserror(cube_t); 25bool iserror(oriented_cube_t);
25bool isconsistent(cube_t); 26bool isconsistent(oriented_cube_t);
26bool issolvable(cube_t); 27bool issolvable(oriented_cube_t);
27bool issolved(cube_t); 28bool issolved(oriented_cube_t);
28cube_t readcube(char *); 29oriented_cube_t readcube(char *);
29int64_t writecube(cube_t, size_t n, char [n]); 30int64_t writecube(oriented_cube_t, size_t n, char [n]);
30 31
31/* Test function to be implemented by all tests */ 32/* Test function to be implemented by all tests */
32void run(void); 33void run(void);

Generated with cgit - Back to sebastiano.tronto.net