@@ -1,6 +1,7 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#include "wapp.h"
|
||||
#include "test_hashset.h"
|
||||
|
||||
wp_persist inline WpU8Stream encoder(void *data);
|
||||
wp_persist inline b8 key_eq(void *a, void *b);
|
||||
@@ -27,6 +28,13 @@ WpTestFuncResult test_hashset_alloc(void) {
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_hashset_get_item_size(void) {
|
||||
b8 result = true;
|
||||
WpHashSet set = wpHashSet(WpStr8, encoder, key_eq, 8);
|
||||
result = result && wpHashSetItemSize(&set) == sizeof(WpStr8);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_hashset_find(void) {
|
||||
b8 result = true;
|
||||
WpHashSet set = wpHashSet(WpStr8, encoder, key_eq, 8);
|
||||
@@ -70,7 +78,7 @@ WpTestFuncResult test_hashset_insert_capped(void) {
|
||||
|
||||
result = result && wpHashSetCapacity(&set) == 4 && wpHashSetCount(&set) == 3;
|
||||
for (u64 i = 0; i < 3; ++i) {
|
||||
result = result && wpStr8Equal(wpArrayGet(WpStr8, set.keys, i), &keys[i]);
|
||||
result = result && wpStr8Equal(&wpHashSetItems(WpStr8, &set)[i], &keys[i]);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
@@ -95,7 +103,7 @@ WpTestFuncResult test_hashset_insert_alloc(void) {
|
||||
}
|
||||
|
||||
result = result && set.keys != set_keys && wpHashSetCapacity(&set) == 8 && wpHashSetCount(&set) == 4;
|
||||
for (u64 i = 0; i < 3; ++i) {
|
||||
for (u64 i = 0; i < wpArrayCount(keys); ++i) {
|
||||
result = result && wpStr8Equal(&wpHashSetItems(WpStr8, &set)[i], &keys[i]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user