Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -7,7 +7,7 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
{
|
||||
GIVEN("Allocate and raw constructor")
|
||||
{
|
||||
NzByteArray byteArray(3);
|
||||
Nz::ByteArray byteArray(3);
|
||||
|
||||
THEN("Capacity is 3 and size is 0")
|
||||
{
|
||||
@@ -23,7 +23,7 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
{
|
||||
REQUIRE(byteArray.GetSize() == 4);
|
||||
REQUIRE(byteArray.GetCapacity() >= 4);
|
||||
REQUIRE(byteArray == NzByteArray("data", 4));
|
||||
REQUIRE(byteArray == Nz::ByteArray("data", 4));
|
||||
REQUIRE(byteArray.ToString() == "data");
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
GIVEN("Iterator and default constructor")
|
||||
{
|
||||
std::string anotherDataString("anotherData");
|
||||
NzByteArray defaultByte;
|
||||
NzByteArray anotherData(anotherDataString.begin(), anotherDataString.end());
|
||||
Nz::ByteArray defaultByte;
|
||||
Nz::ByteArray anotherData(anotherDataString.begin(), anotherDataString.end());
|
||||
|
||||
WHEN("We assign 'anotherData' with iterator")
|
||||
{
|
||||
@@ -48,11 +48,11 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
|
||||
GIVEN("Copy and Move constructor")
|
||||
{
|
||||
NzByteArray originalArray(3, 64);
|
||||
Nz::ByteArray originalArray(3, 64);
|
||||
|
||||
WHEN("We copy")
|
||||
{
|
||||
NzByteArray copyByteArray(originalArray);
|
||||
Nz::ByteArray copyByteArray(originalArray);
|
||||
|
||||
THEN("We get a copy")
|
||||
{
|
||||
@@ -60,13 +60,13 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
|
||||
AND_WHEN("We modify one")
|
||||
{
|
||||
for (NzByteArray::size_type i = 0; i < copyByteArray.GetSize(); ++i)
|
||||
for (Nz::ByteArray::size_type i = 0; i < copyByteArray.GetSize(); ++i)
|
||||
copyByteArray[i] = 46;
|
||||
|
||||
THEN("They are no more equal")
|
||||
{
|
||||
REQUIRE(copyByteArray != originalArray);
|
||||
REQUIRE(copyByteArray == NzByteArray(3, 46));
|
||||
REQUIRE(copyByteArray == Nz::ByteArray(3, 46));
|
||||
REQUIRE(copyByteArray.GetConstBuffer() != originalArray.GetConstBuffer());
|
||||
}
|
||||
}
|
||||
@@ -75,18 +75,18 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
|
||||
WHEN("We move")
|
||||
{
|
||||
NzByteArray moveByteArray(std::move(originalArray));
|
||||
Nz::ByteArray moveByteArray(std::move(originalArray));
|
||||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
REQUIRE(moveByteArray == NzByteArray(3, 64));
|
||||
REQUIRE(moveByteArray == Nz::ByteArray(3, 64));
|
||||
CHECK(originalArray.IsEmpty());
|
||||
REQUIRE(originalArray.GetCapacity() == 0);
|
||||
REQUIRE(moveByteArray.GetConstBuffer() != originalArray.GetConstBuffer());
|
||||
|
||||
AND_WHEN("We modify the empty one")
|
||||
{
|
||||
originalArray.Prepend(NzByteArray(3, 64));
|
||||
originalArray.Prepend(Nz::ByteArray(3, 64));
|
||||
|
||||
THEN("They are no more equal")
|
||||
{
|
||||
@@ -100,9 +100,9 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
|
||||
GIVEN("Two byte array (abc) and (cba)")
|
||||
{
|
||||
NzByteArray abc("abc", 3);
|
||||
NzByteArray cba;
|
||||
cba = std::move(NzByteArray("cba", 3));
|
||||
Nz::ByteArray abc("abc", 3);
|
||||
Nz::ByteArray cba;
|
||||
cba = std::move(Nz::ByteArray("cba", 3));
|
||||
|
||||
WHEN("We do some antagonists operations")
|
||||
{
|
||||
@@ -116,34 +116,34 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
cba.Erase(cba.end() - 1, cba.end());
|
||||
cba.Erase(cba.end() - 1);
|
||||
|
||||
REQUIRE(abc == NzByteArray("c", 1));
|
||||
REQUIRE(cba == NzByteArray("c", 1));
|
||||
REQUIRE(abc == Nz::ByteArray("c", 1));
|
||||
REQUIRE(cba == Nz::ByteArray("c", 1));
|
||||
|
||||
std::string ab("ab");
|
||||
abc.Insert(abc.begin(), ab.begin(), ab.end());
|
||||
cba += NzByteArray("ba", 2);
|
||||
cba += Nz::ByteArray("ba", 2);
|
||||
|
||||
REQUIRE(abc == NzByteArray("abc", 3));
|
||||
REQUIRE(cba == NzByteArray("cba", 3));
|
||||
REQUIRE(abc == Nz::ByteArray("abc", 3));
|
||||
REQUIRE(cba == Nz::ByteArray("cba", 3));
|
||||
|
||||
abc.PopBack();
|
||||
cba.PopFront();
|
||||
|
||||
REQUIRE(abc == NzByteArray("ab", 2));
|
||||
REQUIRE(cba == NzByteArray("ba", 2));
|
||||
REQUIRE(abc == Nz::ByteArray("ab", 2));
|
||||
REQUIRE(cba == Nz::ByteArray("ba", 2));
|
||||
|
||||
abc.PushBack('c');
|
||||
cba.PushFront('c');
|
||||
|
||||
REQUIRE(abc == NzByteArray("abc", 3));
|
||||
REQUIRE(cba == NzByteArray("cba", 3));
|
||||
REQUIRE(abc == Nz::ByteArray("abc", 3));
|
||||
REQUIRE(cba == Nz::ByteArray("cba", 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("One byte array of capacity 10")
|
||||
{
|
||||
NzByteArray capacityArray(10);
|
||||
Nz::ByteArray capacityArray(10);
|
||||
|
||||
WHEN("We reserve for 100")
|
||||
{
|
||||
@@ -167,7 +167,7 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
}
|
||||
}
|
||||
|
||||
NzByteArray::const_pointer oldBuffer = capacityArray.GetConstBuffer();
|
||||
Nz::ByteArray::const_pointer oldBuffer = capacityArray.GetConstBuffer();
|
||||
WHEN("We reserve for 5, add 'data' for 4 and then shrink to fit")
|
||||
{
|
||||
capacityArray.Reserve(5);
|
||||
@@ -192,14 +192,14 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]")
|
||||
|
||||
GIVEN("Three byte array")
|
||||
{
|
||||
NzByteArray first("hello", 5);
|
||||
NzByteArray second("world", 5);
|
||||
NzByteArray third;
|
||||
Nz::ByteArray first("hello", 5);
|
||||
Nz::ByteArray second("world", 5);
|
||||
Nz::ByteArray third;
|
||||
|
||||
WHEN("We swap first and third, then second and third and finally third and first")
|
||||
{
|
||||
NzByteArray oldFirst(first);
|
||||
NzByteArray oldSecond(second);
|
||||
Nz::ByteArray oldFirst(first);
|
||||
Nz::ByteArray oldSecond(second);
|
||||
|
||||
first.Swap(third);
|
||||
std::swap(second, third);
|
||||
|
||||
@@ -6,8 +6,8 @@ SCENARIO("Clock", "[CORE][CLOCK]")
|
||||
{
|
||||
GIVEN("A clock paused")
|
||||
{
|
||||
nzUInt64 initialTime = 1;
|
||||
NzClock clock(initialTime, true);
|
||||
Nz::UInt64 initialTime = 1;
|
||||
Nz::Clock clock(initialTime, true);
|
||||
|
||||
WHEN("We get time")
|
||||
{
|
||||
@@ -21,7 +21,7 @@ SCENARIO("Clock", "[CORE][CLOCK]")
|
||||
clock.Unpause();
|
||||
THEN("Time must not be the initialTime")
|
||||
{
|
||||
NzThread::Sleep(1);
|
||||
Nz::Thread::Sleep(1);
|
||||
REQUIRE(clock.GetMicroseconds() != initialTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@ SCENARIO("Color", "[CORE][COLOR]")
|
||||
{
|
||||
GIVEN("Two colors, one red (255) and one gray (128)")
|
||||
{
|
||||
NzColor red(255, 0, 0);
|
||||
NzColor grey(128);
|
||||
Nz::Color red(255, 0, 0);
|
||||
Nz::Color grey(128);
|
||||
|
||||
WHEN("We do operations")
|
||||
{
|
||||
THEN("These results are expected")
|
||||
{
|
||||
red += NzColor(0, 0, 0);
|
||||
grey *= NzColor(255);
|
||||
REQUIRE((red + grey) == NzColor(255, 128, 128));
|
||||
REQUIRE((red * grey) == NzColor(128, 0, 0));
|
||||
red += Nz::Color(0, 0, 0);
|
||||
grey *= Nz::Color(255);
|
||||
REQUIRE((red + grey) == Nz::Color(255, 128, 128));
|
||||
REQUIRE((red * grey) == Nz::Color(128, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,28 +5,28 @@ SCENARIO("Directory", "[CORE][DIRECTORY]")
|
||||
{
|
||||
GIVEN("The current directory")
|
||||
{
|
||||
NzDirectory currentDirectory(NzDirectory::GetCurrent());
|
||||
Nz::Directory currentDirectory(Nz::Directory::GetCurrent());
|
||||
CHECK(currentDirectory.Exists());
|
||||
currentDirectory.Open();
|
||||
|
||||
WHEN("We create a new directory Test Directory")
|
||||
{
|
||||
NzDirectory::Create("Test Directory");
|
||||
Nz::Directory::Create("Test Directory");
|
||||
|
||||
THEN("A new directory has been created")
|
||||
{
|
||||
CHECK(NzDirectory::Exists(currentDirectory.GetCurrent() + "/Test Directory"));
|
||||
CHECK(Nz::Directory::Exists(currentDirectory.GetCurrent() + "/Test Directory"));
|
||||
CHECK(currentDirectory.IsOpen());
|
||||
}
|
||||
}
|
||||
|
||||
AND_WHEN("We delete it")
|
||||
{
|
||||
NzDirectory::Remove(currentDirectory.GetCurrent() + "/Test Directory", true);
|
||||
Nz::Directory::Remove(currentDirectory.GetCurrent() + "/Test Directory", true);
|
||||
|
||||
THEN("It doesn't exist anymore")
|
||||
{
|
||||
CHECK(!NzDirectory::Exists(currentDirectory.GetCurrent() + "/Test Directory"));
|
||||
CHECK(!Nz::Directory::Exists(currentDirectory.GetCurrent() + "/Test Directory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
SCENARIO("Error", "[CORE][ERROR]")
|
||||
{
|
||||
nzUInt32 oldFlags = NzError::GetFlags();
|
||||
Nz::UInt32 oldFlags = Nz::Error::GetFlags();
|
||||
|
||||
GIVEN("Multiple errors")
|
||||
{
|
||||
@@ -11,18 +11,18 @@ SCENARIO("Error", "[CORE][ERROR]")
|
||||
{
|
||||
THEN("These errors should be written in the log file")
|
||||
{
|
||||
NzError::Error(nzErrorType_Internal, "nzErrorType_Internal");
|
||||
NzError::Error(nzErrorType_Internal, "nzErrorType_Internal", 2, "Error.cpp", "2nd place Internal");
|
||||
REQUIRE("nzErrorType_Internal" == NzError::GetLastError());
|
||||
NzError::Error(nzErrorType_Normal, "nzErrorType_Normal");
|
||||
NzError::Error(nzErrorType_Normal, "nzErrorType_Normal", 2, "Error.cpp", "2nd place Normal");
|
||||
REQUIRE("nzErrorType_Normal" == NzError::GetLastError());
|
||||
NzError::Error(nzErrorType_Warning, "nzErrorType_Warning");
|
||||
NzError::Error(nzErrorType_Warning, "nzErrorType_Warning", 2, "Error.cpp", "2nd place Warning");
|
||||
REQUIRE("nzErrorType_Warning" == NzError::GetLastError());
|
||||
Nz::Error::Trigger(Nz::ErrorType_Internal, "ErrorType_Internal");
|
||||
Nz::Error::Trigger(Nz::ErrorType_Internal, "ErrorType_Internal", 2, "Error.cpp", "2nd place Internal");
|
||||
REQUIRE("ErrorType_Internal" == Nz::Error::GetLastError());
|
||||
Nz::Error::Trigger(Nz::ErrorType_Normal, "ErrorType_Normal");
|
||||
Nz::Error::Trigger(Nz::ErrorType_Normal, "ErrorType_Normal", 2, "Error.cpp", "2nd place Normal");
|
||||
REQUIRE("ErrorType_Normal" == Nz::Error::GetLastError());
|
||||
Nz::Error::Trigger(Nz::ErrorType_Warning, "ErrorType_Warning");
|
||||
Nz::Error::Trigger(Nz::ErrorType_Warning, "ErrorType_Warning", 2, "Error.cpp", "2nd place Warning");
|
||||
REQUIRE("ErrorType_Warning" == Nz::Error::GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NzError::SetFlags(oldFlags);
|
||||
Nz::Error::SetFlags(oldFlags);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ SCENARIO("File", "[CORE][FILE]")
|
||||
{
|
||||
WHEN("We create a new file")
|
||||
{
|
||||
NzFile file("Test File.txt", nzOpenMode_ReadWrite);
|
||||
REQUIRE(file.GetDirectory() == NzDirectory::GetCurrent() + NAZARA_DIRECTORY_SEPARATOR);
|
||||
Nz::File file("Test File.txt", Nz::OpenMode_ReadWrite);
|
||||
REQUIRE(file.GetDirectory() == Nz::Directory::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);
|
||||
Nz::ByteArray byteArray(message, 11);
|
||||
file.Write("Test String");
|
||||
file.Write(byteArray);
|
||||
file.Write(message, sizeof(char), 11);
|
||||
@@ -25,11 +25,11 @@ SCENARIO("File", "[CORE][FILE]")
|
||||
char message[12];
|
||||
REQUIRE(file.Read(message, 11) == 11);
|
||||
message[11] = '\0';
|
||||
REQUIRE(NzString(message) == "Test String");
|
||||
REQUIRE(Nz::String(message) == "Test String");
|
||||
|
||||
REQUIRE(file.Read(message, sizeof(char), 11) == 11);
|
||||
message[11] = '\0';
|
||||
REQUIRE(NzString(message) == "Test String");
|
||||
REQUIRE(Nz::String(message) == "Test String");
|
||||
}
|
||||
|
||||
AND_THEN("We close it")
|
||||
@@ -42,11 +42,11 @@ SCENARIO("File", "[CORE][FILE]")
|
||||
|
||||
WHEN("We delete this file")
|
||||
{
|
||||
NzFile::Delete("Test File.txt");
|
||||
Nz::File::Delete("Test File.txt");
|
||||
|
||||
THEN("It doesn't exist anymore")
|
||||
{
|
||||
CHECK(!NzFile::Exists("Test File.txt"));
|
||||
CHECK(!Nz::File::Exists("Test File.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ SCENARIO("String", "[CORE][STRING]")
|
||||
{
|
||||
GIVEN("One string 'a'")
|
||||
{
|
||||
NzString aDefaultString(1, 'a');
|
||||
Nz::String aDefaultString(1, 'a');
|
||||
|
||||
WHEN("We add information")
|
||||
{
|
||||
@@ -25,12 +25,12 @@ SCENARIO("String", "[CORE][STRING]")
|
||||
{
|
||||
CHECK(aDefaultString.Contains('D'));
|
||||
CHECK(aDefaultString.Contains("String", 3));
|
||||
CHECK(aDefaultString.Contains(NzString("sTRING"), 3, NzString::CaseInsensitive));
|
||||
CHECK(aDefaultString.Contains(Nz::String("sTRING"), 3, Nz::String::CaseInsensitive));
|
||||
REQUIRE(aDefaultString.FindLast('g') == aDefaultString.GetSize() - 1);
|
||||
CHECK(aDefaultString.EndsWith('G', NzString::CaseInsensitive));
|
||||
CHECK(aDefaultString.EndsWith('G', Nz::String::CaseInsensitive));
|
||||
aDefaultString.Append(" ng bla");
|
||||
REQUIRE(aDefaultString.FindWord("ng") == aDefaultString.GetSize() - 6);
|
||||
//TODO REQUIRE(aDefaultString.FindWord(NzString("ng")) == aDefaultString.GetSize() - 6);
|
||||
//TODO REQUIRE(aDefaultString.FindWord(String("ng")) == aDefaultString.GetSize() - 6);
|
||||
CHECK(aDefaultString.StartsWith("aD"));
|
||||
}
|
||||
}
|
||||
@@ -62,14 +62,14 @@ SCENARIO("String", "[CORE][STRING]")
|
||||
|
||||
GIVEN("The string of number 16 in base 16")
|
||||
{
|
||||
NzString number16;
|
||||
Nz::String number16;
|
||||
|
||||
CHECK(number16.IsEmpty());
|
||||
CHECK(number16.IsNull());
|
||||
|
||||
WHEN("We assign to number 16")
|
||||
{
|
||||
number16 = NzString::Number(16, 16);
|
||||
number16 = Nz::String::Number(16, 16);
|
||||
|
||||
THEN("These results are expected")
|
||||
{
|
||||
@@ -85,7 +85,7 @@ SCENARIO("String", "[CORE][STRING]")
|
||||
/* TODO
|
||||
GIVEN("One unicode string")
|
||||
{
|
||||
NzString unicodeString = NzString::Unicode(U"àéçœÂ官話");
|
||||
String unicodeString = String::Unicode(U"àéçœÂ官話");
|
||||
|
||||
WHEN("We convert to other UTF")
|
||||
{
|
||||
@@ -96,11 +96,11 @@ SCENARIO("String", "[CORE][STRING]")
|
||||
THEN("The result should be the identity")
|
||||
{
|
||||
char* utf8 = unicodeString.GetUtf8Buffer();
|
||||
NzString utf8String = NzString::Unicode(utf8);
|
||||
String utf8String = String::Unicode(utf8);
|
||||
char16_t* utf16 = unicodeString.GetUtf16Buffer();
|
||||
NzString utf16String = NzString::Unicode(utf16);
|
||||
String utf16String = String::Unicode(utf16);
|
||||
char32_t* utf32 = unicodeString.GetUtf32Buffer();
|
||||
NzString utf32String = NzString::Unicode(utf32);
|
||||
String utf32String = String::Unicode(utf32);
|
||||
|
||||
REQUIRE(utf8String == utf16String);
|
||||
REQUIRE(utf16String == utf32String);
|
||||
|
||||
@@ -5,67 +5,67 @@ SCENARIO("StringStream", "[CORE][STRINGSTREAM]")
|
||||
{
|
||||
GIVEN("A string stream")
|
||||
{
|
||||
NzStringStream stringstream("default");
|
||||
Nz::StringStream stringStream("default");
|
||||
|
||||
WHEN("We add bool and char")
|
||||
{
|
||||
stringstream << true;
|
||||
stringStream << true;
|
||||
|
||||
char valueCharSigned = 64;
|
||||
stringstream << valueCharSigned;
|
||||
stringStream << valueCharSigned;
|
||||
unsigned char valueCharUnsigned = 64;
|
||||
stringstream << valueCharUnsigned;
|
||||
stringStream << valueCharUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "defaulttrue@@");
|
||||
REQUIRE(stringStream.ToString() == "defaulttrue@@");
|
||||
}
|
||||
|
||||
AND_WHEN("We add short and int")
|
||||
{
|
||||
short valueShortSigned = -3;
|
||||
stringstream << valueShortSigned;
|
||||
stringStream << valueShortSigned;
|
||||
unsigned short valueShortUnsigned = 3;
|
||||
stringstream << valueShortUnsigned;
|
||||
stringStream << valueShortUnsigned;
|
||||
|
||||
int valueIntSigned = -3;
|
||||
stringstream << valueIntSigned;
|
||||
stringStream << valueIntSigned;
|
||||
unsigned int valueIntUnsigned = 3;
|
||||
stringstream << valueIntUnsigned;
|
||||
stringStream << valueIntUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default-33-33");
|
||||
REQUIRE(stringStream.ToString() == "default-33-33");
|
||||
}
|
||||
|
||||
AND_WHEN("We add long and long long")
|
||||
{
|
||||
long valueLongSigned = -3;
|
||||
stringstream << valueLongSigned;
|
||||
stringStream << valueLongSigned;
|
||||
unsigned long valueLongUnsigned = 3;
|
||||
stringstream << valueLongUnsigned;
|
||||
stringStream << valueLongUnsigned;
|
||||
|
||||
long long valueLongLongSigned = -3;
|
||||
stringstream << valueLongLongSigned;
|
||||
stringStream << valueLongLongSigned;
|
||||
unsigned long long valueLongLongUnsigned = 3;
|
||||
stringstream << valueLongLongUnsigned;
|
||||
stringStream << valueLongLongUnsigned;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default-33-33");
|
||||
REQUIRE(stringStream.ToString() == "default-33-33");
|
||||
}
|
||||
|
||||
AND_WHEN("We add floating points")
|
||||
{
|
||||
stringstream << 3.f;
|
||||
stringstream << 3.0;
|
||||
stringstream << 3.0L;
|
||||
stringStream << 3.f;
|
||||
stringStream << 3.0;
|
||||
stringStream << 3.0L;
|
||||
|
||||
REQUIRE(stringstream.ToString() == "default333");
|
||||
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);
|
||||
stringStream << "3";
|
||||
stringStream << std::string("3");
|
||||
stringStream << Nz::String("3");
|
||||
stringStream << static_cast<void*>(nullptr);
|
||||
|
||||
REQUIRE(stringstream.ToString() == (NzString("default333") + NzString::Pointer(nullptr)));
|
||||
REQUIRE(stringStream.ToString() == (Nz::String("default333") + Nz::String::Pointer(nullptr)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user