Fixed warnings in TestLinkedList

This commit is contained in:
Armin Novak 2021-07-28 16:20:32 +02:00 committed by akallabeth
parent 610396e197
commit 00c5a42eef
2 changed files with 49 additions and 30 deletions

View File

@ -7,10 +7,19 @@ int TestLinkedList(int argc, char* argv[])
{
int count;
wLinkedList* list;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
list = LinkedList_New();
LinkedList_AddFirst(list, (void*)(size_t)1);
LinkedList_AddLast(list, (void*)(size_t)2);
LinkedList_AddLast(list, (void*)(size_t)3);
if (!list)
return -1;
if (!LinkedList_AddFirst(list, (void*)(size_t)1))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)2))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)3))
return -1;
count = LinkedList_Count(list);
if (count != 3)
@ -23,12 +32,11 @@ int TestLinkedList(int argc, char* argv[])
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\t%" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\t%p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");
printf("LinkedList First: %" PRIuz " Last: %" PRIuz "\n", (size_t)LinkedList_First(list),
(size_t)LinkedList_Last(list));
printf("LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
LinkedList_RemoveFirst(list);
LinkedList_RemoveLast(list);
count = LinkedList_Count(list);
@ -43,12 +51,11 @@ int TestLinkedList(int argc, char* argv[])
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\t%" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\t%p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");
printf("LinkedList First: %" PRIuz " Last: %" PRIuz "\n", (size_t)LinkedList_First(list),
(size_t)LinkedList_Last(list));
printf("LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
LinkedList_RemoveFirst(list);
LinkedList_RemoveLast(list);
count = LinkedList_Count(list);
@ -59,9 +66,12 @@ int TestLinkedList(int argc, char* argv[])
return -1;
}
LinkedList_AddFirst(list, (void*)(size_t)4);
LinkedList_AddLast(list, (void*)(size_t)5);
LinkedList_AddLast(list, (void*)(size_t)6);
if (!LinkedList_AddFirst(list, (void*)(size_t)4))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)5))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)6))
return -1;
count = LinkedList_Count(list);
if (count != 3)
@ -74,45 +84,51 @@ int TestLinkedList(int argc, char* argv[])
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\t%" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\t%p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");
printf("LinkedList First: %" PRIuz " Last: %" PRIuz "\n", (size_t)LinkedList_First(list),
(size_t)LinkedList_Last(list));
LinkedList_Remove(list, (void*)(size_t)5);
printf("LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
if (!LinkedList_Remove(list, (void*)(size_t)5))
return -1;
LinkedList_Enumerator_Reset(list);
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\t%" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\t%p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");
printf("LinkedList First: %" PRIuz " Last: %" PRIuz "\n", (size_t)LinkedList_First(list),
(size_t)LinkedList_Last(list));
printf("LinkedList First: %p Last: %p\n", LinkedList_First(list), LinkedList_Last(list));
LinkedList_Free(list);
/* Test enumerator robustness */
/* enumerator on an empty list */
list = LinkedList_New();
if (!list)
return -1;
LinkedList_Enumerator_Reset(list);
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\terror: %" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\terror: %p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");
LinkedList_Free(list);
/* Use an enumerator without reset */
list = LinkedList_New();
LinkedList_AddFirst(list, (void*)(size_t)4);
LinkedList_AddLast(list, (void*)(size_t)5);
LinkedList_AddLast(list, (void*)(size_t)6);
if (!list)
return -1;
if (!LinkedList_AddFirst(list, (void*)(size_t)4))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)5))
return -1;
if (!LinkedList_AddLast(list, (void*)(size_t)6))
return -1;
while (LinkedList_Enumerator_MoveNext(list))
{
printf("\t%" PRIuz "\n", (size_t)LinkedList_Enumerator_Current(list));
printf("\t%p\n", LinkedList_Enumerator_Current(list));
}
printf("\n");

View File

@ -5,11 +5,14 @@
int TestQueue(int argc, char* argv[])
{
int item;
int index;
int count;
size_t item;
size_t index;
size_t count;
wQueue* queue;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
queue = Queue_New(TRUE, -1, -1);
if (!queue)
return -1;
@ -20,18 +23,18 @@ int TestQueue(int argc, char* argv[])
}
count = Queue_Count(queue);
printf("queue count: %d\n", count);
printf("queue count: %" PRIuz "\n", count);
for (index = 1; index <= 10; index++)
{
item = (int)(size_t)Queue_Dequeue(queue);
item = (size_t)Queue_Dequeue(queue);
if (item != index)
return -1;
}
count = Queue_Count(queue);
printf("queue count: %d\n", count);
printf("queue count: %" PRIuz "\n", count);
Queue_Enqueue(queue, (void*)(size_t)1);
Queue_Enqueue(queue, (void*)(size_t)2);