Update list tests

This commit is contained in:
Gregory Lirent 2022-06-10 17:08:06 +03:00
parent a1a19a2c7b
commit 11db0557b9
3 changed files with 40 additions and 1 deletions

View File

@ -9,7 +9,10 @@ int main(int argc, char** argv) {
list_t x = { .first = 0, .last = 0 };
list_t y = { .first = 0, .last = 0 };
visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%5) + 12);
visual_push(&x, (random_uint8()%9) + 8);
visual_slice(&x, &y);
visual_push2(&x, (random_uint8()%5) + 12, &y, (random_uint8()%3) + 6);
visual_extend(&x, &y);
visual_sort2(&x, &y);

View File

@ -23,3 +23,4 @@ extern void visual_push2(list_t* x0, size_t n0, list_t* x1, size_t n1);
extern void visual_remove2(list_t* x0, list_t* x1);
extern void visual_sort2(list_t* x0, list_t* x1);
extern void visual_extend(list_t* x, list_t* s);
extern void visual_slice(list_t* x, list_t* s);

View File

@ -186,3 +186,38 @@ void visual_extend(list_t* x, list_t* s) {
psleep(900000);
fputs("\e[u\e[J", stdout);
}
void visual_slice(list_t* x, list_t* s) {
size_t n = list_size(x);
ssize_t i = random_uint64()%(n - 1);
n = n - (i + 1);
puts("\e[s\e[36mTry to slice list:\e[m\n\n");
printf("\e[37;2m%-60s%s\e[m\n", "=== === === === === === === ===", "=== === === === === === === ===");
list_info(x, 0);
list_print(x, "(src)", 0);
fputs("\e[u\e[s\e[4E", stdout);
list_info(s, 60);
list_print(s, "(dest)", 60);
psleep(900000);
list_slice(s, x, i, n, 1);
fputs("\e[u\e[s\e[2E\e[32;1mSUCCESS\e[m\e[J", stdout);
puts("");
put_separator(0);
list_info(x, 0);
list_print(x, "(src)", 0);
fputs("\e[u\e[s\e[4E", stdout);
list_info(s, 60);
list_print(s, "(dest)", 60);
psleep(900000);
fputs("\e[u\e[J", stdout);
}