// TestAString.cpp
//------------------------------------------------------------------------------

// Includes
//------------------------------------------------------------------------------
#include "TestFramework/TestGroup.h"

// Core
#include <Core/Process/Thread.h>
#include <Core/Time/Timer.h>

//------------------------------------------------------------------------------
TEST_GROUP( TestTimer, TestGroupTest )
{
public:
};

//------------------------------------------------------------------------------
TEST_CASE( TestTimer, Validate )
{
    const Timer t;
    const int64_t before = t.GetNow();
#if defined( __OSX__ ) && defined( __aarch64__ ) // ARM
    // TODO:B Figure out why sleep granularity is so poor on Apple Silicon
    Thread::Sleep( 100 ); // sleep for 100ms
#else
    Thread::Sleep( 10 ); // sleep for 10ms
#endif
    const float elapsed = t.GetElapsed();
    const float elapsedMS = t.GetElapsedMS();
    const int64_t after = t.GetNow();

    // some time must have elapsed
    TEST_ASSERT( after > before );

    // sanity check
    TEST_ASSERT( elapsed >= 0.001f ); // at least 1ms
    TEST_ASSERT( elapsed < 1.000f ); // some sensible value

    // sanity check
    TEST_ASSERT( elapsedMS >= 1.0f ); // at least 1ms
    TEST_ASSERT( elapsedMS < 1000.0f ); // some sensible value
}

//------------------------------------------------------------------------------
