[Liblas-commits] r1102 - trunk/test/unit

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Mar 16 10:57:13 EDT 2009


Author: hobu
Date: Mon Mar 16 10:57:12 2009
New Revision: 1102
URL: http://liblas.org/changeset/1102

Log:
making mloskot proud by adding to the tests

Added:
   trunk/test/unit/lassrs_test.cpp
      - copied, changed from r1101, /trunk/test/unit/lasheader_test.cpp
Modified:
   trunk/test/unit/Makefile.am
   trunk/test/unit/common.cpp
   trunk/test/unit/lasheader_test.cpp
   trunk/test/unit/laspoint_test.cpp

Modified: trunk/test/unit/Makefile.am
==============================================================================
--- trunk/test/unit/Makefile.am	(original)
+++ trunk/test/unit/Makefile.am	Mon Mar 16 10:57:12 2009
@@ -25,9 +25,11 @@
 	laserror_test.cpp \
 	lasfile_test.cpp \
 	lasheader_test.cpp \
+    lassrs_test.cpp \
 	laspoint_test.cpp \
 	lasreader_iterator_test.cpp \
 	lasreader_test.cpp \
 	lasrecordheader_test.cpp \
 	laswriter_test.cpp \
 	liblas_test_suite.cpp
+    
\ No newline at end of file

Modified: trunk/test/unit/common.cpp
==============================================================================
--- trunk/test/unit/common.cpp	(original)
+++ trunk/test/unit/common.cpp	Mon Mar 16 10:57:12 2009
@@ -110,6 +110,13 @@
     ensure_equals("wrong defualt time",
         p.GetTime(), double(0));
 
+    ensure_equals("invalid default red color",
+        p.GetColor().GetRed(), 0);
+    ensure_equals("invalid default green color",
+        p.GetColor().GetGreen(), 0);
+    ensure_equals("invalid default blue color",
+        p.GetColor().GetBlue(), 0);
+            
     ensure("invalid defualt point record", p.IsValid());
 }
 

Modified: trunk/test/unit/lasheader_test.cpp
==============================================================================
--- trunk/test/unit/lasheader_test.cpp	(original)
+++ trunk/test/unit/lasheader_test.cpp	Mon Mar 16 10:57:12 2009
@@ -6,6 +6,7 @@
 // http://www.opensource.org/licenses/bsd-license.php)
 //
 #include <liblas/lasheader.hpp>
+#include <liblas/lassrs.hpp>
 #include <liblas/cstdint.hpp>
 #include <liblas/guid.hpp>
 #include <tut/tut.hpp>
@@ -281,5 +282,17 @@
         }
     }
 
+    // Test GetSRS
+    template<>
+    template<>
+    void to::test<12>()
+    {
+        liblas::LASHeader h;
+        liblas::LASSRS srs = h.GetSRS();
+
+        ensure_equals(srs.GetProj4(), "");
+        ensure_equals(srs.GetWKT(), "");
+
+    }
 }
 

Modified: trunk/test/unit/laspoint_test.cpp
==============================================================================
--- trunk/test/unit/laspoint_test.cpp	(original)
+++ trunk/test/unit/laspoint_test.cpp	Mon Mar 16 10:57:12 2009
@@ -6,6 +6,7 @@
 // http://www.opensource.org/licenses/bsd-license.php)
 //
 #include <liblas/laspoint.hpp>
+#include <liblas/lascolor.hpp>
 #include <liblas/exception.hpp>
 #include <tut/tut.hpp>
 #include <bitset>
@@ -366,5 +367,48 @@
             ensure_not(p.IsValid());
         }
     }
+
+    // Test Get/SetColor
+    template<>
+    template<>
+    void to::test<16>()
+    {
+        ensure_equals("invalid default red color",
+            m_default.GetColor().GetRed(), 0);
+
+        ensure_equals("invalid default green color",
+            m_default.GetColor().GetGreen(), 0);
+
+        ensure_equals("invalid default blue color",
+            m_default.GetColor().GetBlue(), 0);
+                        
+        liblas::LASColor color;
+        color.SetRed(211);
+        color.SetGreen(211);
+        color.SetBlue(211);
+        
+        m_default.SetColor(color);
+
+        ensure_equals("invalid set red color",
+            m_default.GetColor().GetRed(), 211);
+
+        ensure_equals("invalid set green color",
+            m_default.GetColor().GetGreen(), 211);
+
+        ensure_equals("invalid set blue color",
+            m_default.GetColor().GetBlue(), 211);
+        
+        liblas::LASPoint p = m_default;
+
+        ensure_equals("invalid copied red color",
+            p.GetColor().GetRed(), 211);
+
+        ensure_equals("invalid copied green color",
+            p.GetColor().GetGreen(), 211);
+            
+        ensure_equals("invalid copied blue color",
+            p.GetColor().GetBlue(), 211);        
+        
+    }
 }
 

Copied: trunk/test/unit/lassrs_test.cpp (from r1101, /trunk/test/unit/lasheader_test.cpp)
==============================================================================
--- /trunk/test/unit/lasheader_test.cpp	(original)
+++ trunk/test/unit/lassrs_test.cpp	Mon Mar 16 10:57:12 2009
@@ -5,7 +5,7 @@
 // (See accompanying file LICENSE.txt or copy at
 // http://www.opensource.org/licenses/bsd-license.php)
 //
-#include <liblas/lasheader.hpp>
+#include <liblas/lassrs.hpp>
 #include <liblas/cstdint.hpp>
 #include <liblas/guid.hpp>
 #include <tut/tut.hpp>
@@ -15,271 +15,272 @@
 
 namespace tut
 { 
-    struct lasheader_data
+    struct lassrs_data
     {
-        liblas::LASHeader m_default;
+        liblas::LASSRS m_default;
     };
 
-    typedef test_group<lasheader_data> tg;
+    typedef test_group<lassrs_data> tg;
     typedef tg::object to;
 
-    tg test_group_lasheader("liblas::LASHeader");
+    tg test_group_lassrs("liblas::LASSRS");
 
     // Test default constructor
     template<>
     template<>
     void to::test<1>()
     {
-        test_default_header(m_default);
+        ensure_equals(m_default.GetProj4(), "");
+        ensure_equals(m_default.GetWKT(), "");
     }
 
-    // Test copy constructor
-    template<>
-    template<>
-    void to::test<2>()
-    {
-        using liblas::LASHeader;
-        
-        LASHeader copy_of_default(m_default);
-        test_default_header(copy_of_default);
-
-        std::string sig("LASF and garbage");
-
-        LASHeader h1;
-        
-        h1.SetFileSignature(sig);
-        ensure_not(h1.GetFileSignature() == sig);
-        ensure_equals(h1.GetFileSignature().size(), 4);
-        ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
-
-        LASHeader h2(h1);
-
-        ensure_not(h2.GetFileSignature() == sig);
-        ensure_equals(h2.GetFileSignature().size(), 4);
-        ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
-    }
-
-
-    // Test assignment operator
-    template<>
-    template<>
-    void to::test<3>()
-    {
-        using liblas::LASHeader;
-        
-        LASHeader copy_of_default;
-        copy_of_default = m_default;
-        test_default_header(copy_of_default);
-
-    }
-
-    // Test Get/SetFileSignature
-    template<>
-    template<>
-    void to::test<4>()
-    {
-        using liblas::LASHeader;
-
-        std::string sig("LASF and garbage");
-
-        LASHeader h1;
-        h1.SetFileSignature(sig);
-
-        ensure_not(h1.GetFileSignature() == sig);
-        ensure_equals(h1.GetFileSignature().size(), 4);
-        ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
-
-        LASHeader h2;
-        h2 = h1;
-
-        ensure_not(h2.GetFileSignature() == sig);
-        ensure_equals(h2.GetFileSignature().size(), 4);
-        ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
-    }
-
-    // Test Get/SetFileSourceId
-    template<>
-    template<>
-    void to::test<5>()
-    {
-        using liblas::LASHeader;
-        using liblas::uint16_t;
-
-        uint16_t const id1 = 1;
-        uint16_t const id2 = 65535;
-        uint16_t const overflowed = 0;
-
-        LASHeader h1;
-        h1.SetFileSourceId(id1);
-        ensure_equals(h1.GetFileSourceId(), id1);
-        h1.SetFileSourceId(id2);
-        ensure_equals(h1.GetFileSourceId(), id2);
-
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable: 4305) //  truncation from 'int' to 'liblas::uint16_t'
-# pragma warning(disable: 4309) // conditional expression is constant.
-#endif
-        // Unsigned overflow
-        // Likely compiler warning: truncation from int to liblas::uint16_t
-        h1.SetFileSourceId(id2 + 1);
-        ensure_equals(h1.GetFileSourceId(), overflowed);
-
-#ifdef _MSC_VER
-# pragma warning(push)
-#endif
-    }
-
-    // Test GetReserved
-    template<>
-    template<>
-    void to::test<6>()
-    {
-        liblas::LASHeader h;
-        ensure_equals(h.GetReserved(), 0);
-    }
-
-    // Test Set/GetProjectId
-    template<>
-    template<>
-    void to::test<7>()
-    {
-        std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6");
-        liblas::guid id(strid.c_str());
-
-        liblas::LASHeader h;
-        h.SetProjectId(id);
-        
-        ensure_not(h.GetProjectId().is_null());
-        ensure_equals(h.GetProjectId(), id);
-    }
-
-    // Test handling minor/major version
-    template<>
-    template<>
-    void to::test<8>()
-    {
-        liblas::LASHeader h;
-
-        h.SetVersionMajor(1);
-        h.SetVersionMinor(0);
-        ensure_equals(h.GetVersionMajor(), 1);
-        ensure_equals(h.GetVersionMinor(), 0);
-
-        h.SetVersionMajor(1);
-        h.SetVersionMinor(1);
-        ensure_equals(h.GetVersionMajor(), 1);
-        ensure_equals(h.GetVersionMinor(), 1);
-
-        try
-        {
-            h.SetVersionMajor(2);
-            ensure("std::out_of_range not thrown", false);
-        }
-        catch (std::out_of_range const& e)
-        {
-            ensure(e.what(), true);
-        }
-
-        try
-        {
-            h.SetVersionMinor(3);
-            ensure("std::out_of_range not thrown", false);
-        }
-        catch (std::out_of_range const& e)
-        {
-            ensure(e.what(), true);
-        }
-    }
-
-    // Test Get/SetSystemId
-    template<>
-    template<>
-    void to::test<9>()
-    {
-        using liblas::LASHeader;
-
-        std::string sysid1("Short Sys Id"); // 12 bytes
-        std::string::size_type const len1 = sysid1.size();
-        std::string sysid2("Long System Identifier - XXX YYY"); // 32 bytes
-        std::string::size_type const len2 = sysid2.size();
-
-        LASHeader h;
-
-        h.SetSystemId(sysid1);
-        ensure_equals(h.GetSystemId(), sysid1);
-        ensure_equals(h.GetSystemId().size(), len1);
-        ensure_equals(h.GetSystemId(true).size(), 32);
-
-        h.SetSystemId(sysid2);
-        ensure_equals(h.GetSystemId(), sysid2);
-        ensure_equals(h.GetSystemId().size(), len2);
-        ensure_equals(h.GetSystemId(true).size(), 32);
-    }
-
-    // Test Get/SetSoftwareId
-    template<>
-    template<>
-    void to::test<10>()
-    {
-        using liblas::LASHeader;
-
-        std::string softid1("Short Soft Id"); // 13 bytes
-        std::string::size_type const len1 = softid1.size();
-        std::string softid2("Long Software Identifier - XX YY"); // 32 bytes
-        std::string::size_type const len2 = softid2.size();
-
-        LASHeader h;
-        h.SetSoftwareId(softid1);
-        ensure_equals(h.GetSoftwareId(), softid1);
-        ensure_equals(h.GetSoftwareId().size(), len1);
-        ensure_equals(h.GetSoftwareId(true).size(), 32);
-
-        h.SetSoftwareId(softid2);
-        ensure_equals(h.GetSoftwareId(), softid2);
-        ensure_equals(h.GetSoftwareId().size(), len2);
-        ensure_equals(h.GetSoftwareId(true).size(), 32);
-    }
-
-    // Test GetPointRecordsByReturnCount
-    template<>
-    template<>
-    void to::test<11>()
-    {
-        liblas::LASHeader h;
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-
-        h.SetPointRecordsByReturnCount(0, 100);
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-        ensure_equals(h.GetPointRecordsByReturnCount().at(0), 100);
-
-        h.SetPointRecordsByReturnCount(1, 101);
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-        ensure_equals(h.GetPointRecordsByReturnCount().at(1), 101);
-
-        h.SetPointRecordsByReturnCount(2, 102);
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-        ensure_equals(h.GetPointRecordsByReturnCount().at(2), 102);
-
-        h.SetPointRecordsByReturnCount(3, 103);
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-        ensure_equals(h.GetPointRecordsByReturnCount().at(3), 103);
-
-        h.SetPointRecordsByReturnCount(4, 104);
-        ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
-        ensure_equals(h.GetPointRecordsByReturnCount().at(4), 104);
-
-        try
-        {
-            // 5 is out of range
-            h.SetPointRecordsByReturnCount(5, 500);
-            ensure("std::out_of_range not thrown", false);
-        }
-        catch (std::out_of_range const& e)
-        {
-            ensure(e.what(), true);
-        }
-    }
+//     // Test copy constructor
+//     template<>
+//     template<>
+//     void to::test<2>()
+//     {
+//         using liblas::LASSRS;
+//         
+//         LASSRS copy_of_default(m_default);
+//         test_default_header(copy_of_default);
+// 
+//         std::string sig("LASF and garbage");
+// 
+//         LASHeader h1;
+//         
+//         h1.SetFileSignature(sig);
+//         ensure_not(h1.GetFileSignature() == sig);
+//         ensure_equals(h1.GetFileSignature().size(), 4);
+//         ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
+// 
+//         LASHeader h2(h1);
+// 
+//         ensure_not(h2.GetFileSignature() == sig);
+//         ensure_equals(h2.GetFileSignature().size(), 4);
+//         ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
+//     }
+// 
+// 
+//     // Test assignment operator
+//     template<>
+//     template<>
+//     void to::test<3>()
+//     {
+//         using liblas::LASHeader;
+//         
+//         LASHeader copy_of_default;
+//         copy_of_default = m_default;
+//         test_default_header(copy_of_default);
+// 
+//     }
+// 
+//     // Test Get/SetFileSignature
+//     template<>
+//     template<>
+//     void to::test<4>()
+//     {
+//         using liblas::LASHeader;
+// 
+//         std::string sig("LASF and garbage");
+// 
+//         LASHeader h1;
+//         h1.SetFileSignature(sig);
+// 
+//         ensure_not(h1.GetFileSignature() == sig);
+//         ensure_equals(h1.GetFileSignature().size(), 4);
+//         ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
+// 
+//         LASHeader h2;
+//         h2 = h1;
+// 
+//         ensure_not(h2.GetFileSignature() == sig);
+//         ensure_equals(h2.GetFileSignature().size(), 4);
+//         ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
+//     }
+// 
+//     // Test Get/SetFileSourceId
+//     template<>
+//     template<>
+//     void to::test<5>()
+//     {
+//         using liblas::LASHeader;
+//         using liblas::uint16_t;
+// 
+//         uint16_t const id1 = 1;
+//         uint16_t const id2 = 65535;
+//         uint16_t const overflowed = 0;
+// 
+//         LASHeader h1;
+//         h1.SetFileSourceId(id1);
+//         ensure_equals(h1.GetFileSourceId(), id1);
+//         h1.SetFileSourceId(id2);
+//         ensure_equals(h1.GetFileSourceId(), id2);
+// 
+// #ifdef _MSC_VER
+// # pragma warning(push)
+// # pragma warning(disable: 4305) //  truncation from 'int' to 'liblas::uint16_t'
+// # pragma warning(disable: 4309) // conditional expression is constant.
+// #endif
+//         // Unsigned overflow
+//         // Likely compiler warning: truncation from int to liblas::uint16_t
+//         h1.SetFileSourceId(id2 + 1);
+//         ensure_equals(h1.GetFileSourceId(), overflowed);
+// 
+// #ifdef _MSC_VER
+// # pragma warning(push)
+// #endif
+//     }
+// 
+//     // Test GetReserved
+//     template<>
+//     template<>
+//     void to::test<6>()
+//     {
+//         liblas::LASHeader h;
+//         ensure_equals(h.GetReserved(), 0);
+//     }
+// 
+//     // Test Set/GetProjectId
+//     template<>
+//     template<>
+//     void to::test<7>()
+//     {
+//         std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6");
+//         liblas::guid id(strid.c_str());
+// 
+//         liblas::LASHeader h;
+//         h.SetProjectId(id);
+//         
+//         ensure_not(h.GetProjectId().is_null());
+//         ensure_equals(h.GetProjectId(), id);
+//     }
+// 
+//     // Test handling minor/major version
+//     template<>
+//     template<>
+//     void to::test<8>()
+//     {
+//         liblas::LASHeader h;
+// 
+//         h.SetVersionMajor(1);
+//         h.SetVersionMinor(0);
+//         ensure_equals(h.GetVersionMajor(), 1);
+//         ensure_equals(h.GetVersionMinor(), 0);
+// 
+//         h.SetVersionMajor(1);
+//         h.SetVersionMinor(1);
+//         ensure_equals(h.GetVersionMajor(), 1);
+//         ensure_equals(h.GetVersionMinor(), 1);
+// 
+//         try
+//         {
+//             h.SetVersionMajor(2);
+//             ensure("std::out_of_range not thrown", false);
+//         }
+//         catch (std::out_of_range const& e)
+//         {
+//             ensure(e.what(), true);
+//         }
+// 
+//         try
+//         {
+//             h.SetVersionMinor(3);
+//             ensure("std::out_of_range not thrown", false);
+//         }
+//         catch (std::out_of_range const& e)
+//         {
+//             ensure(e.what(), true);
+//         }
+//     }
+// 
+//     // Test Get/SetSystemId
+//     template<>
+//     template<>
+//     void to::test<9>()
+//     {
+//         using liblas::LASHeader;
+// 
+//         std::string sysid1("Short Sys Id"); // 12 bytes
+//         std::string::size_type const len1 = sysid1.size();
+//         std::string sysid2("Long System Identifier - XXX YYY"); // 32 bytes
+//         std::string::size_type const len2 = sysid2.size();
+// 
+//         LASHeader h;
+// 
+//         h.SetSystemId(sysid1);
+//         ensure_equals(h.GetSystemId(), sysid1);
+//         ensure_equals(h.GetSystemId().size(), len1);
+//         ensure_equals(h.GetSystemId(true).size(), 32);
+// 
+//         h.SetSystemId(sysid2);
+//         ensure_equals(h.GetSystemId(), sysid2);
+//         ensure_equals(h.GetSystemId().size(), len2);
+//         ensure_equals(h.GetSystemId(true).size(), 32);
+//     }
+// 
+//     // Test Get/SetSoftwareId
+//     template<>
+//     template<>
+//     void to::test<10>()
+//     {
+//         using liblas::LASHeader;
+// 
+//         std::string softid1("Short Soft Id"); // 13 bytes
+//         std::string::size_type const len1 = softid1.size();
+//         std::string softid2("Long Software Identifier - XX YY"); // 32 bytes
+//         std::string::size_type const len2 = softid2.size();
+// 
+//         LASHeader h;
+//         h.SetSoftwareId(softid1);
+//         ensure_equals(h.GetSoftwareId(), softid1);
+//         ensure_equals(h.GetSoftwareId().size(), len1);
+//         ensure_equals(h.GetSoftwareId(true).size(), 32);
+// 
+//         h.SetSoftwareId(softid2);
+//         ensure_equals(h.GetSoftwareId(), softid2);
+//         ensure_equals(h.GetSoftwareId().size(), len2);
+//         ensure_equals(h.GetSoftwareId(true).size(), 32);
+//     }
+// 
+//     // Test GetPointRecordsByReturnCount
+//     template<>
+//     template<>
+//     void to::test<11>()
+//     {
+//         liblas::LASHeader h;
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+// 
+//         h.SetPointRecordsByReturnCount(0, 100);
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+//         ensure_equals(h.GetPointRecordsByReturnCount().at(0), 100);
+// 
+//         h.SetPointRecordsByReturnCount(1, 101);
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+//         ensure_equals(h.GetPointRecordsByReturnCount().at(1), 101);
+// 
+//         h.SetPointRecordsByReturnCount(2, 102);
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+//         ensure_equals(h.GetPointRecordsByReturnCount().at(2), 102);
+// 
+//         h.SetPointRecordsByReturnCount(3, 103);
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+//         ensure_equals(h.GetPointRecordsByReturnCount().at(3), 103);
+// 
+//         h.SetPointRecordsByReturnCount(4, 104);
+//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+//         ensure_equals(h.GetPointRecordsByReturnCount().at(4), 104);
+// 
+//         try
+//         {
+//             // 5 is out of range
+//             h.SetPointRecordsByReturnCount(5, 500);
+//             ensure("std::out_of_range not thrown", false);
+//         }
+//         catch (std::out_of_range const& e)
+//         {
+//             ensure(e.what(), true);
+//         }
+//     }
 
 }
 


More information about the Liblas-commits mailing list