mirror of https://github.com/OpenRCT2/OpenRCT2.git
Allow tests to work with CRLF test data
This commit is contained in:
parent
1dc7bc2466
commit
5dbd3c7c0c
|
@ -10,9 +10,6 @@ echo -e "\033[0;36mBuilding OpenRCT2 repository indexes...\033[0m"
|
|||
./openrct2 scan-objects
|
||||
|
||||
if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
|
||||
# Ensure test data uses LF
|
||||
dos2unix testdata/keys/*
|
||||
|
||||
# Now run all the tests
|
||||
echo -e "\033[0;36mRunning OpenRCT2 tests...\033[0m"
|
||||
./tests --gtest_output=xml:../artifacts/test-results.xml
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include "TestData.h"
|
||||
#include "helpers/StringHelpers.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <openrct2/core/Crypt.h>
|
||||
|
@ -153,7 +154,7 @@ TEST_F(CryptTests, RSA_VerifyWithPublic)
|
|||
|
||||
TEST_F(CryptTests, RSAKey_GetPublic)
|
||||
{
|
||||
auto inPem = File::ReadAllText(GetTestPublicKeyPath());
|
||||
auto inPem = NormaliseLineEndings(File::ReadAllText(GetTestPublicKeyPath()));
|
||||
auto publicKey = Crypt::CreateRSAKey();
|
||||
publicKey->SetPublic(inPem);
|
||||
auto outPem = publicKey->GetPublic();
|
||||
|
|
|
@ -24,3 +24,35 @@ inline std::string StringFromHex(const std::string_view& input)
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string NormaliseLineEndings(const std::string_view& input)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(input.size());
|
||||
auto ignoreNextNewLine = false;
|
||||
for (auto c : input)
|
||||
{
|
||||
if (c == '\r')
|
||||
{
|
||||
ignoreNextNewLine = true;
|
||||
result.push_back('\n');
|
||||
}
|
||||
else if (c == '\n')
|
||||
{
|
||||
if (ignoreNextNewLine)
|
||||
{
|
||||
ignoreNextNewLine = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back('\n');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoreNextNewLine = false;
|
||||
result.push_back(c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue