-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.c
More file actions
636 lines (482 loc) · 18.7 KB
/
tests.c
File metadata and controls
636 lines (482 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
#include "tests.h"
#include <assert.h>
#ifdef HASH_TABLE_UNIT_TEST
typedef struct _INTERNAL_HASH_TABLE
{
size_t nNumberOfEntries;
size_t nNumberOfBuckets;
size_t nNumberOfBucketsUsed;
PHASH_ENTRY* Buckets;
DOUBLE dLoadFactor;
}INTERNAL_HASH_TABLE, * PINTERNAL_HASH_TABLE;
static Test_IsPrime_0()
{
assert(IsPrime(0) == FALSE);
}
static Test_IsPrime_1()
{
assert(IsPrime(1) == FALSE);
}
static Test_IsPrime_2()
{
assert(IsPrime(2) == TRUE);
}
static Test_IsPrime_3()
{
assert(IsPrime(3) == TRUE);
}
static Test_IsPrime_4()
{
assert(IsPrime(4) == FALSE);
}
static Test_IsPrime_5()
{
assert(IsPrime(5) == TRUE);
}
static Test_IsPrime_6()
{
assert(IsPrime(6) == FALSE);
}
static Test_IsPrime_7()
{
assert(IsPrime(7) == TRUE);
}
/* FindClosestPrime Tests ********************************/
static Test_FindClosestPrime_0()
{
assert(FindClosestPrime(0) == 2);
}
static Test_FindClosestPrime_1201()
{
assert(FindClosestPrime(1201) == 1201);
}
static Test_FindClosestPrime_4294967290()
{
assert(FindClosestPrime(4294967290) == 4294967291);
}
static Test_FindClosestPrime_SIZE_MAX()
{
assert(FindClosestPrime(SIZE_MAX) == SIZE_MAX);
}
/*********************************************************/
/* _Fnv1aHash32 tests ************************************/
static Test__Fnv1aHash32_When_Data_Is_Null()
{
assert(_Fnv1aHash32(NULL, 100) == 0);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
}
static Test__Fnv1aHash32_When_Data_Length_Is_0()
{
assert(_Fnv1aHash32("Hello", 0) == 0);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
}
static Test__Fnv1aHash32_KnownPlainText()
{
assert(_Fnv1aHash32("The quick brown fox jumps over the lazy dog", 43) == 0x048fff90);
}
/*********************************************************/
/* CreateHashTable tests********************************/
static void Test_CreateHashTable_0_Load_Factor()
{
PHASH_TABLE pHashTable = CreateHashTable(100, 0);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
assert(pHashTable == NULL);
}
static void Test_CreateHashTable_SIZE_MAX_Entries()
{
PHASH_TABLE pHashTable = CreateHashTable(SIZE_MAX, .50);
assert(GetLastError() == ERROR_OUTOFMEMORY);
assert(pHashTable == NULL);
}
static void Test_CreateHashTable()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable != NULL);
assert(pHashTable->DeleteEntry != NULL);
assert(pHashTable->GetFirstEntry != NULL);
assert(pHashTable->GetNextEntry != NULL);
assert(pHashTable->GetNumberOfEntries != NULL);
assert(pHashTable->GetValue != NULL);
assert(pHashTable->SetEntry != NULL);
assert(pHashTable->pInternal != NULL);
PINTERNAL_HASH_TABLE pInternal = pHashTable->pInternal;
assert(pInternal->Buckets != NULL);
assert(pInternal->dLoadFactor == 0.50);
assert(pInternal->nNumberOfEntries == 0);
assert(pInternal->nNumberOfBucketsUsed == 0);
assert(pInternal->nNumberOfBuckets == 2);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
/* Insert Key tests*****************************************************************/
static void Test_SetEntry_NULL_Table()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
BOOL bRet = FALSE;
bRet = pHashTable->SetEntry(NULL, (PVOID)"test", 4, (PVOID)"Hello World");
assert(bRet == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
}
static void Test_SetEntry_0_nKeyLength()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
BOOL bRet = FALSE;
bRet = pHashTable->SetEntry(&pHashTable, (PVOID)"test", 0, (PVOID)"Hello World");
assert(bRet == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
}
static void Test_SetEntry_NULL_pKey()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
BOOL bRet = FALSE;
bRet = pHashTable->SetEntry(&pHashTable, NULL, 4, (PVOID)"Hello World");
assert(bRet == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
}
static void Test_SetEntry_Test_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
BOOL bRet = FALSE;
DWORD dwTestValue = 0xABCDEF00;
bRet = pHashTable->SetEntry(&pHashTable, "test", 4, (PVOID)&dwTestValue);
assert(bRet == TRUE);
assert(GetLastError() == ERROR_SUCCESS);
PINTERNAL_HASH_TABLE pInternal = pHashTable->pInternal;
assert(pInternal->nNumberOfBucketsUsed == 1);
assert(pInternal->nNumberOfEntries == 1);
DWORD dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"test", 4);
assert(dwGetValue == dwTestValue);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_SetEntry_Test_Keys()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
BOOL bRet = FALSE;
DWORD dwTestValue1 = 0x00000000;
DWORD dwTestValue2 = 0x00000001;
DWORD dwTestValue3 = 0x00000002;
bRet = pHashTable->SetEntry(&pHashTable, "spider", 6, (PVOID)&dwTestValue1);
bRet = pHashTable->SetEntry(&pHashTable, "eye", 3, (PVOID)&dwTestValue2);
bRet = pHashTable->SetEntry(&pHashTable, "lamb", 4, (PVOID)&dwTestValue3);
assert(bRet == TRUE);
assert(GetLastError() == ERROR_SUCCESS);
PINTERNAL_HASH_TABLE pInternal = pHashTable->pInternal;
assert(pInternal->nNumberOfBucketsUsed == 3);
assert(pInternal->nNumberOfEntries == 3);
// (3 / 0.50) = 6
// next prime number >= 6 is 7
assert(pInternal->nNumberOfBuckets == 7);
DWORD dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"spider", 6);
assert(dwGetValue == dwTestValue1);
dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"eye", 3);
assert(dwGetValue == dwTestValue2);
dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"lamb", 4);
assert(dwGetValue == dwTestValue3);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_SetEntry_Test_Keys_Known_Collision()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 1.0);
BOOL bRet = FALSE;
DWORD dwTestValue1 = 0x00000000;
DWORD dwTestValue2 = 0x00000001;
bRet = pHashTable->SetEntry(&pHashTable, "costarring", 10, (PVOID)&dwTestValue1);
assert(bRet == TRUE);
assert(GetLastError() == ERROR_SUCCESS);
bRet = pHashTable->SetEntry(&pHashTable, "liquid", 6, (PVOID)&dwTestValue2);
assert(bRet == TRUE);
assert(GetLastError() == ERROR_SUCCESS);
PINTERNAL_HASH_TABLE pInternal = pHashTable->pInternal;
assert(pInternal->nNumberOfBucketsUsed == 1);
assert(pInternal->nNumberOfEntries == 2);
assert(pInternal->nNumberOfBuckets == 2);
DWORD dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"costarring", 10);
assert(dwGetValue == dwTestValue1);
dwGetValue = *(DWORD*)pHashTable->GetValue(pHashTable, (PVOID)"liquid", 6);
assert(dwGetValue == dwTestValue2);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
/* DeleteEntry Tests *************************************************************/
static void Test_DeleteEntry_NULL_Table()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(pHashTable != NULL);
assert(pHashTable->DeleteEntry(NULL, "test", 4, FALSE, FALSE) == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_NULL_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(pHashTable != NULL);
assert(pHashTable->DeleteEntry(pHashTable, NULL, 4, FALSE, FALSE) == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_0_nKeyLength()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(pHashTable != NULL);
assert(pHashTable->DeleteEntry(pHashTable, "test", 0, FALSE, FALSE) == FALSE);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_Test_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, (PVOID)"test", 4, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
assert(pHashTable->DeleteEntry(pHashTable, "test", 4, FALSE, FALSE) == TRUE);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 0);
assert(pHashTable->GetValue(pHashTable, "test", 4) == FALSE);
assert(GetLastError() == ERROR_NO_MATCH);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_From_List()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, (PVOID)"costarring", 10, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
pHashTable->SetEntry(&pHashTable, (PVOID)"liquid", 6, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 2);
assert(pHashTable->DeleteEntry(pHashTable, "liquid", 6, FALSE, FALSE) == TRUE);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
assert(*(int*)(pHashTable->GetValue(pHashTable, (PVOID)"costarring", 10)) == dwValue);
assert(GetLastError() == ERROR_SUCCESS);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_Head_From_List()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, (PVOID)"costarring", 10, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
pHashTable->SetEntry(&pHashTable, (PVOID)"liquid", 6, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 2);
assert(pHashTable->DeleteEntry(pHashTable, "costarring", 10, FALSE, FALSE) == TRUE);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
assert(*(int*)(pHashTable->GetValue(pHashTable, (PVOID)"liquid", 6)) == dwValue);
assert(GetLastError() == ERROR_SUCCESS);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_Nonexistent_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
DWORD dwValue = 0x00ABCDEF;
CHAR* pTestKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 5);
assert(pTestKey != NULL);
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, (PVOID)"test", 4, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
assert(pHashTable->DeleteEntry(pHashTable, (PVOID)"aaaa", 4, FALSE, FALSE) == FALSE);
assert(GetLastError() == ERROR_NO_MATCH);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_DeleteEntry_Free_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
DWORD dwValue = 0x00ABCDEF;
CHAR* pTestKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 5);
assert(pTestKey != NULL);
memcpy(pTestKey, (void*)"test", 5);
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, (PVOID)pTestKey, 4, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 1);
assert(pHashTable->DeleteEntry(pHashTable, (PVOID)pTestKey, 4, TRUE, FALSE) == TRUE);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 0);
assert(pHashTable->GetValue(pHashTable, "test", 4) == FALSE);
assert(GetLastError() == ERROR_NO_MATCH);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
/* GetNumberOfEntries Tests *************************************************************/
static void Test_GetNumberOfEntries_NULL_Table()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(pHashTable != NULL);
assert(pHashTable->GetNumberOfEntries(NULL) == 0);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_GetNumberOfEntries_3_Entries()
{
PHASH_TABLE pHashTable = CreateHashTable(7, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
pHashTable->SetEntry(&pHashTable, "test1", 5, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
pHashTable->SetEntry(&pHashTable, "test2", 5, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
pHashTable->SetEntry(&pHashTable, "test3", 5, (PVOID)&dwValue);
assert(GetLastError() == ERROR_SUCCESS);
assert(pHashTable->GetNumberOfEntries(pHashTable) == 3);
assert(GetLastError() == ERROR_SUCCESS);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
/* GetValue Tests *************************************************************/
static void Test_GetValue_NULL_Table()
{
PHASH_TABLE pHashTable = CreateHashTable(7, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
assert(pHashTable->GetValue(NULL, "test", 4) == NULL);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_GetValue_NULL_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(7, 0.50);
DWORD dwValue = 0x00ABCDEF;
assert(pHashTable != NULL);
assert(pHashTable->GetValue(pHashTable, NULL, 4) == NULL);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_GetValue_0_KeyLength()
{
PHASH_TABLE pHashTable = CreateHashTable(31, 0.50);
DWORD dwValue0 = 0x00ABCDEF;
DWORD dwValue1 = 0xFFFFFFFF;
DWORD dwValue2 = 0x10101010;
assert(pHashTable != NULL);
assert(pHashTable->SetEntry(&pHashTable, "test", 4, &dwValue0) == TRUE);
assert(pHashTable->GetValue(pHashTable, "test", 0) == NULL);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_GetValue_NonExistent_Key()
{
PHASH_TABLE pHashTable = CreateHashTable(31, 0.50);
DWORD dwValue0 = 0x00ABCDEF;
DWORD dwValue1 = 0xFFFFFFFF;
DWORD dwValue2 = 0x10101010;
assert(pHashTable != NULL);
assert(pHashTable->SetEntry(&pHashTable, "test", 4, &dwValue0) == TRUE);
assert(pHashTable->SetEntry(&pHashTable, "costarring", 10, &dwValue1) == TRUE);
assert(pHashTable->SetEntry(&pHashTable, "liquid", 6, &dwValue2) == TRUE);
assert(pHashTable->GetValue(pHashTable, "test1", 5) == NULL);
assert(GetLastError() == ERROR_NO_MATCH);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_GetValue()
{
PHASH_TABLE pHashTable = CreateHashTable(31, 0.50);
DWORD dwValue0 = 0x00ABCDEF;
DWORD dwValue1 = 0xFFFFFFFF;
DWORD dwValue2 = 0x10101010;
assert(pHashTable != NULL);
assert(pHashTable->SetEntry(&pHashTable, "test", 4, &dwValue0) == TRUE);
assert(pHashTable->SetEntry(&pHashTable, "costarring", 10, &dwValue1) == TRUE);
assert(pHashTable->SetEntry(&pHashTable, "liquid", 6, &dwValue2) == TRUE);
assert(*(DWORD *)pHashTable->GetValue(pHashTable, "test", 4) == dwValue0);
assert(GetLastError() == ERROR_SUCCESS);
// create a list with keys that collide
assert(*(DWORD*)pHashTable->GetValue(pHashTable, "costarring", 10) == dwValue1);
assert(GetLastError() == ERROR_SUCCESS);
assert(*(DWORD*)pHashTable->GetValue(pHashTable, "liquid", 6) == dwValue2);
assert(GetLastError() == ERROR_SUCCESS);
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_IterateTable()
{
PHASH_TABLE pHashTable = CreateHashTable(31, 0.50);
assert(pHashTable != NULL);
char *strA = "test_value";
char *strB = "costarring_value";
char *strC = "liquid_value";
pHashTable->SetEntry(&pHashTable, (PVOID)"test", 4, (PVOID)strA);
pHashTable->SetEntry(&pHashTable, (PVOID)"costarring", 10, (PVOID)strB);
pHashTable->SetEntry(&pHashTable, (PVOID)"liquid", 6, (PVOID)strC);
printf("\nNumber of entries is: %zu\n", pHashTable->GetNumberOfEntries(pHashTable)); // 5
PHASH_ENTRY pHashEntry = NULL;
PHASH_TABLE_ITERATOR sIterator = _HashTableGetFirstEntry(pHashTable, &pHashEntry);
BOOL f = TRUE;
while (pHashEntry)
{
if (f)
{
printf("{%s: %s ", (char*)pHashEntry->pKey, (char *)pHashEntry->pValue);
f = FALSE;
}
else
printf(", %s: %s", (char*)pHashEntry->pKey, (char *)pHashEntry->pValue);
_HashTableGetNextEntry(&sIterator, &pHashEntry);
}
if(!f)
printf("}\n\n");
FreeHashTable(&pHashTable, FALSE, FALSE);
}
static void Test_FreeHashTable()
{
PHASH_TABLE pHashTable = CreateHashTable(0, 0.50);
assert(GetLastError() == ERROR_INVALID_PARAMETER);
assert(pHashTable == NULL);
}
static
void RunTests()
{
/* IsPrime tests*/
Test_IsPrime_0();
Test_IsPrime_1();
Test_IsPrime_2();
Test_IsPrime_3();
Test_IsPrime_4();
Test_IsPrime_5();
Test_IsPrime_6();
Test_IsPrime_7();
/* FindClosestPrime tests*/
Test_FindClosestPrime_0();
Test_FindClosestPrime_1201();
Test_FindClosestPrime_4294967290();
Test_FindClosestPrime_SIZE_MAX();
/* _Fnv1aHash32 tests*/
Test__Fnv1aHash32_When_Data_Is_Null();
Test__Fnv1aHash32_When_Data_Length_Is_0();
Test__Fnv1aHash32_KnownPlainText();
/* CreateHashTableTests*/
Test_CreateHashTable_0_Load_Factor();
Test_CreateHashTable_SIZE_MAX_Entries();
Test_CreateHashTable();
/* SetEntry Test*/
Test_SetEntry_NULL_Table();
Test_SetEntry_NULL_pKey();
Test_SetEntry_Test_Key();
Test_SetEntry_Test_Keys();
Test_SetEntry_Test_Keys_Known_Collision();
/* Delete Entry */
Test_DeleteEntry_NULL_Table();
Test_DeleteEntry_NULL_Key();
Test_DeleteEntry_0_nKeyLength();
Test_DeleteEntry_Test_Key();
Test_DeleteEntry_From_List();
Test_DeleteEntry_Head_From_List();
Test_DeleteEntry_Nonexistent_Key();
Test_DeleteEntry_Free_Key();
/* GetNumberOfEntries tests*/
Test_GetNumberOfEntries_NULL_Table();
Test_GetNumberOfEntries_3_Entries();
/* GetValue tests */
Test_GetValue_NULL_Table();
Test_GetValue_NULL_Key();
Test_GetValue_0_KeyLength();
Test_GetValue_NonExistent_Key();
Test_GetValue();
/* Iterate tests */
Test_IterateTable();
printf("All tests have passed\n");
}
void main()
{
RunTests();
}
#endif