#include <bee2/core/hex.h>
#include <bee2/core/mem.h>
#include <bee2/core/str.h>
#include <bee2/crypto/belt.h>
bool_t hexTest()
{
octet buf[256];
char hex[512 + 1];
char hex1[512 + 1];
size_t count;
if (!hexIsValid("1234") ||
hexIsValid("12345") ||
!hexIsValid("ABCDEFabcdef") ||
hexIsValid("abcdefgh"))
return FALSE;
for (count = 0; count <= 256; ++count)
{
hexFrom(hex, beltH(), count);
if (!hexEq(beltH(), hex))
return FALSE;
hexTo(buf, hex);
if (!memEq(buf, beltH(), count))
return FALSE;
hexFromRev(hex, beltH(), count);
if (!hexEqRev(beltH(), hex))
return FALSE;
hexToRev(buf, hex);
if (!memEq(buf, beltH(), count))
return FALSE;
memCopy(hex1, hex, sizeof(hex));
hexLower(hex1);
hexUpper(hex1);
if (!strEq(hex, hex1))
return FALSE;
}
return TRUE;
}