mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-04 15:19:09 +00:00
FloatUtils: Remove IntDouble and IntFloat
Type punning via unions in C++ invokes undefined behavior. Instead, leverage BitCast, our variant of C++2a's std::bit_cast
This commit is contained in:
parent
bde4e970f1
commit
0a3631cc76
3 changed files with 32 additions and 46 deletions
|
@ -10,8 +10,8 @@
|
|||
|
||||
#include <gtest/gtest.h> // NOLINT
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Common/FloatUtils.h"
|
||||
#include "VideoCommon/CPMemory.h"
|
||||
#include "VideoCommon/DataReader.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
|
@ -72,14 +72,15 @@ protected:
|
|||
m_src.Write<T, true>(val);
|
||||
}
|
||||
|
||||
void ExpectOut(float val)
|
||||
void ExpectOut(float expected)
|
||||
{
|
||||
// Read unswapped.
|
||||
Common::IntFloat expected(val), actual(m_dst.Read<float, false>());
|
||||
if (!actual.f || actual.f != actual.f)
|
||||
EXPECT_EQ(expected.i, actual.i);
|
||||
const float actual = m_dst.Read<float, false>();
|
||||
|
||||
if (!actual || actual != actual)
|
||||
EXPECT_EQ(Common::BitCast<u32>(expected), Common::BitCast<u32>(actual));
|
||||
else
|
||||
EXPECT_EQ(expected.f, actual.f);
|
||||
EXPECT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
void RunVertices(int count, int expected_count = -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue