UnitTests: Add build script and move current tests to "tests/Engine" directory (from "tests/Nazara")
Former-commit-id: 5639305bbdbb69ad6f6f282df6c6de930220b57f
This commit is contained in:
71
tests/Engine/Core/StringStream.cpp
Normal file
71
tests/Engine/Core/StringStream.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Catch/catch.hpp>
|
||||
|
||||
SCENARIO("StringStream", "[CORE][STRINGSTREAM]")
|
||||
{
|
||||
GIVEN("A string stream")
|
||||
{
|
||||
NzStringStream stringstream("default");
|
||||
|
||||
WHEN("We add bool and char")
|
||||
{
|
||||
stringstream << true;
|
||||
|
||||
char valueCharSigned = 64;
|
||||
stringstream << valueCharSigned;
|
||||
unsigned char valueCharUnsigned = 64;
|
||||
stringstream << valueCharUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "defaulttrue@@");
|
||||
}
|
||||
|
||||
AND_WHEN("We add short and int")
|
||||
{
|
||||
short valueShortSigned = -3;
|
||||
stringstream << valueShortSigned;
|
||||
unsigned short valueShortUnsigned = 3;
|
||||
stringstream << valueShortUnsigned;
|
||||
|
||||
int valueIntSigned = -3;
|
||||
stringstream << valueIntSigned;
|
||||
unsigned int valueIntUnsigned = 3;
|
||||
stringstream << valueIntUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default-33-33");
|
||||
}
|
||||
|
||||
AND_WHEN("We add long and long long")
|
||||
{
|
||||
long valueLongSigned = -3;
|
||||
stringstream << valueLongSigned;
|
||||
unsigned long valueLongUnsigned = 3;
|
||||
stringstream << valueLongUnsigned;
|
||||
|
||||
long long valueLongLongSigned = -3;
|
||||
stringstream << valueLongLongSigned;
|
||||
unsigned long long valueLongLongUnsigned = 3;
|
||||
stringstream << valueLongLongUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default-33-33");
|
||||
}
|
||||
|
||||
AND_WHEN("We add floating points")
|
||||
{
|
||||
stringstream << 3.f;
|
||||
stringstream << 3.0;
|
||||
stringstream << 3.0L;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default333");
|
||||
}
|
||||
|
||||
AND_WHEN("We add string and pointer")
|
||||
{
|
||||
stringstream << "3";
|
||||
stringstream << std::string("3");
|
||||
stringstream << NzString("3");
|
||||
stringstream << static_cast<void*>(nullptr);
|
||||
|
||||
REQUIRE(stringstream.ToString() == (NzString("default3330x") + NzString(sizeof(void*) * 2, "0")));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user