aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/shell.c34
-rwxr-xr-xshell/test.sh22
-rw-r--r--shell/testcases/000_frommoves.in1
-rw-r--r--shell/testcases/000_frommoves.out1
-rw-r--r--shell/testcases/001_compose.in1
-rw-r--r--shell/testcases/001_compose.out1
6 files changed, 0 insertions, 60 deletions
diff --git a/shell/shell.c b/shell/shell.c
index ecd39f2..40a5748 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -15,7 +15,6 @@
15#define MAX_PATH_LENGTH UINT64_C(10000) 15#define MAX_PATH_LENGTH UINT64_C(10000)
16 16
17#define FLAG_CUBE "-cube" 17#define FLAG_CUBE "-cube"
18#define FLAG_PERM "-perm"
19#define FLAG_COMMAND "-command" 18#define FLAG_COMMAND "-command"
20#define FLAG_STR_CUBE "-cubestr" 19#define FLAG_STR_CUBE "-cubestr"
21#define FLAG_MOVES "-moves" 20#define FLAG_MOVES "-moves"
@@ -37,7 +36,6 @@
37typedef struct { 36typedef struct {
38 int command_index; 37 int command_index;
39 char cube[NISSY_SIZE_CUBE]; 38 char cube[NISSY_SIZE_CUBE];
40 char cube_perm[NISSY_SIZE_CUBE];
41 char *str_command; 39 char *str_command;
42 char *str_cube; 40 char *str_cube;
43 char *str_moves; 41 char *str_moves;
@@ -51,7 +49,6 @@ typedef struct {
51 unsigned threads; 49 unsigned threads;
52} args_t; 50} args_t;
53 51
54static int64_t compose_exec(args_t *);
55static int64_t inverse_exec(args_t *); 52static int64_t inverse_exec(args_t *);
56static int64_t applymoves_exec(args_t *); 53static int64_t applymoves_exec(args_t *);
57static int64_t applytrans_exec(args_t *); 54static int64_t applytrans_exec(args_t *);
@@ -69,7 +66,6 @@ static bool parse_uint(const char *, unsigned *);
69static uint8_t parse_nisstype(const char *); 66static uint8_t parse_nisstype(const char *);
70 67
71static bool set_cube(int, char **, args_t *); 68static bool set_cube(int, char **, args_t *);
72static bool set_cube_perm(int, char **, args_t *);
73static bool set_str_command(int, char **, args_t *); 69static bool set_str_command(int, char **, args_t *);
74static bool set_str_cube(int, char **, args_t *); 70static bool set_str_cube(int, char **, args_t *);
75static bool set_str_moves(int, char **, args_t *); 71static bool set_str_moves(int, char **, args_t *);
@@ -92,7 +88,6 @@ struct {
92 bool (*set)(int, char **, args_t *); 88 bool (*set)(int, char **, args_t *);
93} options[] = { 89} options[] = {
94 OPTION(FLAG_CUBE, 1, set_cube), 90 OPTION(FLAG_CUBE, 1, set_cube),
95 OPTION(FLAG_PERM, 1, set_cube_perm),
96 OPTION(FLAG_COMMAND, 1, set_str_command), 91 OPTION(FLAG_COMMAND, 1, set_str_command),
97 OPTION(FLAG_STR_CUBE, 1, set_str_cube), 92 OPTION(FLAG_STR_CUBE, 1, set_str_cube),
98 OPTION(FLAG_MOVES, 1, set_str_moves), 93 OPTION(FLAG_MOVES, 1, set_str_moves),
@@ -116,12 +111,6 @@ struct {
116} commands[] = { 111} commands[] = {
117/* TODO: add synopsis and description here */ 112/* TODO: add synopsis and description here */
118 COMMAND( 113 COMMAND(
119 "compose",
120 "compose " FLAG_CUBE " CUBE " FLAG_PERM " PERM",
121 "Apply on CUBE the permutation defined by PERM.",
122 compose_exec
123 ),
124 COMMAND(
125 "inverse", 114 "inverse",
126 "inverse " FLAG_CUBE " CUBE ", 115 "inverse " FLAG_CUBE " CUBE ",
127 "Compute the inverse of the given CUBE.", 116 "Compute the inverse of the given CUBE.",
@@ -224,19 +213,6 @@ rand64(void)
224} 213}
225 214
226static int64_t 215static int64_t
227compose_exec(args_t *args)
228{
229 char result[NISSY_SIZE_CUBE];
230 int64_t ret;
231
232 ret = nissy_compose(args->cube, args->cube_perm, result);
233 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
234 printf("%s\n", result);
235
236 return ret;
237}
238
239static int64_t
240inverse_exec(args_t *args) 216inverse_exec(args_t *args)
241{ 217{
242 char result[NISSY_SIZE_CUBE]; 218 char result[NISSY_SIZE_CUBE];
@@ -531,7 +507,6 @@ parse_args(int argc, char **argv, args_t *args)
531 *args = (args_t) { 507 *args = (args_t) {
532 .command_index = -1, 508 .command_index = -1,
533 .cube = "", 509 .cube = "",
534 .cube_perm = "",
535 .str_cube = "", 510 .str_cube = "",
536 .str_moves = "", 511 .str_moves = "",
537 .str_trans = "", 512 .str_trans = "",
@@ -630,15 +605,6 @@ set_cube(int argc, char **argv, args_t *args)
630} 605}
631 606
632static bool 607static bool
633set_cube_perm(int argc, char **argv, args_t *args)
634{
635 memcpy(args->cube_perm, argv[0], NISSY_SIZE_CUBE);
636 args->cube_perm[21] = 0;
637
638 return true;
639}
640
641static bool
642set_str_command(int argc, char **argv, args_t *args) 608set_str_command(int argc, char **argv, args_t *args)
643{ 609{
644 args->str_command = argv[0]; 610 args->str_command = argv[0];
diff --git a/shell/test.sh b/shell/test.sh
deleted file mode 100755
index 8bc4589..0000000
--- a/shell/test.sh
+++ /dev/null
@@ -1,22 +0,0 @@
1#!/bin/sh
2
3SHELLBIN="./debugrun"
4TESTDIR="./shell/testcases"
5TESTOUT="shell/lasttest.out"
6TESTERR="shell/lasttest.err"
7
8for cin in "$TESTDIR"/*.in; do
9 c=$(echo "$cin" | sed 's/\.in//')
10 cout="$c.out"
11 printf "%s: " "$c"
12 (cat "$cin" | xargs "$SHELLBIN") > $TESTOUT 2> $TESTERR
13 if diff "$cout" "$TESTOUT"; then
14 printf "OK\n"
15 else
16 printf "Test failed! stderr:\n"
17 cat $TESTERR
18 exit 1
19 fi
20done
21
22echo "All tests passed!"
diff --git a/shell/testcases/000_frommoves.in b/shell/testcases/000_frommoves.in
deleted file mode 100644
index 2b3c6d1..0000000
--- a/shell/testcases/000_frommoves.in
+++ /dev/null
@@ -1 +0,0 @@
1frommoves -moves "UFRR"
diff --git a/shell/testcases/000_frommoves.out b/shell/testcases/000_frommoves.out
deleted file mode 100644
index dfefe81..0000000
--- a/shell/testcases/000_frommoves.out
+++ /dev/null
@@ -1 +0,0 @@
1DEOISVBH=ZFCYHAGBLTKU
diff --git a/shell/testcases/001_compose.in b/shell/testcases/001_compose.in
deleted file mode 100644
index fa09a0b..0000000
--- a/shell/testcases/001_compose.in
+++ /dev/null
@@ -1 +0,0 @@
1compose -cube NEORSQLH=ZFCYUAGLHTKB -perm NEORSQLH=ZFCYUAGLHTKB
diff --git a/shell/testcases/001_compose.out b/shell/testcases/001_compose.out
deleted file mode 100644
index d36a93c..0000000
--- a/shell/testcases/001_compose.out
+++ /dev/null
@@ -1 +0,0 @@
1ASTUGFBH=DACXEZGBLIKF

Generated with cgit - Back to sebastiano.tronto.net