summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/test/helpers.cpp15
-rw-r--r--slicer/test/helpers.h3
-rw-r--r--slicer/test/serializers.cpp7
3 files changed, 21 insertions, 4 deletions
diff --git a/slicer/test/helpers.cpp b/slicer/test/helpers.cpp
index 5527f5a..58f47bc 100644
--- a/slicer/test/helpers.cpp
+++ b/slicer/test/helpers.cpp
@@ -2,6 +2,8 @@
#include <stdexcept>
#include <stdlib.h>
#include <dlfcn.h>
+#include <fstream>
+#include <boost/test/test_tools.hpp>
void
system(const std::string & cmd)
@@ -12,6 +14,19 @@ system(const std::string & cmd)
}
}
+void
+diff(const boost::filesystem::path & left, const boost::filesystem::path & right)
+{
+ std::ifstream fl(left.string());
+ std::ifstream fr(right.string());
+
+ std::string l, r;
+ std::copy_if(std::istreambuf_iterator<char>(fl), std::istreambuf_iterator<char>(), back_inserter(l), [](char x){ return !isspace(x); });
+ std::copy_if(std::istreambuf_iterator<char>(fr), std::istreambuf_iterator<char>(), back_inserter(r), [](char x){ return !isspace(x); });
+
+ BOOST_REQUIRE_EQUAL(l, r);
+}
+
void *
loadlib(const boost::filesystem::path & so)
{
diff --git a/slicer/test/helpers.h b/slicer/test/helpers.h
index f8f7a7d..385ee64 100644
--- a/slicer/test/helpers.h
+++ b/slicer/test/helpers.h
@@ -14,5 +14,8 @@ loadlib(const boost::filesystem::path &);
void
closelib(void *);
+void
+diff(const boost::filesystem::path & left, const boost::filesystem::path & right);
+
#endif
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index df6c052..89e7d8d 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -12,7 +12,6 @@
#include <boost/format.hpp>
#include <boost/function.hpp>
#include <types.h>
-#include <misc.h>
#include <fstream>
#include "helpers.h"
#include "fileStructure.h"
@@ -54,7 +53,7 @@ class FileBased : public FileStructure {
}
BOOST_TEST_CHECKPOINT("Checksum: " << input << " === " << output);
- system(stringbf("diff -w %s %s", input, output));
+ diff(input, output);
}
template<typename T, typename Deserializer, typename Serializer, typename Internal>
@@ -96,7 +95,7 @@ class FileBased : public FileStructure {
ifree(docWrite);
BOOST_TEST_CHECKPOINT("Checksum: " << input << " === " << output);
- system(stringbf("diff -w %s %s", input, output));
+ diff(input, output);
}
};
@@ -435,7 +434,7 @@ BOOST_AUTO_TEST_CASE( any )
Slicer::Serialize<Slicer::XmlFileSerializer>(object, output);
BOOST_TEST_CHECKPOINT("Checksum: " << input << " === " << output);
- system(stringbf("diff -w %s %s", input, output));
+ diff(input, output);
}
BOOST_AUTO_TEST_SUITE_END();