diff options
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/shell.c | 34 | ||||
| -rwxr-xr-x | shell/test.sh | 22 | ||||
| -rw-r--r-- | shell/testcases/000_frommoves.in | 1 | ||||
| -rw-r--r-- | shell/testcases/000_frommoves.out | 1 | ||||
| -rw-r--r-- | shell/testcases/001_compose.in | 1 | ||||
| -rw-r--r-- | shell/testcases/001_compose.out | 1 |
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 @@ | |||
| 37 | typedef struct { | 36 | typedef 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 | ||
| 54 | static int64_t compose_exec(args_t *); | ||
| 55 | static int64_t inverse_exec(args_t *); | 52 | static int64_t inverse_exec(args_t *); |
| 56 | static int64_t applymoves_exec(args_t *); | 53 | static int64_t applymoves_exec(args_t *); |
| 57 | static int64_t applytrans_exec(args_t *); | 54 | static int64_t applytrans_exec(args_t *); |
| @@ -69,7 +66,6 @@ static bool parse_uint(const char *, unsigned *); | |||
| 69 | static uint8_t parse_nisstype(const char *); | 66 | static uint8_t parse_nisstype(const char *); |
| 70 | 67 | ||
| 71 | static bool set_cube(int, char **, args_t *); | 68 | static bool set_cube(int, char **, args_t *); |
| 72 | static bool set_cube_perm(int, char **, args_t *); | ||
| 73 | static bool set_str_command(int, char **, args_t *); | 69 | static bool set_str_command(int, char **, args_t *); |
| 74 | static bool set_str_cube(int, char **, args_t *); | 70 | static bool set_str_cube(int, char **, args_t *); |
| 75 | static bool set_str_moves(int, char **, args_t *); | 71 | static 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 | ||
| 226 | static int64_t | 215 | static int64_t |
| 227 | compose_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 | |||
| 239 | static int64_t | ||
| 240 | inverse_exec(args_t *args) | 216 | inverse_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 | ||
| 632 | static bool | 607 | static bool |
| 633 | set_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 | |||
| 641 | static bool | ||
| 642 | set_str_command(int argc, char **argv, args_t *args) | 608 | set_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 | |||
| 3 | SHELLBIN="./debugrun" | ||
| 4 | TESTDIR="./shell/testcases" | ||
| 5 | TESTOUT="shell/lasttest.out" | ||
| 6 | TESTERR="shell/lasttest.err" | ||
| 7 | |||
| 8 | for 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 | ||
| 20 | done | ||
| 21 | |||
| 22 | echo "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 @@ | |||
| 1 | frommoves -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 @@ | |||
| 1 | DEOISVBH=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 @@ | |||
| 1 | compose -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 @@ | |||
| 1 | ASTUGFBH=DACXEZGBLIKF | ||
