summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GenerateExportHeader
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/GenerateExportHeader')
-rw-r--r--Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
index dcaa4f2..ed8c35e 100644
--- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
@@ -8,6 +8,14 @@
#include "libshared.h"
#include "libstatic.h"
+static void rtrim(std::string& str, char byte)
+{
+ const std::size_t size = str.size();
+ if (size && str[size - 1] == byte) {
+ str.resize(size - 1);
+ }
+}
+
void compare(const char* refName, const char* testName)
{
std::ifstream ref;
@@ -31,16 +39,14 @@ void compare(const char* refName, const char* testName)
// Some very old Borland runtimes (C++ Builder 5 WITHOUT Update 1) add a
// trailing null to the string that we need to strip before testing for a
// trailing space.
- if (refLine.size() && refLine[refLine.size() - 1] == 0) {
- refLine.resize(refLine.size() - 1);
- }
- if (testLine.size() && testLine[testLine.size() - 1] == 0) {
- testLine.resize(testLine.size() - 1);
- }
+ rtrim(refLine, 0);
+ rtrim(testLine, 0);
// The reference files never have trailing spaces:
- if (testLine.size() && testLine[testLine.size() - 1] == ' ') {
- testLine.resize(testLine.size() - 1);
- }
+ rtrim(testLine, ' ');
+ // Strip trailing CR. LF is not returned by getline, but CR is returned
+ // on some platforms.
+ rtrim(refLine, '\r');
+ rtrim(testLine, '\r');
if (refLine != testLine) {
std::cout << "Ref and test are not the same:\n Ref: \"" << refLine
<< "\"\n Test: \"" << testLine << "\"\n";