MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / testHighResolutionCounterSnap

Method testHighResolutionCounterSnap

Tests/Libraries/Time/TimeTest.cpp:62–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void SC::TimeTest::testHighResolutionCounterSnap()
63{
64 //! [highResolutionCounterSnapSnippet]
65 Time::HighResolutionCounter start, end;
66 start.snap();
67 Thread::Sleep(100);
68 end.snap();
69
70 // Test all time conversion methods
71 Time::Milliseconds elapsedMs = end.subtractExact(start).toMilliseconds();
72 SC_TEST_EXPECT(elapsedMs < 2000_ms and elapsedMs > 0_ms);
73
74 // Test nanoseconds conversion
75 Time::Nanoseconds elapsedNs = end.toNanoseconds();
76 SC_TEST_EXPECT(elapsedNs.ns > 800000000); // More than 800ms in ns
77
78 // Test seconds conversion
79 Time::Seconds elapsedSec = end.toSeconds();
80 SC_TEST_EXPECT(elapsedSec.sec >= 0); // Should be roughly 1 second
81
82 // Test relative time and approximate subtraction
83 Time::Relative relativeTime = end.getRelative();
84 SC_TEST_EXPECT(relativeTime > Time::Relative::fromSeconds(0.8));
85
86 Time::Relative approxTime = end.subtractApproximate(start);
87 SC_TEST_EXPECT(approxTime > Time::Relative::fromSeconds(0.05));
88 //! [highResolutionCounterSnapSnippet]
89}
90
91void SC::TimeTest::testHighResolutionCounterOffsetBy()
92{

Callers

nothing calls this directly

Calls 6

subtractExactMethod · 0.80
getRelativeMethod · 0.80
subtractApproximateMethod · 0.80
toMillisecondsMethod · 0.45
toNanosecondsMethod · 0.45
toSecondsMethod · 0.45

Tested by

no test coverage detected