Fix StringStream tests
This commit is contained in:
parent
9911c6e07c
commit
ee06fffd03
|
|
@ -229,7 +229,7 @@ namespace Nz
|
||||||
|
|
||||||
// Use a temporary buffer to prevent 1kb string capacity growth
|
// Use a temporary buffer to prevent 1kb string capacity growth
|
||||||
std::array<char, maxSize + 1> buffer;
|
std::array<char, maxSize + 1> buffer;
|
||||||
std::size_t written = std::snprintf(buffer.data(), buffer.size(), "%f", number);
|
std::size_t written = std::snprintf(buffer.data(), buffer.size(), "%.6f", number);
|
||||||
|
|
||||||
std::size_t start = m_result.GetSize();
|
std::size_t start = m_result.GetSize();
|
||||||
m_result.Resize(start + written);
|
m_result.Resize(start + written);
|
||||||
|
|
@ -251,7 +251,7 @@ namespace Nz
|
||||||
|
|
||||||
// Use a temporary buffer to prevent 1kb string capacity growth
|
// Use a temporary buffer to prevent 1kb string capacity growth
|
||||||
std::array<char, maxSize + 1> buffer;
|
std::array<char, maxSize + 1> buffer;
|
||||||
std::size_t written = std::snprintf(buffer.data(), buffer.size(), "%f", number);
|
std::size_t written = std::snprintf(buffer.data(), buffer.size(), "%.6Lf", number);
|
||||||
|
|
||||||
std::size_t start = m_result.GetSize();
|
std::size_t start = m_result.GetSize();
|
||||||
m_result.Resize(start + written);
|
m_result.Resize(start + written);
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,22 @@ SCENARIO("StringStream", "[CORE][STRINGSTREAM]")
|
||||||
REQUIRE(stringStream.ToString() == "default-33-33");
|
REQUIRE(stringStream.ToString() == "default-33-33");
|
||||||
}
|
}
|
||||||
|
|
||||||
AND_WHEN("We add floating points")
|
AND_WHEN("We add round floating points")
|
||||||
{
|
{
|
||||||
stringStream << 3.f;
|
stringStream << 3.f;
|
||||||
stringStream << 3.0;
|
stringStream << 3.0;
|
||||||
stringStream << 3.0L;
|
stringStream << 3.0L;
|
||||||
|
|
||||||
REQUIRE(stringStream.ToString() == "default333");
|
REQUIRE(stringStream.ToString() == "default3.0000003.0000003.000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
AND_WHEN("We add floating points")
|
||||||
|
{
|
||||||
|
stringStream << 3.5f << ' ';
|
||||||
|
stringStream << 3.65 << ' ';
|
||||||
|
stringStream << 3.6478L;
|
||||||
|
|
||||||
|
REQUIRE(stringStream.ToString() == "default3.500000 3.650000 3.647800");
|
||||||
}
|
}
|
||||||
|
|
||||||
AND_WHEN("We add string and pointer")
|
AND_WHEN("We add string and pointer")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue