tests: add FFstrbuf smallest allocation test & minor fix (#1387)

This commit is contained in:
apocelipes 2024-11-11 07:58:24 +08:00 committed by GitHub
parent 07d0743a18
commit 0a61031463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -116,7 +116,7 @@ int main(void)
{
FF_LIST_AUTO_DESTROY test = ffListCreate(1);
VERIFY(test.elementSize = 1);
VERIFY(test.elementSize == 1);
VERIFY(test.capacity == 0);
VERIFY(test.length == 0);
}

View File

@ -442,6 +442,19 @@ int main(void)
VERIFY(ffStrbufEqualS(&strbuf, "AA12BB3456CCDD"));
ffStrbufDestroy(&strbuf);
// smallest allocation test
{
FF_STRBUF_AUTO_DESTROY strbuf1 = ffStrbufCreateA(10);
VERIFY(strbuf1.allocated == 10);
ffStrbufEnsureFree(&strbuf1, 16);
VERIFY(strbuf1.allocated == 32);
FF_STRBUF_AUTO_DESTROY strbuf2 = ffStrbufCreate();
VERIFY(strbuf2.allocated == 0);
ffStrbufEnsureFree(&strbuf2, 16);
VERIFY(strbuf2.allocated == 32);
}
//Success
puts("\e[32mAll tests passed!" FASTFETCH_TEXT_MODIFIER_RESET);
}