Fixing MacOS build and Spin Test (#9)

* Fixing guid.cpp build error on Mac.

Removing constexpr from functions with reinterpret_cast.

* Fixing Spin_SortValidation on MacOS.

MacOS system_clock only has microsecond precision.
This means we need to wait longer in the test for the timer to change.
Some time > 65 milliseconds.

* Fixing typo and cv -> cV casing in comment.
This commit is contained in:
Casey Irvine 2019-06-21 17:27:56 -07:00 коммит произвёл Mohit Tandon
Родитель 8e22e62458
Коммит cf38d2b44b
3 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -12,14 +12,14 @@ enum class spin_counter_interval
/**
The coarse interval drops the 24 least significant bits in
time_since_epoch resulting in a counter that increments every 1.67
seconds.
seconds (on system with 10 million ticks = 1 second).
*/
coarse = 24,
/**
The fine interval drops the 16 least significant bits in
time_since_epoch resulting in a counter that increments every 6.5
milliseconds.
milliseconds (on system with 10 million ticks = 1 second).
*/
fine = 16
};

Просмотреть файл

@ -38,13 +38,13 @@ constexpr std::array<unsigned char, 16> convert_to_array(const unsigned char* g)
}
#ifdef GUID_WINDOWS
constexpr std::array<unsigned char, 16> convert_to_array(const GUID& g)
std::array<unsigned char, 16> convert_to_array(const GUID& g)
{
return impl::convert_to_array(reinterpret_cast<const unsigned char*>(&g));
}
#endif
#ifdef GUID_LIBUUID
constexpr std::array<unsigned char, 16> convert_to_array(const uuid_t& g)
std::array<unsigned char, 16> convert_to_array(const uuid_t& g)
{
return impl::convert_to_array(reinterpret_cast<const unsigned char*>(g));
}

Просмотреть файл

@ -294,8 +294,17 @@ TEST_CASE("Spin_SortValidation")
lastSpinValue = spinValue;
// MacOS SYSTEM_CLOCK and std::chrono::system_clock have microsecond precision.
// Both Windows and Linux have sub-microsecond precision.
// This means we need to wait a bit longer (over 65 milliseconds) on MacOS
// for the spin operator to change the value of the cV.
#ifdef __APPLE__
// Wait for 70ms
std::this_thread::sleep_for(std::chrono::milliseconds(70));
#else
// Wait for 10ms.
std::this_thread::sleep_for(std::chrono::milliseconds(10));
#endif
}
// The counter should wrap at most 1 time.