3 #include <winpr/tchar.h>
4 #include <winpr/collections.h>
6 static char* key1 =
"key1";
7 static char* key2 =
"key2";
8 static char* key3 =
"key3";
10 static char* val1 =
"val1";
11 static char* val2 =
"val2";
12 static char* val3 =
"val3";
14 int TestListDictionary(
int argc,
char* argv[])
18 wListDictionary* list = NULL;
23 list = ListDictionary_New(TRUE);
27 if (!ListDictionary_Add(list, key1, val1) || !ListDictionary_Add(list, key2, val2) ||
28 !ListDictionary_Add(list, key3, val3))
31 count = ListDictionary_Count(list);
35 printf(
"ListDictionary_Count: Expected : 3, Actual: %" PRIuz
"\n", count);
39 ListDictionary_Remove(list, key2);
41 count = ListDictionary_Count(list);
45 printf(
"ListDictionary_Count: Expected : 2, Actual: %" PRIuz
"\n", count);
49 ListDictionary_Remove(list, key3);
51 count = ListDictionary_Count(list);
55 printf(
"ListDictionary_Count: Expected : 1, Actual: %" PRIuz
"\n", count);
59 ListDictionary_Remove(list, key1);
61 count = ListDictionary_Count(list);
65 printf(
"ListDictionary_Count: Expected : 0, Actual: %" PRIuz
"\n", count);
69 if (!ListDictionary_Add(list, key1, val1) || !ListDictionary_Add(list, key2, val2) ||
70 !ListDictionary_Add(list, key3, val3))
73 count = ListDictionary_Count(list);
77 printf(
"ListDictionary_Count: Expected : 3, Actual: %" PRIuz
"\n", count);
81 value = (
char*)ListDictionary_GetItemValue(list, key1);
83 if (strcmp(value, val1) != 0)
85 printf(
"ListDictionary_GetItemValue: Expected : %" PRIuz
", Actual: %" PRIuz
"\n",
86 (
size_t)val1, (
size_t)value);
90 value = (
char*)ListDictionary_GetItemValue(list, key2);
92 if (strcmp(value, val2) != 0)
94 printf(
"ListDictionary_GetItemValue: Expected : %" PRIuz
", Actual: %" PRIuz
"\n",
95 (
size_t)val2, (
size_t)value);
99 value = (
char*)ListDictionary_GetItemValue(list, key3);
101 if (strcmp(value, val3) != 0)
103 printf(
"ListDictionary_GetItemValue: Expected : %" PRIuz
", Actual: %" PRIuz
"\n",
104 (
size_t)val3, (
size_t)value);
108 ListDictionary_SetItemValue(list, key2,
"apple");
110 value = (
char*)ListDictionary_GetItemValue(list, key2);
112 if (strcmp(value,
"apple") != 0)
114 printf(
"ListDictionary_GetItemValue: Expected : %s, Actual: %s\n",
"apple", value);
118 if (!ListDictionary_Contains(list, key2))
120 printf(
"ListDictionary_Contains: Expected : TRUE, Actual: FALSE\n");
124 if (!ListDictionary_Take(list, key2))
126 printf(
"ListDictionary_Remove: Expected : TRUE, Actual: FALSE\n");
130 if (ListDictionary_Take(list, key2))
132 printf(
"ListDictionary_Remove: Expected : FALSE, Actual: TRUE\n");
136 value = ListDictionary_Take_Head(list);
137 count = ListDictionary_Count(list);
138 if ((strncmp(value, val1, 4) != 0) || (count != 1))
140 printf(
"ListDictionary_Remove_Head: Expected : %s, Actual: %s Count: %" PRIuz
"\n", val1,
145 value = ListDictionary_Take_Head(list);
146 count = ListDictionary_Count(list);
147 if ((strncmp(value, val3, 4) != 0) || (count != 0))
149 printf(
"ListDictionary_Remove_Head: Expected : %s, Actual: %s Count: %" PRIuz
"\n", val3,
154 value = ListDictionary_Take_Head(list);
157 printf(
"ListDictionary_Remove_Head: Expected : (null), Actual: %s\n", value);
161 if (!ListDictionary_Add(list, key1, val1) || !ListDictionary_Add(list, key2, val2) ||
162 !ListDictionary_Add(list, key3, val3))
165 ListDictionary_Clear(list);
167 count = ListDictionary_Count(list);
171 printf(
"ListDictionary_Count: Expected : 0, Actual: %" PRIuz
"\n", count);
175 ListDictionary_Free(list);