Added tests file for Utils.hpp, fixed OctToInt and Split functions

This commit is contained in:
Vladyslav Baranovskyi
2024-10-03 20:10:15 +03:00
parent 8c2cf49054
commit a7673b6fb7
2 changed files with 218 additions and 6 deletions

View File

@@ -127,7 +127,7 @@ namespace OpenVulkano
static constexpr int64_t OctToInt(std::string_view string)
{
int64_t result = 0;
for(int i = static_cast<int>(string.length()) - 1; i >= 0; i--)
for(int i = 0; i < static_cast<int>(string.length()); i++)
{
char c = string[i];
if (c == 0) break;
@@ -168,18 +168,21 @@ namespace OpenVulkano
{
std::vector<std::string> subs;
size_t startPos = 0, pos;
while ((pos = str.find(separator, startPos)) != std::string::npos)
{
if (startPos == pos)
if (pos != startPos)
{
startPos++;
continue;
subs.emplace_back(str.substr(startPos, pos - startPos));
}
subs.emplace_back(str.substr(startPos, pos - startPos));
startPos = pos + 1;
}
if (startPos != str.length() - 1)
if (startPos < str.size())
{
subs.emplace_back(str.substr(startPos));
}
return subs;
}