[Liblas-commits] hg: Fixed incorrect test case of reader_iterator.

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jul 29 11:47:18 EDT 2010


changeset a227d7b038ef in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=a227d7b038ef
summary: Fixed incorrect test case of reader_iterator.

diffstat:

 test/unit/common.hpp                  |  37 +++++++++++++++++-----------------
 test/unit/lasreader_iterator_test.cpp |  25 ++--------------------
 2 files changed, 21 insertions(+), 41 deletions(-)

diffs (104 lines):

diff -r 9dcdde9c7334 -r a227d7b038ef test/unit/common.hpp
--- a/test/unit/common.hpp	Thu Jul 29 16:45:57 2010 +0100
+++ b/test/unit/common.hpp	Thu Jul 29 16:50:55 2010 +0100
@@ -9,6 +9,7 @@
 #include <liblas/laspoint.hpp>
 #include <liblas/lasheader.hpp>
 
+#include <iostream>
 
 namespace tut
 {
@@ -37,38 +38,36 @@
 // Functor to calculate bounding box of a set of points
 struct bbox_calculator
 {
-    typedef liblas::Bounds result_type;
-
-    bbox_calculator() : empty(true) {}
-
-    result_type get_result() const { return bbox; }    
+    bbox_calculator(liblas::Bounds& bbox) : bbox(&bbox), empty(true) {}
 
     void operator()(liblas::Point const& p)
     {
+        assert(0 != bbox);
+
         // Box initialization during first iteration only
         if (empty)
         {
-            bbox.min(0, p.GetX());
-            bbox.max(0, p.GetX());
-            bbox.min(1, p.GetY());
-            bbox.max(1, p.GetY());
-            bbox.min(2, p.GetZ());
-            bbox.max(2, p.GetZ());
+            bbox->min(0, p.GetX());
+            bbox->max(0, p.GetX());
+            bbox->min(1, p.GetY());
+            bbox->max(1, p.GetY());
+            bbox->min(2, p.GetZ());
+            bbox->max(2, p.GetZ());
             empty = false;
         }
 
         // Expand bounding box to include given point
-        bbox.min(0, std::min(bbox.min(0), p.GetX()));
-        bbox.min(1, std::min(bbox.min(1), p.GetY()));
-        bbox.min(2, std::min(bbox.min(2), p.GetZ()));
-        bbox.max(0, std::max(bbox.max(0), p.GetX()));
-        bbox.max(1, std::max(bbox.max(1), p.GetY()));
-        bbox.max(2, std::max(bbox.max(2), p.GetZ()));
+        bbox->min(0, std::min(bbox->min(0), p.GetX()));
+        bbox->min(1, std::min(bbox->min(1), p.GetY()));
+        bbox->min(2, std::min(bbox->min(2), p.GetZ()));
+        bbox->max(0, std::max(bbox->max(0), p.GetX()));
+        bbox->max(1, std::max(bbox->max(1), p.GetY()));
+        bbox->max(2, std::max(bbox->max(2), p.GetZ()));
     }
 
-
+private:
+    liblas::Bounds* bbox;
     bool empty;
-    liblas::Bounds bbox;
 };
 
 // Common test procedure for default constructed point data.
diff -r 9dcdde9c7334 -r a227d7b038ef test/unit/lasreader_iterator_test.cpp
--- a/test/unit/lasreader_iterator_test.cpp	Thu Jul 29 16:45:57 2010 +0100
+++ b/test/unit/lasreader_iterator_test.cpp	Thu Jul 29 16:50:55 2010 +0100
@@ -383,30 +383,11 @@
 
         Header const& h = reader_.GetHeader();
         bbox_t lasbbox = h.GetExtent();
-
-        // I don't know why this is failing -- hobu
-
-       // std::cout << std::endl;
-       //  std::cout << "minx: " << h.GetMinX()
-       //            << " miny: " << h.GetMinY()
-       //            << " minz: " << h.GetMinZ()
-       //            << " maxx: " << h.GetMaxX()
-       //            << " maxy: " << h.GetMaxY()
-       //            << " maxz: " << h.GetMaxZ();
                   
         // Accumulate points extents to common bounding box
-        bbox_calculator calculator;
-        std::for_each(it, end, calculator);
+        bbox_t accumulated;
+        std::for_each(it, end, bbox_calculator(accumulated));
         
-        // std::cout << std::endl;
-        // bbox_t b = calculator.get_result();
-        // std::cout << "minx: " << b.min.x
-        //           << " miny: " << b.min.y
-        //           << " minz: " << b.min.z
-        //           << " maxx: " << b.max.x
-        //           << " maxy: " << b.max.y
-        //           << " maxz: " << b.max.z;
-
-        ensure(lasbbox == calculator.get_result());
+        ensure(lasbbox == accumulated);
     }
 }


More information about the Liblas-commits mailing list