[Liblas-commits] hg: Added a bunch of asserts to make it easier to debug laswrite...

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Oct 10 22:16:46 EDT 2009


changeset e638fd7bc2d8 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=e638fd7bc2d8
summary: Added a bunch of asserts to make it easier to debug laswrite problems with breaking file (lasreader reports EOF error)

diffstat:

 include/liblas/detail/utility.hpp |  7 +++++++
 src/detail/reader10.cpp           |  1 +
 src/lasreader.cpp                 |  1 -
 test/unit/laswriter_test.cpp      |  5 +++++
 4 files changed, 13 insertions(+), 1 deletions(-)

diffs (93 lines):

diff -r af24c7e8c91c -r e638fd7bc2d8 include/liblas/detail/utility.hpp
--- a/include/liblas/detail/utility.hpp	Sat Oct 10 02:30:57 2009 +0100
+++ b/include/liblas/detail/utility.hpp	Sun Oct 11 03:16:37 2009 +0100
@@ -371,6 +371,8 @@
 template <typename T>
 inline void read_n(T& dest, std::istream& src, std::streamsize const& num)
 {
+    assert(src);
+
     // TODO: Review and redesign errors handling logic if necessary
     if (!src)
         throw std::runtime_error("detail::liblas::read_n input stream is not readable");
@@ -386,6 +388,8 @@
 template <>
 inline void read_n<PointRecord>(PointRecord& dest, std::istream& src, std::streamsize const& num)
 {
+    assert(src);
+
     // TODO: Review and redesign errors handling logic if necessary
     if (!src)
         throw std::runtime_error("detail::liblas::read_n input stream is not readable");
@@ -408,6 +412,8 @@
 template <>
 inline void read_n<VLRHeader>(VLRHeader& dest, std::istream& src, std::streamsize const& num)
 {
+    assert(src);
+
     // TODO: Review and redesign errors handling logic if necessary
     if (!src)
         throw std::runtime_error("detail::liblas::read_n input stream is not readable");
@@ -424,6 +430,7 @@
 template <>
 inline void read_n<std::string>(std::string& dest, std::istream& src, std::streamsize const& num)
 {
+    assert(src);
     assert(dest.max_size() >= static_cast<std::string::size_type>(num));
 
     // TODO: Review and redesign errors handling logic if necessary
diff -r af24c7e8c91c -r e638fd7bc2d8 src/detail/reader10.cpp
--- a/src/detail/reader10.cpp	Sat Oct 10 02:30:57 2009 +0100
+++ b/src/detail/reader10.cpp	Sun Oct 11 03:16:37 2009 +0100
@@ -89,6 +89,7 @@
     read_n(fsig, m_ifs, 4);
     header.SetFileSignature(fsig);
 
+
     // 2. Reserved
     // This data must always contain Zeros.
     read_n(n4, m_ifs, sizeof(n4));
diff -r af24c7e8c91c -r e638fd7bc2d8 src/lasreader.cpp
--- a/src/lasreader.cpp	Sat Oct 10 02:30:57 2009 +0100
+++ b/src/lasreader.cpp	Sun Oct 11 03:16:37 2009 +0100
@@ -58,7 +58,6 @@
     m_pimpl(detail::ReaderFactory::Create(ifs)),
     bCustomHeader(false)
 {
-
     Init();
 }
 
diff -r af24c7e8c91c -r e638fd7bc2d8 test/unit/laswriter_test.cpp
--- a/test/unit/laswriter_test.cpp	Sat Oct 10 02:30:57 2009 +0100
+++ b/test/unit/laswriter_test.cpp	Sun Oct 11 03:16:37 2009 +0100
@@ -68,10 +68,13 @@
             test_default_header(hdr_default);
         }
 
+            exit(0);
         // Read previously created LAS file and check its header block
         {
             std::ifstream ifs;
             ifs.open(tmpfile_.c_str(), std::ios::in | std::ios::binary);
+            ensure(ifs.is_open());
+
             liblas::LASReader reader(ifs);
 
             ensure_equals<std::size_t>(reader.GetVersion(), liblas::eLASVersion12);
@@ -125,6 +128,7 @@
         {
             std::ifstream ifs;
             ifs.open(tmpfile_.c_str(), std::ios::in | std::ios::binary);
+            ensure(ifs.is_open());
             liblas::LASReader reader(ifs);
 
             liblas::LASPoint point; // reusable cache
@@ -215,6 +219,7 @@
         {
             std::ifstream ifs;
             ifs.open(tmpfile_.c_str(), std::ios::in | std::ios::binary);
+            ensure(ifs.is_open());
             liblas::LASReader reader(ifs);
 
             liblas::LASHeader const& header = reader.GetHeader();


More information about the Liblas-commits mailing list