Base IACoreV2
Some checks failed
CI / build-linux-and-wasm (x64-linux) (push) Has been cancelled

This commit is contained in:
2026-01-22 05:54:26 +05:30
parent dedf28c6cb
commit 3ad1e3a2fb
57 changed files with 4398 additions and 4639 deletions

View File

@ -25,7 +25,7 @@ using namespace IACore;
struct TestVec3
{
FLOAT32 x, y, z;
f32 x, y, z;
// Equality operator required for hash maps, though strictly
// the hash function itself doesn't need it, it's good practice to test both.
@ -48,10 +48,10 @@ IAT_BEGIN_BLOCK(Core, Utils)
// -------------------------------------------------------------------------
// 1. Binary <-> Hex String Conversion
// -------------------------------------------------------------------------
BOOL TestHexConversion()
bool TestHexConversion()
{
// A. Binary To Hex
UINT8 bin[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0xFF};
u8 bin[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0xFF};
String hex = IACore::Utils::BinaryToHexString(bin);
IAT_CHECK_EQ(hex, String("DEADBEEF00FF"));
@ -59,7 +59,7 @@ BOOL TestHexConversion()
// B. Hex To Binary (Valid Upper)
auto resUpper = IACore::Utils::HexStringToBinary("DEADBEEF00FF");
IAT_CHECK(resUpper.has_value());
IAT_CHECK_EQ(resUpper->size(), (SIZE_T) 6);
IAT_CHECK_EQ(resUpper->size(), (usize) 6);
IAT_CHECK_EQ((*resUpper)[0], 0xDE);
IAT_CHECK_EQ((*resUpper)[5], 0xFF);
@ -69,7 +69,7 @@ BOOL TestHexConversion()
IAT_CHECK_EQ((*resLower)[0], 0xDE);
// D. Round Trip Integrity
Vector<UINT8> original = {1, 2, 3, 4, 5};
Vec<u8> original = {1, 2, 3, 4, 5};
String s = IACore::Utils::BinaryToHexString(original);
auto back = IACore::Utils::HexStringToBinary(s);
IAT_CHECK(back.has_value());
@ -82,7 +82,7 @@ BOOL TestHexConversion()
// -------------------------------------------------------------------------
// 2. Hex Error Handling
// -------------------------------------------------------------------------
BOOL TestHexErrors()
bool TestHexErrors()
{
// Odd Length
auto odd = IACore::Utils::HexStringToBinary("ABC");
@ -95,7 +95,7 @@ BOOL TestHexErrors()
// Empty string is valid (empty vector)
auto empty = IACore::Utils::HexStringToBinary("");
IAT_CHECK(empty.has_value());
IAT_CHECK_EQ(empty->size(), (SIZE_T) 0);
IAT_CHECK_EQ(empty->size(), (usize) 0);
return TRUE;
}
@ -103,9 +103,9 @@ BOOL TestHexErrors()
// -------------------------------------------------------------------------
// 3. Algorithms: Sorting
// -------------------------------------------------------------------------
BOOL TestSort()
bool TestSort()
{
Vector<int> nums = {5, 1, 4, 2, 3};
Vec<int> nums = {5, 1, 4, 2, 3};
IACore::Utils::Sort(nums);
@ -121,10 +121,10 @@ BOOL TestSort()
// -------------------------------------------------------------------------
// 4. Algorithms: Binary Search (Left/Right)
// -------------------------------------------------------------------------
BOOL TestBinarySearch()
bool TestBinarySearch()
{
// Must be sorted for Binary Search
Vector<int> nums = {10, 20, 20, 20, 30};
Vec<int> nums = {10, 20, 20, 20, 30};
// Search Left (Lower Bound) -> First element >= value
auto itLeft = IACore::Utils::BinarySearchLeft(nums, 20);
@ -148,11 +148,11 @@ BOOL TestBinarySearch()
// -------------------------------------------------------------------------
// 5. Hashing Basics
// -------------------------------------------------------------------------
BOOL TestHashBasics()
bool TestHashBasics()
{
UINT64 h1 = IACore::Utils::ComputeHash(10, 20.5f, "Hello");
UINT64 h2 = IACore::Utils::ComputeHash(10, 20.5f, "Hello");
UINT64 h3 = IACore::Utils::ComputeHash(10, 20.5f, "World");
u64 h1 = IACore::Utils::ComputeHash(10, 20.5f, "Hello");
u64 h2 = IACore::Utils::ComputeHash(10, 20.5f, "Hello");
u64 h3 = IACore::Utils::ComputeHash(10, 20.5f, "World");
// Determinism
IAT_CHECK_EQ(h1, h2);
@ -162,8 +162,8 @@ BOOL TestHashBasics()
// Order sensitivity (Golden ratio combine should care about order)
// Hash(A, B) != Hash(B, A)
UINT64 orderA = IACore::Utils::ComputeHash(1, 2);
UINT64 orderB = IACore::Utils::ComputeHash(2, 1);
u64 orderA = IACore::Utils::ComputeHash(1, 2);
u64 orderB = IACore::Utils::ComputeHash(2, 1);
IAT_CHECK_NEQ(orderA, orderB);
return TRUE;
@ -172,7 +172,7 @@ BOOL TestHashBasics()
// -------------------------------------------------------------------------
// 6. Macro Verification (IA_MAKE_HASHABLE)
// -------------------------------------------------------------------------
BOOL TestHashMacro()
bool TestHashMacro()
{
TestVec3 v1{1.0f, 2.0f, 3.0f};
TestVec3 v2{1.0f, 2.0f, 3.0f};
@ -180,9 +180,9 @@ BOOL TestHashMacro()
ankerl::unordered_dense::hash<TestVec3> hasher;
UINT64 h1 = hasher(v1);
UINT64 h2 = hasher(v2);
UINT64 h3 = hasher(v3);
u64 h1 = hasher(v1);
u64 h2 = hasher(v2);
u64 h3 = hasher(v3);
IAT_CHECK_EQ(h1, h2); // Same content = same hash
IAT_CHECK_NEQ(h1, h3); // Different content = different hash
@ -191,10 +191,10 @@ BOOL TestHashMacro()
// Verify ComputeHash integration
// -------------------------------------------------------------
UINT64 hManual = 0;
u64 hManual = 0;
IACore::Utils::HashCombine(hManual, v1);
UINT64 hWrapper = IACore::Utils::ComputeHash(v1);
u64 hWrapper = IACore::Utils::ComputeHash(v1);
// This proves ComputeHash found the specialization and mixed it correctly
IAT_CHECK_EQ(hManual, hWrapper);