UTIL: fixed windows newline handling for test

Martin Gerhardy 2020-01-07 21:18:32 +01:00
parent b428333c8c
commit b75c029c0b
1 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,13 @@
#include "core/tests/AbstractTest.h"
#include "util/IncludeUtil.h"
#include <SDL_platform.h>
#ifdef __WINDOWS__
#define NEWLINE "\r\n"
#else
#define NEWLINE "\n"
#endif
class IncludeUtilTest : public core::AbstractTest {
};
@ -12,13 +19,13 @@ TEST_F(IncludeUtilTest, testInclude) {
std::vector<std::string> includedFiles;
std::vector<std::string> includeDirs { "." };
const std::string src = io::filesystem()->load("main.h");
EXPECT_EQ(34u, src.size());
EXPECT_FALSE(src.empty());
std::pair<std::string, bool> retIncludes = util::handleIncludes(src, includeDirs, &includedFiles);
EXPECT_TRUE(retIncludes.second);
EXPECT_EQ(2u, includedFiles.size());
EXPECT_EQ("#error \"one\"\n#include \"two.h\"\n\n#error \"two\"\n\n", retIncludes.first);
EXPECT_EQ("#error \"one\"" NEWLINE "#include \"two.h\"" NEWLINE NEWLINE "#error \"two\"" NEWLINE NEWLINE, retIncludes.first);
retIncludes = util::handleIncludes(retIncludes.first, includeDirs, &includedFiles);
EXPECT_TRUE(retIncludes.second);
EXPECT_EQ(3u, includedFiles.size());
EXPECT_EQ("#error \"one\"\n#error \"two\"\n\n\n#error \"two\"\n\n", retIncludes.first);
EXPECT_EQ("#error \"one\"" NEWLINE "#error \"two\"" NEWLINE NEWLINE NEWLINE "#error \"two\"" NEWLINE NEWLINE, retIncludes.first);
}