#include <stdio.h>
#include <stdlib.h>
#include <bee2/core/util.h>
static const char* utilInfo()
{
static char descr[128];
sprintf(descr, "%s,B_PER_W=%d,B_PER_S=%d,%s",
(OCTET_ORDER == LITTLE_ENDIAN) ? "LITTLE_ENDIAN" : "BIG_ENDIAN",
B_PER_W, B_PER_S,
#ifdef SAFE_FAST
"FAST"
#else
"SAFE"
#endif
);
return descr;
}
static size_t _ctr = 5;
static void destroy1()
{
if (_ctr != 2)
{
printf("Assertion in %s::%d\n", __FILE__, __LINE__);
abort();
}
}
static void destroy2()
{
_ctr--;
}
bool_t utilTest()
{
printf("utilVersion: %s [%s]\n", utilVersion(), utilInfo());
if (utilMin(5, SIZE_1, (size_t)2, (size_t)3, SIZE_1, SIZE_0) != 0 ||
utilMax(5, SIZE_1, (size_t)2, (size_t)3, SIZE_1, SIZE_0) != 3)
return FALSE;
if (!utilOnExit(destroy1) || !utilOnExit(destroy2) ||
!utilOnExit(destroy2) || !utilOnExit(destroy2))
return FALSE;
if (utilCRC32("123456789", 9, 0) != 0xCBF43926)
return FALSE;
if (utilFNV32("3pjNqM", 6, 0x811C9DC5) != 0)
return FALSE;
return TRUE;
}