aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-22 06:43:11 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-22 18:45:47 +0100
commitce3f1cc0ef9f46d70ab5387b1458e9098b40711d (patch)
tree4949745670b829f2211381bf14b8440dcc6ca7b1 /test
parent0550a16c1cce868bbc3f3b5ad59f80e35cf2a6cd (diff)
downloadnissy-core-ce3f1cc0ef9f46d70ab5387b1458e9098b40711d.tar.gz
nissy-core-ce3f1cc0ef9f46d70ab5387b1458e9098b40711d.zip
Some safety with move arrays, small refactor appendchar
Diffstat (limited to 'test')
-rw-r--r--test/010_math_permtoindex/permtoindex_tests.c4
-rw-r--r--test/011_math_indextoperm/indextoperm_tests.c2
-rw-r--r--test/012_math_permsign/permsign_tests.c4
-rw-r--r--test/013_math_digitstosumzero/digitstosumzero_tests.c7
-rw-r--r--test/014_math_sumzerotodigits/sumzerotodigits.c2
-rw-r--r--test/032_invertmoves/invertmoves_tests.c8
-rw-r--r--test/080_allowednext/allowednext_tests.c4
-rw-r--r--test/test.h2
8 files changed, 17 insertions, 16 deletions
diff --git a/test/010_math_permtoindex/permtoindex_tests.c b/test/010_math_permtoindex/permtoindex_tests.c
index 98c8207..ff61945 100644
--- a/test/010_math_permtoindex/permtoindex_tests.c
+++ b/test/010_math_permtoindex/permtoindex_tests.c
@@ -1,6 +1,6 @@
1#include "../test.h" 1#include "../test.h"
2 2
3int64_t permtoindex(uint8_t *, int64_t); 3int64_t permtoindex(size_t n, const uint8_t [n]);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
@@ -14,6 +14,6 @@ void run(void) {
14 a[i] = atoi(str); 14 a[i] = atoi(str);
15 } 15 }
16 16
17 p = permtoindex(a, n); 17 p = permtoindex(n, a);
18 printf("%" PRId64 "\n", p); 18 printf("%" PRId64 "\n", p);
19} 19}
diff --git a/test/011_math_indextoperm/indextoperm_tests.c b/test/011_math_indextoperm/indextoperm_tests.c
index cb1306d..87399ef 100644
--- a/test/011_math_indextoperm/indextoperm_tests.c
+++ b/test/011_math_indextoperm/indextoperm_tests.c
@@ -1,6 +1,6 @@
1#include "../test.h" 1#include "../test.h"
2 2
3void indextoperm(int64_t, int64_t, uint8_t *); 3void indextoperm(int64_t, size_t n, uint8_t [n]);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
diff --git a/test/012_math_permsign/permsign_tests.c b/test/012_math_permsign/permsign_tests.c
index fa8ce9b..0ec22af 100644
--- a/test/012_math_permsign/permsign_tests.c
+++ b/test/012_math_permsign/permsign_tests.c
@@ -1,6 +1,6 @@
1#include "../test.h" 1#include "../test.h"
2 2
3int permsign(uint8_t *, int64_t); 3int permsign(size_t n, const uint8_t [n]);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
@@ -16,6 +16,6 @@ void run(void) {
16 a[i] = atoi(str); 16 a[i] = atoi(str);
17 } 17 }
18 18
19 p = permsign(a, n); 19 p = permsign(n, a);
20 printf("%d\n", p); 20 printf("%d\n", p);
21} 21}
diff --git a/test/013_math_digitstosumzero/digitstosumzero_tests.c b/test/013_math_digitstosumzero/digitstosumzero_tests.c
index f28c02a..795bd9b 100644
--- a/test/013_math_digitstosumzero/digitstosumzero_tests.c
+++ b/test/013_math_digitstosumzero/digitstosumzero_tests.c
@@ -1,10 +1,11 @@
1#include "../test.h" 1#include "../test.h"
2 2
3int64_t digitstosumzero(uint8_t *, uint8_t, uint8_t); 3int64_t digitstosumzero(size_t n, uint8_t [n], uint8_t);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
7 uint8_t i, n, b, a[100]; 7 uint8_t i, b, a[100];
8 size_t n;
8 int64_t p; 9 int64_t p;
9 10
10 fgets(str, STRLENMAX, stdin); 11 fgets(str, STRLENMAX, stdin);
@@ -16,6 +17,6 @@ void run(void) {
16 a[i] = atoi(str); 17 a[i] = atoi(str);
17 } 18 }
18 19
19 p = digitstosumzero(a, n, b); 20 p = digitstosumzero(n, a, b);
20 printf("%" PRId64 "\n", p); 21 printf("%" PRId64 "\n", p);
21} 22}
diff --git a/test/014_math_sumzerotodigits/sumzerotodigits.c b/test/014_math_sumzerotodigits/sumzerotodigits.c
index 5bea7ca..19272ea 100644
--- a/test/014_math_sumzerotodigits/sumzerotodigits.c
+++ b/test/014_math_sumzerotodigits/sumzerotodigits.c
@@ -1,6 +1,6 @@
1#include "../test.h" 1#include "../test.h"
2 2
3void sumzerotodigits(int64_t, uint8_t, uint8_t, uint8_t *); 3void sumzerotodigits(int64_t, size_t n, uint8_t, uint8_t [n]);
4 4
5void run(void) { 5void run(void) {
6 char str[STRLENMAX]; 6 char str[STRLENMAX];
diff --git a/test/032_invertmoves/invertmoves_tests.c b/test/032_invertmoves/invertmoves_tests.c
index d5da323..d791524 100644
--- a/test/032_invertmoves/invertmoves_tests.c
+++ b/test/032_invertmoves/invertmoves_tests.c
@@ -3,8 +3,8 @@
3#define MAXMOVES 20 3#define MAXMOVES 20
4 4
5int64_t readmoves(const char *, int, uint8_t *); 5int64_t readmoves(const char *, int, uint8_t *);
6void writemoves(uint8_t *, int, uint64_t, char *); 6void writemoves(size_t n, uint8_t [n], size_t m, char [m]);
7void invertmoves(uint8_t *, uint8_t, uint8_t *); 7void invertmoves(size_t n, const uint8_t [n], uint8_t [n]);
8 8
9void run(void) { 9void run(void) {
10 char movestr[STRLENMAX], outstr[STRLENMAX]; 10 char movestr[STRLENMAX], outstr[STRLENMAX];
@@ -14,8 +14,8 @@ void run(void) {
14 fgets(movestr, STRLENMAX, stdin); 14 fgets(movestr, STRLENMAX, stdin);
15 c = readmoves(movestr, MAXMOVES, moves); 15 c = readmoves(movestr, MAXMOVES, moves);
16 16
17 invertmoves(moves, c, ret); 17 invertmoves(c, moves, ret);
18 writemoves(ret, c, STRLENMAX, outstr); 18 writemoves(c, ret, STRLENMAX, outstr);
19 19
20 printf("%s\n", outstr); 20 printf("%s\n", outstr);
21} 21}
diff --git a/test/080_allowednext/allowednext_tests.c b/test/080_allowednext/allowednext_tests.c
index 644d4c5..08fe491 100644
--- a/test/080_allowednext/allowednext_tests.c
+++ b/test/080_allowednext/allowednext_tests.c
@@ -1,6 +1,6 @@
1#include "../test.h" 1#include "../test.h"
2 2
3bool allowednextmove(uint8_t *, uint8_t); 3bool allowednextmove(size_t n, const uint8_t [n]);
4 4
5static char *moves[] = { 5static char *moves[] = {
6 "U", "U2", "U'", 6 "U", "U2", "U'",
@@ -31,5 +31,5 @@ void run(void) {
31 n > 2 ? moves[m[n-3]] : "-", 31 n > 2 ? moves[m[n-3]] : "-",
32 n > 1 ? moves[m[n-2]] : "-", 32 n > 1 ? moves[m[n-2]] : "-",
33 n > 0 ? moves[m[n-1]] : "-"); 33 n > 0 ? moves[m[n-1]] : "-");
34 printf("%s\n", allowednextmove(m, n) ? "true" : "false"); 34 printf("%s\n", allowednextmove(n, m) ? "true" : "false");
35} 35}
diff --git a/test/test.h b/test/test.h
index 4b281e0..3854520 100644
--- a/test/test.h
+++ b/test/test.h
@@ -25,7 +25,7 @@ bool isconsistent(cube_t);
25bool issolvable(cube_t); 25bool issolvable(cube_t);
26bool issolved(cube_t); 26bool issolved(cube_t);
27cube_t readcube(char *, char *); 27cube_t readcube(char *, char *);
28int64_t writecube(char *, cube_t, uint64_t, char *); 28int64_t writecube(char *, cube_t, size_t n, char [n]);
29 29
30/* Test function to be implemented by all tests */ 30/* Test function to be implemented by all tests */
31void run(void); 31void run(void);

Generated with cgit - Back to sebastiano.tronto.net