diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-10 19:26:47 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-10 19:26:47 +0200 |
| commit | 832ad3dcf3818e57c53304ea9b09a943e785a16b (patch) | |
| tree | db78b51e3eee74d293b38337eeb1a02e33c5aed6 | |
| parent | 1cecea625ed405c7203d1977e687da36d835fc9a (diff) | |
| download | nissy-core-832ad3dcf3818e57c53304ea9b09a943e785a16b.tar.gz nissy-core-832ad3dcf3818e57c53304ea9b09a943e785a16b.zip | |
Added tests for B32
| -rw-r--r-- | TODO.txt | 5 | ||||
| -rw-r--r-- | src/io_cube.h | 10 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/00_garbage.in (renamed from test/020_io_H48_read_write/00_garbage.in) | 0 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/00_garbage.out (renamed from test/020_io_H48_read_write/00_garbage.out) | 0 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/01_solved.in | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/01_solved.out | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/02_F.in | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/02_F.out | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/03_scrambled.in | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/03_scrambled.out | 1 | ||||
| -rw-r--r-- | test/020_io_B32_read_write/io_B32_tests.c | 21 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/00_garbage.in | 3 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/00_garbage.out | 1 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/01_solved_oneline.in (renamed from test/020_io_H48_read_write/01_solved_oneline.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/01_solved_oneline.out (renamed from test/020_io_H48_read_write/01_solved_oneline.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/02_solved_oneline_whitespace.in (renamed from test/020_io_H48_read_write/02_solved_oneline_whitespace.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/02_solved_oneline_whitespace.out (renamed from test/020_io_H48_read_write/02_solved_oneline_whitespace.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/03_solved_multiline.in (renamed from test/020_io_H48_read_write/03_solved_multiline.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/03_solved_multiline.out (renamed from test/020_io_H48_read_write/03_solved_multiline.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/04_unsolvable_ep.in (renamed from test/020_io_H48_read_write/04_unsolvable_ep.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/04_unsolvable_ep.out (renamed from test/020_io_H48_read_write/04_unsolvable_ep.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/05_unsolvable_eo.in (renamed from test/020_io_H48_read_write/05_unsolvable_eo.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/05_unsolvable_eo.out (renamed from test/020_io_H48_read_write/05_unsolvable_eo.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/06_unsolvable_cp.in (renamed from test/020_io_H48_read_write/06_unsolvable_cp.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/06_unsolvable_cp.out (renamed from test/020_io_H48_read_write/06_unsolvable_cp.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/07_unsolvable_co.in (renamed from test/020_io_H48_read_write/07_unsolvable_co.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/07_unsolvable_co.out (renamed from test/020_io_H48_read_write/07_unsolvable_co.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/08_unsolved.in (renamed from test/020_io_H48_read_write/08_unsolved.in) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/08_unsolved.out (renamed from test/020_io_H48_read_write/08_unsolved.out) | 0 | ||||
| -rw-r--r-- | test/021_io_H48_read_write/io_H48_tests.c (renamed from test/020_io_H48_read_write/io_H48_tests.c) | 0 | ||||
| -rw-r--r-- | test/023_io_LST_write/io_LST_write_tests.c (renamed from test/023_io_LST_write/io_LST_tests.c) | 0 | ||||
| -rw-r--r-- | test/024_io_LST_read/io_LST_read_tests.c (renamed from test/024_io_LST_read/io_LST_tests.c) | 0 |
32 files changed, 38 insertions, 8 deletions
| @@ -1,14 +1,13 @@ | |||
| 1 | Refactoring: remove cube_fast_t and add b32 format | 1 | Refactoring: remove cube_fast_t and add b32 format |
| 2 | - see TODO comments in cube.h | 2 | - see TODO comments in cube.h |
| 3 | - switch to b32 by default (part 1) | ||
| 4 | add tests for b32 (write at some by hand) | ||
| 5 | - fix utility code in utils/*.c | 3 | - fix utility code in utils/*.c |
| 6 | replace h48_to_lst with convert.c | 4 | replace h48_to_lst with convert.c |
| 7 | fix invert.c | 5 | fix invert.c |
| 8 | fix utils/*.sh scripts to use the new convert | 6 | fix utils/*.sh scripts to use the new convert |
| 9 | convert all utils/cubes/*.txt files in b32 format | 7 | convert all utils/cubes/*.txt files in b32 format |
| 10 | - switch to b32 by default (part 2) | 8 | - switch to b32 by default |
| 11 | change all tests to use b32 | 9 | change all tests to use b32 |
| 10 | split read and write for H48 | ||
| 12 | - if all public functions work with strings, always use return value | 11 | - if all public functions work with strings, always use return value |
| 13 | as error code (solve already does this), and use string as buffer | 12 | as error code (solve already does this), and use string as buffer |
| 14 | to print error | 13 | to print error |
diff --git a/src/io_cube.h b/src/io_cube.h index 63c9f53..430d3ac 100644 --- a/src/io_cube.h +++ b/src/io_cube.h | |||
| @@ -324,17 +324,17 @@ writecube_LST(cube_t cube, char *buf) | |||
| 324 | _static uint8_t | 324 | _static uint8_t |
| 325 | b32toedge(char c) | 325 | b32toedge(char c) |
| 326 | { | 326 | { |
| 327 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g')) | 327 | if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) |
| 328 | return 255; | 328 | return 255; |
| 329 | 329 | ||
| 330 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a'); | 330 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | _static uint8_t | 333 | _static uint8_t |
| 334 | b32tocorner(char c) { | 334 | b32tocorner(char c) { |
| 335 | uint8_t val; | 335 | uint8_t val; |
| 336 | 336 | ||
| 337 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g')) | 337 | if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) |
| 338 | return 255; | 338 | return 255; |
| 339 | 339 | ||
| 340 | val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; | 340 | val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; |
| @@ -345,7 +345,7 @@ b32tocorner(char c) { | |||
| 345 | _static char | 345 | _static char |
| 346 | edgetob32(uint8_t edge) | 346 | edgetob32(uint8_t edge) |
| 347 | { | 347 | { |
| 348 | return edge <= 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); | 348 | return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | _static char | 351 | _static char |
| @@ -355,5 +355,5 @@ cornertob32(uint8_t corner) | |||
| 355 | 355 | ||
| 356 | val = (corner & 7) | ((corner & 96) >> 2); | 356 | val = (corner & 7) | ((corner & 96) >> 2); |
| 357 | 357 | ||
| 358 | return val <= 26 ? 'A' + (char)val : 'a' + (char)(val - 26); | 358 | return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); |
| 359 | } | 359 | } |
diff --git a/test/020_io_H48_read_write/00_garbage.in b/test/020_io_B32_read_write/00_garbage.in index 9ac203a..9ac203a 100644 --- a/test/020_io_H48_read_write/00_garbage.in +++ b/test/020_io_B32_read_write/00_garbage.in | |||
diff --git a/test/020_io_H48_read_write/00_garbage.out b/test/020_io_B32_read_write/00_garbage.out index 5b9114e..5b9114e 100644 --- a/test/020_io_H48_read_write/00_garbage.out +++ b/test/020_io_B32_read_write/00_garbage.out | |||
diff --git a/test/020_io_B32_read_write/01_solved.in b/test/020_io_B32_read_write/01_solved.in new file mode 100644 index 0000000..e1df94b --- /dev/null +++ b/test/020_io_B32_read_write/01_solved.in | |||
| @@ -0,0 +1 @@ | |||
| ABCDEFGH=ABCDEFGHIJKL | |||
diff --git a/test/020_io_B32_read_write/01_solved.out b/test/020_io_B32_read_write/01_solved.out new file mode 100644 index 0000000..e1df94b --- /dev/null +++ b/test/020_io_B32_read_write/01_solved.out | |||
| @@ -0,0 +1 @@ | |||
| ABCDEFGH=ABCDEFGHIJKL | |||
diff --git a/test/020_io_B32_read_write/02_F.in b/test/020_io_B32_read_write/02_F.in new file mode 100644 index 0000000..1677251 --- /dev/null +++ b/test/020_io_B32_read_write/02_F.in | |||
| @@ -0,0 +1 @@ | |||
| MBODSFQH=ZBCYEFGHQTKL | |||
diff --git a/test/020_io_B32_read_write/02_F.out b/test/020_io_B32_read_write/02_F.out new file mode 100644 index 0000000..1677251 --- /dev/null +++ b/test/020_io_B32_read_write/02_F.out | |||
| @@ -0,0 +1 @@ | |||
| MBODSFQH=ZBCYEFGHQTKL | |||
diff --git a/test/020_io_B32_read_write/03_scrambled.in b/test/020_io_B32_read_write/03_scrambled.in new file mode 100644 index 0000000..ed442fe --- /dev/null +++ b/test/020_io_B32_read_write/03_scrambled.in | |||
| @@ -0,0 +1 @@ | |||
| OINUTCXB=JCRIEDAbVaGH | |||
diff --git a/test/020_io_B32_read_write/03_scrambled.out b/test/020_io_B32_read_write/03_scrambled.out new file mode 100644 index 0000000..ed442fe --- /dev/null +++ b/test/020_io_B32_read_write/03_scrambled.out | |||
| @@ -0,0 +1 @@ | |||
| OINUTCXB=JCRIEDAbVaGH | |||
diff --git a/test/020_io_B32_read_write/io_B32_tests.c b/test/020_io_B32_read_write/io_B32_tests.c new file mode 100644 index 0000000..1953453 --- /dev/null +++ b/test/020_io_B32_read_write/io_B32_tests.c | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | int main(void) { | ||
| 4 | char str[STRLENMAX]; | ||
| 5 | cube_t cube; | ||
| 6 | |||
| 7 | fgets(str, STRLENMAX, stdin); | ||
| 8 | |||
| 9 | cube = readcube("B32", str); | ||
| 10 | |||
| 11 | if (iserror(cube)) { | ||
| 12 | printf("Error reading cube\n"); | ||
| 13 | } else if (!issolvable(cube)) { | ||
| 14 | printf("Cube is not solvable\n"); | ||
| 15 | } else { | ||
| 16 | writecube("B32", cube, str); | ||
| 17 | printf("%s\n", str); | ||
| 18 | } | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/test/021_io_H48_read_write/00_garbage.in b/test/021_io_H48_read_write/00_garbage.in new file mode 100644 index 0000000..9ac203a --- /dev/null +++ b/test/021_io_H48_read_write/00_garbage.in | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | FUF0 UBBBR2 k4 | ||
| 2 | hello | ||
| 3 | garbage | ||
diff --git a/test/021_io_H48_read_write/00_garbage.out b/test/021_io_H48_read_write/00_garbage.out new file mode 100644 index 0000000..5b9114e --- /dev/null +++ b/test/021_io_H48_read_write/00_garbage.out | |||
| @@ -0,0 +1 @@ | |||
| Error reading cube | |||
diff --git a/test/020_io_H48_read_write/01_solved_oneline.in b/test/021_io_H48_read_write/01_solved_oneline.in index dff224d..dff224d 100644 --- a/test/020_io_H48_read_write/01_solved_oneline.in +++ b/test/021_io_H48_read_write/01_solved_oneline.in | |||
diff --git a/test/020_io_H48_read_write/01_solved_oneline.out b/test/021_io_H48_read_write/01_solved_oneline.out index dff224d..dff224d 100644 --- a/test/020_io_H48_read_write/01_solved_oneline.out +++ b/test/021_io_H48_read_write/01_solved_oneline.out | |||
diff --git a/test/020_io_H48_read_write/02_solved_oneline_whitespace.in b/test/021_io_H48_read_write/02_solved_oneline_whitespace.in index 5d10368..5d10368 100644 --- a/test/020_io_H48_read_write/02_solved_oneline_whitespace.in +++ b/test/021_io_H48_read_write/02_solved_oneline_whitespace.in | |||
diff --git a/test/020_io_H48_read_write/02_solved_oneline_whitespace.out b/test/021_io_H48_read_write/02_solved_oneline_whitespace.out index dff224d..dff224d 100644 --- a/test/020_io_H48_read_write/02_solved_oneline_whitespace.out +++ b/test/021_io_H48_read_write/02_solved_oneline_whitespace.out | |||
diff --git a/test/020_io_H48_read_write/03_solved_multiline.in b/test/021_io_H48_read_write/03_solved_multiline.in index 9f9652b..9f9652b 100644 --- a/test/020_io_H48_read_write/03_solved_multiline.in +++ b/test/021_io_H48_read_write/03_solved_multiline.in | |||
diff --git a/test/020_io_H48_read_write/03_solved_multiline.out b/test/021_io_H48_read_write/03_solved_multiline.out index dff224d..dff224d 100644 --- a/test/020_io_H48_read_write/03_solved_multiline.out +++ b/test/021_io_H48_read_write/03_solved_multiline.out | |||
diff --git a/test/020_io_H48_read_write/04_unsolvable_ep.in b/test/021_io_H48_read_write/04_unsolvable_ep.in index 8483962..8483962 100644 --- a/test/020_io_H48_read_write/04_unsolvable_ep.in +++ b/test/021_io_H48_read_write/04_unsolvable_ep.in | |||
diff --git a/test/020_io_H48_read_write/04_unsolvable_ep.out b/test/021_io_H48_read_write/04_unsolvable_ep.out index e35c6e4..e35c6e4 100644 --- a/test/020_io_H48_read_write/04_unsolvable_ep.out +++ b/test/021_io_H48_read_write/04_unsolvable_ep.out | |||
diff --git a/test/020_io_H48_read_write/05_unsolvable_eo.in b/test/021_io_H48_read_write/05_unsolvable_eo.in index a92089d..a92089d 100644 --- a/test/020_io_H48_read_write/05_unsolvable_eo.in +++ b/test/021_io_H48_read_write/05_unsolvable_eo.in | |||
diff --git a/test/020_io_H48_read_write/05_unsolvable_eo.out b/test/021_io_H48_read_write/05_unsolvable_eo.out index e35c6e4..e35c6e4 100644 --- a/test/020_io_H48_read_write/05_unsolvable_eo.out +++ b/test/021_io_H48_read_write/05_unsolvable_eo.out | |||
diff --git a/test/020_io_H48_read_write/06_unsolvable_cp.in b/test/021_io_H48_read_write/06_unsolvable_cp.in index 2085dd5..2085dd5 100644 --- a/test/020_io_H48_read_write/06_unsolvable_cp.in +++ b/test/021_io_H48_read_write/06_unsolvable_cp.in | |||
diff --git a/test/020_io_H48_read_write/06_unsolvable_cp.out b/test/021_io_H48_read_write/06_unsolvable_cp.out index e35c6e4..e35c6e4 100644 --- a/test/020_io_H48_read_write/06_unsolvable_cp.out +++ b/test/021_io_H48_read_write/06_unsolvable_cp.out | |||
diff --git a/test/020_io_H48_read_write/07_unsolvable_co.in b/test/021_io_H48_read_write/07_unsolvable_co.in index abd74e2..abd74e2 100644 --- a/test/020_io_H48_read_write/07_unsolvable_co.in +++ b/test/021_io_H48_read_write/07_unsolvable_co.in | |||
diff --git a/test/020_io_H48_read_write/07_unsolvable_co.out b/test/021_io_H48_read_write/07_unsolvable_co.out index e35c6e4..e35c6e4 100644 --- a/test/020_io_H48_read_write/07_unsolvable_co.out +++ b/test/021_io_H48_read_write/07_unsolvable_co.out | |||
diff --git a/test/020_io_H48_read_write/08_unsolved.in b/test/021_io_H48_read_write/08_unsolved.in index c992ce7..c992ce7 100644 --- a/test/020_io_H48_read_write/08_unsolved.in +++ b/test/021_io_H48_read_write/08_unsolved.in | |||
diff --git a/test/020_io_H48_read_write/08_unsolved.out b/test/021_io_H48_read_write/08_unsolved.out index 8c132cf..8c132cf 100644 --- a/test/020_io_H48_read_write/08_unsolved.out +++ b/test/021_io_H48_read_write/08_unsolved.out | |||
diff --git a/test/020_io_H48_read_write/io_H48_tests.c b/test/021_io_H48_read_write/io_H48_tests.c index 705356c..705356c 100644 --- a/test/020_io_H48_read_write/io_H48_tests.c +++ b/test/021_io_H48_read_write/io_H48_tests.c | |||
diff --git a/test/023_io_LST_write/io_LST_tests.c b/test/023_io_LST_write/io_LST_write_tests.c index df35632..df35632 100644 --- a/test/023_io_LST_write/io_LST_tests.c +++ b/test/023_io_LST_write/io_LST_write_tests.c | |||
diff --git a/test/024_io_LST_read/io_LST_tests.c b/test/024_io_LST_read/io_LST_read_tests.c index 506a23d..506a23d 100644 --- a/test/024_io_LST_read/io_LST_tests.c +++ b/test/024_io_LST_read/io_LST_read_tests.c | |||
