Test fixes for linux
Former-commit-id: 9d58eba0f30eb968161b212541f2411263162293
This commit is contained in:
parent
a4032abe63
commit
438e45c08e
|
|
@ -3958,12 +3958,12 @@ NzString NzString::Number(unsigned long long number, nzUInt8 radix)
|
||||||
|
|
||||||
NzString NzString::Pointer(const void* ptr)
|
NzString NzString::Pointer(const void* ptr)
|
||||||
{
|
{
|
||||||
const unsigned int size = sizeof(void*)*2 + 2;
|
const unsigned int capacity = sizeof(void*)*2 + 2;
|
||||||
|
|
||||||
char* str = new char[size+1];
|
char* str = new char[capacity+1];
|
||||||
std::sprintf(str, "0x%p", ptr);
|
int size = std::sprintf(str, "0x%p", ptr);
|
||||||
|
|
||||||
return NzString(new SharedString(1, size, size, str));
|
return NzString(new SharedString(1, capacity, size, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Unicode(char32_t character)
|
NzString NzString::Unicode(char32_t character)
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ NzStringStream& NzStringStream::operator<<(const NzString& string)
|
||||||
NzStringStream& NzStringStream::operator<<(const void* ptr)
|
NzStringStream& NzStringStream::operator<<(const void* ptr)
|
||||||
{
|
{
|
||||||
m_strings.push_back(NzString::Pointer(ptr));
|
m_strings.push_back(NzString::Pointer(ptr));
|
||||||
m_bufferSize += sizeof(void*)*2;
|
m_bufferSize += m_strings.back().GetSize();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,18 +247,18 @@ namespace
|
||||||
m_misses = 0;
|
m_misses = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetMissCount()
|
int GetMissCount() const
|
||||||
{
|
{
|
||||||
return m_misses;
|
return m_misses;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetVertex(int which)
|
int GetVertex(int which) const
|
||||||
{
|
{
|
||||||
return m_cache[which];
|
return m_cache[which];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int FindVertex(int v)
|
int FindVertex(int v) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -328,9 +328,9 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float CalculateVertexScore(unsigned int vertex)
|
float CalculateVertexScore(unsigned int vertex) const
|
||||||
{
|
{
|
||||||
VertexCacheData *v = &m_vertices[vertex];
|
const VertexCacheData* v = &m_vertices[vertex];
|
||||||
if (v->remaining_valence <= 0)
|
if (v->remaining_valence <= 0)
|
||||||
// No tri needs this vertex!
|
// No tri needs this vertex!
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
|
|
@ -545,7 +545,7 @@ namespace
|
||||||
float sum = 0.f;
|
float sum = 0.f;
|
||||||
for (unsigned int i = 0; i < 3; ++i)
|
for (unsigned int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
VertexCacheData *v = &m_vertices[t->verts[i]];
|
VertexCacheData* v = &m_vertices[t->verts[i]];
|
||||||
float sc = v->current_score;
|
float sc = v->current_score;
|
||||||
if (!v->calculated)
|
if (!v->calculated)
|
||||||
sc = CalculateVertexScore(t->verts[i]);
|
sc = CalculateVertexScore(t->verts[i]);
|
||||||
|
|
@ -572,13 +572,13 @@ namespace
|
||||||
if (vert < 0)
|
if (vert < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VertexCacheData *v = &m_vertices[vert];
|
const VertexCacheData* v = &m_vertices[vert];
|
||||||
|
|
||||||
// iterate through all *active* triangles of this vertex
|
// iterate through all *active* triangles of this vertex
|
||||||
for (int j=0; j<v->remaining_valence; j++)
|
for (int j = 0; j < v->remaining_valence; j++)
|
||||||
{
|
{
|
||||||
int tri = v->tri_indices[j];
|
int tri = v->tri_indices[j];
|
||||||
TriangleCacheData *t = &m_triangles[tri];
|
TriangleCacheData* t = &m_triangles[tri];
|
||||||
if (!t->calculated)
|
if (!t->calculated)
|
||||||
// calculate triangle score
|
// calculate triangle score
|
||||||
TriangleScoreRecalculation(tri);
|
TriangleScoreRecalculation(tri);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ SCENARIO("StringStream", "[CORE][STRINGSTREAM]")
|
||||||
stringstream << NzString("3");
|
stringstream << NzString("3");
|
||||||
stringstream << static_cast<void*>(nullptr);
|
stringstream << static_cast<void*>(nullptr);
|
||||||
|
|
||||||
REQUIRE(stringstream.ToString() == (NzString("default3330x") + NzString(sizeof(void*) * 2, "0")));
|
REQUIRE(stringstream.ToString() == (NzString("default333") + NzString::Pointer(nullptr)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ SCENARIO("EulerAngles", "[MATH][EULERANGLES]")
|
||||||
{
|
{
|
||||||
THEN("These results are expected")
|
THEN("These results are expected")
|
||||||
{
|
{
|
||||||
REQUIRE(NzEulerAnglesf(NzFromDegrees(45.f), 0.f, 0.f) == NzQuaternionf(0.923879504204f, 0.382683455944f, 0.f, 0.f).ToEulerAngles());
|
REQUIRE(NzEulerAngles<int>(NzFromDegrees(45.f), 0.f, 0.f) == NzEulerAngles<int>(NzQuaternionf(0.923879504204f, 0.382683455944f, 0.f, 0.f).ToEulerAngles()));
|
||||||
REQUIRE(NzEulerAnglesf(0.f, NzFromDegrees(45.f), 0.f) == NzQuaternionf(0.923879504204f, 0.f, 0.382683455944f, 0.f).ToEulerAngles());
|
REQUIRE(NzEulerAngles<int>(0.f, NzFromDegrees(45.f), 0.f) == NzEulerAngles<int>(NzQuaternionf(0.923879504204f, 0.f, 0.382683455944f, 0.f).ToEulerAngles()));
|
||||||
//REQUIRE(NzEulerAnglesf(0.f, 0.f, NzFromDegrees(45.f)) == NzQuaternionf(0.923879504204f, 0.f, 0.f, 0.382683455944f).ToEulerAngles());
|
REQUIRE(NzEulerAngles<int>(0.f, 0.f, NzFromDegrees(45.f)) == NzEulerAngles<int>(NzQuaternionf(0.923879504204f, 0.f, 0.f, 0.382683455944f).ToEulerAngles()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ SCENARIO("OrientedBox", "[MATH][ORIENTEDBOX]")
|
||||||
NzOrientedBoxf secondCenterAndUnit(NzOrientedBox<int>(NzVector3i::Zero(), NzVector3i::Unit()));
|
NzOrientedBoxf secondCenterAndUnit(NzOrientedBox<int>(NzVector3i::Zero(), NzVector3i::Unit()));
|
||||||
|
|
||||||
firstCenterAndUnit.Update(NzMatrix4f::Identity());
|
firstCenterAndUnit.Update(NzMatrix4f::Identity());
|
||||||
|
secondCenterAndUnit.Update(NzMatrix4f::Identity());
|
||||||
|
|
||||||
WHEN("We compare them")
|
WHEN("We compare them")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,11 @@ SCENARIO("Quaternion", "[MATH][QUATERNION]")
|
||||||
NzQuaternionf quaterionB(NzFromDegrees(45.f), NzVector3f::UnitZ());
|
NzQuaternionf quaterionB(NzFromDegrees(45.f), NzVector3f::UnitZ());
|
||||||
NzQuaternionf quaternionC = NzQuaternionf::Slerp(quaterionA, quaterionB, 0.5f);
|
NzQuaternionf quaternionC = NzQuaternionf::Slerp(quaterionA, quaterionB, 0.5f);
|
||||||
|
|
||||||
REQUIRE(quaternionC == NzQuaternionf(NzFromDegrees(22.5f), NzVector3f::UnitZ()));
|
NzQuaternionf unitZ225(NzFromDegrees(22.5f), NzVector3f::UnitZ());
|
||||||
|
REQUIRE(quaternionC.w == Approx(unitZ225.w));
|
||||||
|
REQUIRE(quaternionC.x == Approx(unitZ225.x));
|
||||||
|
REQUIRE(quaternionC.y == Approx(unitZ225.y));
|
||||||
|
REQUIRE(quaternionC.z == Approx(unitZ225.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue