[Liblas-commits] hg-main-tree: turn on pipeline writer testing

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jul 27 05:45:52 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/0dab4c7fe9f6
changeset: 951:0dab4c7fe9f6
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Jul 27 02:45:47 2011 -0700
description:
turn on pipeline writer testing

diffstat:

 test/data/pipeline_write_out.xml  |   2 --
 test/unit/PipelineManagerTest.cpp |   6 +++---
 test/unit/Support.cpp             |  34 ++++++++++++++++++++++++++++++++++
 test/unit/Support.hpp             |   1 +
 4 files changed, 38 insertions(+), 5 deletions(-)

diffs (86 lines):

diff -r f7e648dae130 -r 0dab4c7fe9f6 test/data/pipeline_write_out.xml
--- a/test/data/pipeline_write_out.xml	Tue Jul 26 20:00:27 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Pipeline><Writer><Type>drivers.las.writer</Type><Option><Name>filename</Name><Value>out.las</Value><Description>junk junk junk</Description></Option><Filter><Type>filters.crop</Type><Option><Name>bounds</Name><Value>([0,1000000],[0,1000000],[0,1000000])</Value></Option><Reader><Type>drivers.las.reader</Type><Option><Name>filename</Name><Value>../../test/data/1.2-with-color.las</Value></Option></Reader></Filter></Writer></Pipeline>
\ No newline at end of file
diff -r f7e648dae130 -r 0dab4c7fe9f6 test/unit/PipelineManagerTest.cpp
--- a/test/unit/PipelineManagerTest.cpp	Tue Jul 26 20:00:27 2011 -0700
+++ b/test/unit/PipelineManagerTest.cpp	Wed Jul 27 02:45:47 2011 -0700
@@ -115,10 +115,10 @@
 
     mgr.writeWriterPipeline("test.xml");
 
-    bool filesSame = Support::compare_files("test.xml", Support::datapath("pipeline_write_out.xml"));
-    //BOOST_CHECK(filesSame);
+    bool filesSame = Support::compare_text_files("test.xml", Support::datapath("pipeline_write.xml"));
+    BOOST_CHECK(filesSame);
 
-    //if (filesSame)
+    if (filesSame)
     {
         Utils::deleteFile("test.xml");
     }
diff -r f7e648dae130 -r 0dab4c7fe9f6 test/unit/Support.cpp
--- a/test/unit/Support.cpp	Tue Jul 26 20:00:27 2011 -0700
+++ b/test/unit/Support.cpp	Wed Jul 27 02:45:47 2011 -0700
@@ -35,6 +35,7 @@
 #include "Support.hpp"
 
 #include <iostream>
+#include <string>
 
 #include <boost/test/unit_test.hpp>
 
@@ -53,6 +54,39 @@
 }
 
 
+// same as compare_files, but for text files: ignores CRLF differences
+bool Support::compare_text_files(const std::string& file1, const std::string& file2)
+{
+    if (!pdal::Utils::fileExists(file1) ||
+        !pdal::Utils::fileExists(file2))
+        return false;
+
+    std::istream* str1 = pdal::Utils::openFile(file1, false);
+    std::istream* str2 = pdal::Utils::openFile(file2, false);
+    BOOST_CHECK(str1);
+    BOOST_CHECK(str2);
+
+    bool same = true;
+    while (!str1->eof())
+    {
+        std::string buf1;
+        std::string buf2;
+        std::getline(*str1, buf1);
+        std::getline(*str2, buf2);
+
+        same = (str1->eof() == str2->eof());
+        if (!same) break;
+
+        same = (buf1 == buf2);
+        if (!same) break;
+    }
+
+    pdal::Utils::closeFile(str1);
+    pdal::Utils::closeFile(str2);
+
+    return same;
+}
+
 bool Support::compare_files(const std::string& file1, const std::string& file2)
 {
     if (!pdal::Utils::fileExists(file1) ||
diff -r f7e648dae130 -r 0dab4c7fe9f6 test/unit/Support.hpp
--- a/test/unit/Support.hpp	Tue Jul 26 20:00:27 2011 -0700
+++ b/test/unit/Support.hpp	Wed Jul 27 02:45:47 2011 -0700
@@ -55,6 +55,7 @@
 
     // verify if two files are the same
     static bool compare_files(const std::string& file1, const std::string& file2);
+    static bool compare_text_files(const std::string& file1, const std::string& file2);
 
     // validate a point's XYZ values
     static void check_pN(const pdal::PointBuffer& data, const pdal::Schema& schema, 


More information about the Liblas-commits mailing list