/* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ #include "../../../include/extra/list.h" #include "../../include/random.h" #include "../../include/test.h" #include "../../include/time.h" #include "../../../src/__internal/vnode.h" vtype_string* string_duplicate(const vtype_string* x) { return 0; } vtype_array* array_duplicate (const vtype_array* x) { return 0; } vtype_map* map_duplicate (const vtype_map* x) { return 0; } vtype_set* vset_duplicate (const vtype_set* x) { return 0; } void string_free(vtype_string* x) {} void array_free (vtype_array* x) {} void map_free (vtype_map* x) {} void vset_free (vtype_set* x) {} int string_compare(const vtype_string* s0, const vtype_string* s1) { return random_int8(); } int array_compare (const vtype_array* s0, const vtype_array* s1) { return random_int8(); } int map_compare (const vtype_map* s0, const vtype_map* s1) { return random_int8(); } int vset_compare (const vtype_set* s0, const vtype_set* s1) { return random_int8(); } static void list_push_random(vtype_list* x, vtype_bool front) { if (!front) switch (random_uint8()%13) { default: case 0: list_push_back(x, random_boolean()); break; case 1: list_push_back(x, random_uint8()); break; case 2: list_push_back(x, random_uint16()); break; case 3: list_push_back(x, random_uint32()); break; case 4: list_push_back(x, random_uint64()); break; case 5: list_push_back(x, random_int8()); break; case 6: list_push_back(x, random_int16()); break; case 7: list_push_back(x, random_int32()); break; case 8: list_push_back(x, random_int64()); break; case 9: list_push_back(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; case 10: list_push_back(x, random_float()); break; case 11: list_push_back(x, random_double()); break; case 12: list_push_back(x, random_ldouble()); break; } else switch (random_uint8()%13) { default: case 0: list_push_front(x, random_boolean()); break; case 1: list_push_front(x, random_uint8()); break; case 2: list_push_front(x, random_uint16()); break; case 3: list_push_front(x, random_uint32()); break; case 4: list_push_front(x, random_uint64()); break; case 5: list_push_front(x, random_int8()); break; case 6: list_push_front(x, random_int16()); break; case 7: list_push_front(x, random_int32()); break; case 8: list_push_front(x, random_int64()); break; case 9: list_push_front(x, (void*)((sizeof(void*) == 8) ? random_uint64() : random_uint32())); break; case 10: list_push_front(x, random_float()); break; case 11: list_push_front(x, random_double()); break; case 12: list_push_front(x, random_ldouble()); break; } } static int list_node_print(void* v, ssize_t i, vtype t, void* _) { print_container_value(&i, v, t, 1); return 0; } static void list_print(const vtype_list* x, const char* prefix) { print_container_values_prefix("List", prefix); list_foreach(x, 0, list_node_print); put_separator(); } static void list_info(const vtype_list* x) { print_container_info("List", "nodes", 0, list_size(x), -1); put_separator(); }