Added clock time
Some checks failed
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 1m32s
CI / Windows Release Package (push) Failing after 2m7s

This commit is contained in:
2026-05-06 12:38:23 +10:00
parent d2cf852eb2
commit 414ef62479
17 changed files with 335 additions and 18 deletions

View File

@@ -0,0 +1,50 @@
#include "RuntimeClock.h"
#include <cmath>
#include <iostream>
namespace
{
int gFailures = 0;
void Expect(bool condition, const char* message)
{
if (condition)
return;
std::cerr << "FAIL: " << message << "\n";
++gFailures;
}
void TestUtcSecondsOfDay()
{
const RuntimeClockSnapshot midnight = MakeRuntimeClockSnapshot(0);
Expect(midnight.utcTimeSeconds == 0.0, "Unix epoch starts at UTC midnight");
const RuntimeClockSnapshot midday = MakeRuntimeClockSnapshot(12 * 3600 + 34 * 60 + 56);
Expect(midday.utcTimeSeconds == 45296.0, "UTC time of day is seconds since midnight");
}
void TestOffsetLooksLikeTimezoneOffset()
{
const RuntimeClockSnapshot snapshot = MakeRuntimeClockSnapshot(12 * 3600);
Expect(std::fmod(snapshot.utcOffsetSeconds, 60.0) == 0.0, "UTC offset is minute-aligned");
Expect(snapshot.utcOffsetSeconds >= -14.0 * 3600.0 && snapshot.utcOffsetSeconds <= 14.0 * 3600.0,
"UTC offset is in the normal timezone range");
}
}
int main()
{
TestUtcSecondsOfDay();
TestOffsetLooksLikeTimezoneOffset();
if (gFailures != 0)
{
std::cerr << gFailures << " RuntimeClock test failure(s).\n";
return 1;
}
std::cout << "RuntimeClock tests passed.\n";
return 0;
}

View File

@@ -62,6 +62,8 @@ void TestGlobalParamStylePacking()
AppendStd140Float(buffer, 10.0f); // time
AppendStd140Vec2(buffer, 1920.0f, 1080.0f); // input resolution
AppendStd140Vec2(buffer, 1280.0f, 720.0f); // output resolution
AppendStd140Float(buffer, 45296.0f); // UTC time of day
AppendStd140Float(buffer, 36000.0f); // UTC offset
AppendStd140Float(buffer, 42.0f); // frame count
AppendStd140Float(buffer, 0.5f); // mix
AppendStd140Float(buffer, 1.0f); // bypass
@@ -78,8 +80,10 @@ void TestGlobalParamStylePacking()
Expect(ReadFloat(buffer, 0) == 10.0f, "time is at the start of the block");
Expect(ReadFloat(buffer, 8) == 1920.0f, "first vec2 aligns after scalar padding");
Expect(ReadFloat(buffer, 16) == 1280.0f, "second vec2 follows first vec2");
Expect(ReadInt(buffer, 36) == 3, "history length scalar remains tightly packed");
Expect(ReadFloat(buffer, 48) == 4.0f, "vec2 shader parameter aligns to 8 bytes");
Expect(ReadFloat(buffer, 24) == 45296.0f, "UTC time follows output resolution");
Expect(ReadFloat(buffer, 28) == 36000.0f, "UTC offset follows UTC time");
Expect(ReadInt(buffer, 44) == 3, "history length scalar remains tightly packed");
Expect(ReadFloat(buffer, 56) == 4.0f, "vec2 shader parameter aligns to 8 bytes");
Expect(ReadFloat(buffer, 64) == 0.1f, "color parameter aligns to 16 bytes");
Expect(ReadInt(buffer, 80) == 1, "boolean parameter follows vec4");
Expect(ReadInt(buffer, 84) == 2, "enum parameter follows boolean");