Fixes
This commit is contained in:
@ -23,13 +23,13 @@ set(TEST_SOURCES
|
||||
|
||||
add_executable(IACore_Test_Suite ${TEST_SOURCES})
|
||||
|
||||
# Enable exceptions for testing framework (even if Core is no-except)
|
||||
# Enable exceptions for testing framework
|
||||
target_compile_options(IACore_Test_Suite PRIVATE -fexceptions)
|
||||
set_target_properties(IACore_Test_Suite PROPERTIES USE_EXCEPTIONS ON)
|
||||
|
||||
target_link_libraries(IACore_Test_Suite PRIVATE IACore)
|
||||
|
||||
# Copy necessary runtime assets if you have them (like the LongProcess test subject)
|
||||
# Copy necessary runtime assets
|
||||
add_custom_command(TARGET IACore_Test_Suite POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_FILE:LongProcess>
|
||||
|
||||
@ -23,8 +23,6 @@ using namespace IACore;
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constants
|
||||
// -----------------------------------------------------------------------------
|
||||
// We use a unique prefix to ensure we don't accidentally mess with real
|
||||
// system variables like PATH or HOME.
|
||||
static const char *TEST_KEY = "IA_TEST_ENV_VAR_12345";
|
||||
static const char *TEST_VAL = "Hello World";
|
||||
|
||||
@ -123,7 +121,6 @@ BOOL TestDefaults()
|
||||
// -------------------------------------------------------------------------
|
||||
// 5. Empty Strings vs Null/Unset
|
||||
// -------------------------------------------------------------------------
|
||||
// This is a critical edge case.
|
||||
// Does Set(Key, "") create an existing empty variable, or unset it?
|
||||
// Standard POSIX/Windows API behavior is that it EXISTS, but is empty.
|
||||
BOOL TestEmptyValue()
|
||||
|
||||
@ -50,7 +50,6 @@ BOOL TestBasicRun()
|
||||
IAT_CHECK(result.has_value());
|
||||
IAT_CHECK_EQ(*result, 0); // Exit code 0
|
||||
|
||||
// Note: Echo might add newline, but your LineBuffer trims/handles it.
|
||||
// We check if "HelloIA" is contained or equal.
|
||||
IAT_CHECK(captured.find("HelloIA") != String::npos);
|
||||
|
||||
@ -137,14 +136,9 @@ BOOL TestMissingExe()
|
||||
// -------------------------------------------------------------------------
|
||||
BOOL TestLargeOutput()
|
||||
{
|
||||
// We need to generate output larger than the internal 4096 buffer
|
||||
// Need to generate output larger than the internal 4096 buffer
|
||||
// to ensure the "partial line" logic works when a line crosses a buffer boundary.
|
||||
|
||||
// We will construct a python script or shell command to print a massive line.
|
||||
// Cross platform approach: Use Python if available, or just a long echo.
|
||||
// Let's assume 'python3' or 'python' is in path, otherwise skip?
|
||||
// Safer: Use pure shell loop if possible, or just a massive command line arg.
|
||||
|
||||
String massiveString;
|
||||
massiveString.reserve(5000);
|
||||
for (int i = 0; i < 500; ++i)
|
||||
@ -223,10 +217,6 @@ BOOL TestComplexArguments()
|
||||
// 3. path/to/file
|
||||
String complexArgs = "-DDEFINED_MSG=\\\"Hello World\\\" -v path/to/file";
|
||||
|
||||
// We can't easily inspect the child process argv in this unit test framework without
|
||||
// writing a dedicated child program that prints its argv.
|
||||
// However, for now, we ensure it doesn't crash or return error code 127.
|
||||
|
||||
// Use "echo" to verify what it received.
|
||||
// Expected output: -DDEFINED_MSG="Hello World" -v path/to/file
|
||||
String cmd = "/bin/echo";
|
||||
|
||||
@ -21,7 +21,9 @@ using namespace IACore;
|
||||
|
||||
IAT_BEGIN_BLOCK(Core, RingBuffer)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 1. Basic Push Pop
|
||||
// -------------------------------------------------------------------------
|
||||
BOOL TestPushPop()
|
||||
{
|
||||
// Allocate raw memory for the ring buffer
|
||||
@ -54,7 +56,9 @@ BOOL TestPushPop()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// 2. Wrap Around (The hardest logic to get right)
|
||||
// -------------------------------------------------------------------------
|
||||
// 2. Wrap Around
|
||||
// -------------------------------------------------------------------------
|
||||
BOOL TestWrapAround()
|
||||
{
|
||||
// Small buffer to force wrapping quickly
|
||||
|
||||
@ -20,10 +20,6 @@
|
||||
|
||||
using namespace IACore;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Block Definition
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IAT_BEGIN_BLOCK(Core, StreamReader)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -53,14 +49,13 @@ BOOL TestReadUint8()
|
||||
BOOL TestReadMultiByte()
|
||||
{
|
||||
// 0x04030201 in Little Endian memory layout
|
||||
// IACore always assumes a Little Endian machine
|
||||
UINT8 data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
StreamReader reader(data);
|
||||
|
||||
auto val = reader.Read<UINT32>();
|
||||
IAT_CHECK(val.has_value());
|
||||
|
||||
// Assuming standard x86/ARM Little Endian for this test
|
||||
// If your engine supports Big Endian, you'd check architecture here
|
||||
IAT_CHECK_EQ(*val, (UINT32) 0x04030201);
|
||||
|
||||
IAT_CHECK_EQ(reader.Cursor(), (SIZE_T) 4);
|
||||
|
||||
@ -88,7 +88,6 @@ BOOL TestHexErrors()
|
||||
// Odd Length
|
||||
auto odd = IACore::Utils::HexStringToBinary("ABC");
|
||||
IAT_CHECK_NOT(odd.has_value());
|
||||
// Optional: IAT_CHECK_EQ(odd.error(), "Hex string must have even length");
|
||||
|
||||
// Invalid Characters
|
||||
auto invalid = IACore::Utils::HexStringToBinary("ZZTOP");
|
||||
@ -178,9 +177,8 @@ BOOL TestHashMacro()
|
||||
{
|
||||
TestVec3 v1{1.0f, 2.0f, 3.0f};
|
||||
TestVec3 v2{1.0f, 2.0f, 3.0f};
|
||||
TestVec3 v3{1.0f, 2.0f, 4.0f}; // Slight change
|
||||
TestVec3 v3{1.0f, 2.0f, 4.0f};
|
||||
|
||||
// Instantiate the hasher manually to verify the struct specialization exists
|
||||
ankerl::unordered_dense::hash<TestVec3> hasher;
|
||||
|
||||
UINT64 h1 = hasher(v1);
|
||||
@ -194,10 +192,6 @@ BOOL TestHashMacro()
|
||||
// Verify ComputeHash integration
|
||||
// -------------------------------------------------------------
|
||||
|
||||
// We cannot check EQ(h1, ComputeHash(v1)) because ComputeHash applies
|
||||
// one extra layer of "Golden Ratio Mixing" on top of the object's hash.
|
||||
// Instead, we verify that ComputeHash behaves exactly like a manual HashCombine.
|
||||
|
||||
UINT64 hManual = 0;
|
||||
IACore::Utils::HashCombine(hManual, v1);
|
||||
|
||||
@ -206,7 +200,7 @@ BOOL TestHashMacro()
|
||||
// This proves ComputeHash found the specialization and mixed it correctly
|
||||
IAT_CHECK_EQ(hManual, hWrapper);
|
||||
|
||||
// Optional: Verify the avalanche effect took place (hWrapper should NOT be h1)
|
||||
// Verify the avalanche effect took place (hWrapper should NOT be h1)
|
||||
IAT_CHECK_NEQ(h1, hWrapper);
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user