1 // $Id: lasvariablerecord_test.cpp 712 2008-05-14 22:47:43Z hobu $ 2 // 3 // (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net 4 // Distributed under the BSD License 5 // (See accompanying file LICENSE.txt or copy at 6 // http://www.opensource.org/licenses/bsd-license.php) 7 // 8 #include <liblas12/lasvariablerecord.hpp> 9 #include <liblas12/cstdint.hpp> 10 #include <tut/tut.hpp> 11 #include <string> 12 13 namespace tut 14 { 15 struct lasvariablerecord_data 16 { 17 liblas::LASVariableRecord m_default; 18 test_defaulttut::lasvariablerecord_data19 void test_default(liblas::LASVariableRecord const& h) 20 { 21 ensure_equals("wrong default reserved bytes", 22 h.GetReserved(), liblas::uint16_t()); 23 24 ensure_equals("wrong default record identifier", 25 h.GetRecordId(), liblas::uint16_t()); 26 27 ensure_equals("wrong default record length", 28 h.GetRecordLength(), liblas::uint16_t()); 29 30 ensure_equals("wrong default user identifier", 31 h.GetUserId(true).c_str(), std::string()); 32 33 ensure_equals("wrong default description", 34 h.GetDescription(true).c_str(), std::string()); 35 } 36 }; 37 38 typedef test_group<lasvariablerecord_data> tg; 39 typedef tg::object to; 40 41 tg test_group_lasvariablerecord("liblas::LASVariableRecord"); 42 43 // Test default constructor 44 template<> 45 template<> test()46 void to::test<1>() 47 { 48 test_default(m_default); 49 } 50 51 // Test copy constructor 52 template<> 53 template<> test()54 void to::test<2>() 55 { 56 liblas::LASVariableRecord hdr_copy(m_default); 57 test_default(hdr_copy); 58 } 59 60 // Test assignment operator 61 template<> 62 template<> test()63 void to::test<3>() 64 { 65 liblas::LASVariableRecord hdr_copy; 66 test_default(hdr_copy); 67 68 hdr_copy = m_default; 69 test_default(hdr_copy); 70 } 71 72 // Test equal function 73 template<> 74 template<> test()75 void to::test<4>() 76 { 77 liblas::LASVariableRecord hdr; 78 ensure("two default headers not equal", m_default.equal(hdr)); 79 80 liblas::LASVariableRecord hdr_copy(m_default); 81 ensure("copy of default header not equal", hdr.equal(m_default)); 82 } 83 84 // Test equal-to operator 85 template<> 86 template<> test()87 void to::test<5>() 88 { 89 liblas::LASVariableRecord hdr; 90 ensure("two default headers not equal", m_default == hdr); 91 92 liblas::LASVariableRecord hdr_copy(m_default); 93 ensure("copy of default header not equal", hdr == m_default); 94 } 95 96 // Test not-equal-to operator 97 template<> 98 template<> test()99 void to::test<6>() 100 { 101 liblas::LASVariableRecord hdr; 102 ensure_not("two default headers not equal", m_default != hdr); 103 104 liblas::LASVariableRecord hdr_copy(m_default); 105 ensure_not("copy of default header not equal", hdr != m_default); 106 } 107 } 108 109