UnitTests: Add build script and move current tests to "tests/Engine" directory (from "tests/Nazara")

Former-commit-id: 5639305bbdbb69ad6f6f282df6c6de930220b57f
This commit is contained in:
Lynix
2015-09-19 01:14:19 +02:00
parent a09f859144
commit a61f968d05
24 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#include <Nazara/Core/File.hpp>
#include <Catch/catch.hpp>
SCENARIO("File", "[CORE][FILE]")
{
GIVEN("One file")
{
WHEN("We create a new file")
{
NzFile file("Test File.txt", nzOpenMode_ReadWrite);
REQUIRE(file.GetDirectory() == NzDirectory::GetCurrent() + NAZARA_DIRECTORY_SEPARATOR);
CHECK(file.IsOpen());
THEN("We are allowed to write 3 times 'Test String'")
{
const char message[12] = "Test String"; // 11 + '\0'
NzByteArray byteArray(message, 11);
file.Write("Test String");
file.Write(byteArray);
file.Write(message, sizeof(char), 11);
}
AND_THEN("We can retrieve 3 times 'Test String'")
{
char message[12];
REQUIRE(file.Read(message, 11) == 11);
message[11] = '\0';
REQUIRE(NzString(message) == "Test String");
REQUIRE(file.Read(message, sizeof(char), 11) == 11);
message[11] = '\0';
REQUIRE(NzString(message) == "Test String");
}
AND_THEN("We close it")
{
file.Close();
REQUIRE(file.GetSize() == 33U);
CHECK(!file.IsOpen());
}
}
WHEN("We delete this file")
{
NzFile::Delete("Test File.txt");
THEN("It doesn't exist anymore")
{
CHECK(!NzFile::Exists("Test File.txt"));
}
}
}
}