Tests: Handle integer floating point numbers
This commit is contained in:
parent
31766eaf8d
commit
d8ed251ad1
|
@ -171,6 +171,19 @@ static inline vec128_t vec128i(uint32_t x, uint32_t y, uint32_t z, uint32_t w) {
|
|||
v.u32[3] = w;
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128q(uint64_t src) {
|
||||
vec128_t v;
|
||||
for (auto i = 0; i < 2; ++i) {
|
||||
v.i64[i] = src;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128q(uint64_t x, uint64_t y) {
|
||||
vec128_t v;
|
||||
v.i64[0] = x;
|
||||
v.i64[1] = y;
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128d(double src) {
|
||||
vec128_t v;
|
||||
for (auto i = 0; i < 2; ++i) {
|
||||
|
|
|
@ -147,11 +147,28 @@ bool PPCContext::CompareRegWithString(const char* name, const char* value,
|
|||
}
|
||||
return true;
|
||||
} else if (sscanf(name, "f%d", &n) == 1) {
|
||||
double expected = string_util::from_string<double>(value);
|
||||
// TODO(benvanik): epsilon
|
||||
if (this->f[n] != expected) {
|
||||
std::snprintf(out_value, out_value_size, "%f", this->f[n]);
|
||||
return false;
|
||||
if (std::strstr(value, "0x")) {
|
||||
// Special case: Treat float as integer.
|
||||
uint64_t expected = string_util::from_string<uint64_t>(value, true);
|
||||
|
||||
union {
|
||||
double f;
|
||||
uint64_t u;
|
||||
} f2u;
|
||||
f2u.f = this->f[n];
|
||||
|
||||
if (f2u.u != expected) {
|
||||
std::snprintf(out_value, out_value_size, "%016" PRIX64, f2u.u);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
double expected = string_util::from_string<double>(value);
|
||||
|
||||
// TODO(benvanik): epsilon
|
||||
if (this->f[n] != expected) {
|
||||
std::snprintf(out_value, out_value_size, "%f", this->f[n]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (sscanf(name, "v%d", &n) == 1) {
|
||||
|
|
Loading…
Reference in New Issue