~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to test/unit/lasspatialreference_test.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: lasspatialreference_test.cpp 1102 2009-03-16 14:57:12Z 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 <liblas/lasspatialreference.hpp>
9
 
#include <liblas/cstdint.hpp>
10
 
#include <liblas/guid.hpp>
11
 
#include <tut/tut.hpp>
12
 
#include <string>
13
 
#include <stdexcept>
14
 
#include "common.hpp"
15
 
 
16
 
namespace tut
17
 
18
 
    struct lasspatialreference_data
19
 
    {
20
 
        liblas::LASSpatialReference m_default;
21
 
    };
22
 
 
23
 
    typedef test_group<lasspatialreference_data> tg;
24
 
    typedef tg::object to;
25
 
 
26
 
    tg test_group_lasspatialreference("liblas::LASSpatialReference");
27
 
 
28
 
    // Test default constructor
29
 
    template<>
30
 
    template<>
31
 
    void to::test<1>()
32
 
    {
33
 
        ensure_equals(m_default.GetProj4(), "");
34
 
        ensure_equals(m_default.GetWKT(), "");
35
 
    }
36
 
 
37
 
//     // Test copy constructor
38
 
//     template<>
39
 
//     template<>
40
 
//     void to::test<2>()
41
 
//     {
42
 
//         using liblas::LASSpatialReference;
43
 
//         
44
 
//         LASSpatialReference copy_of_default(m_default);
45
 
//         test_default_header(copy_of_default);
46
 
// 
47
 
//         std::string sig("LASF and garbage");
48
 
// 
49
 
//         LASHeader h1;
50
 
//         
51
 
//         h1.SetFileSignature(sig);
52
 
//         ensure_not(h1.GetFileSignature() == sig);
53
 
//         ensure_equals(h1.GetFileSignature().size(), 4);
54
 
//         ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
55
 
// 
56
 
//         LASHeader h2(h1);
57
 
// 
58
 
//         ensure_not(h2.GetFileSignature() == sig);
59
 
//         ensure_equals(h2.GetFileSignature().size(), 4);
60
 
//         ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
61
 
//     }
62
 
// 
63
 
// 
64
 
//     // Test assignment operator
65
 
//     template<>
66
 
//     template<>
67
 
//     void to::test<3>()
68
 
//     {
69
 
//         using liblas::LASHeader;
70
 
//         
71
 
//         LASHeader copy_of_default;
72
 
//         copy_of_default = m_default;
73
 
//         test_default_header(copy_of_default);
74
 
// 
75
 
//     }
76
 
// 
77
 
//     // Test Get/SetFileSignature
78
 
//     template<>
79
 
//     template<>
80
 
//     void to::test<4>()
81
 
//     {
82
 
//         using liblas::LASHeader;
83
 
// 
84
 
//         std::string sig("LASF and garbage");
85
 
// 
86
 
//         LASHeader h1;
87
 
//         h1.SetFileSignature(sig);
88
 
// 
89
 
//         ensure_not(h1.GetFileSignature() == sig);
90
 
//         ensure_equals(h1.GetFileSignature().size(), 4);
91
 
//         ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
92
 
// 
93
 
//         LASHeader h2;
94
 
//         h2 = h1;
95
 
// 
96
 
//         ensure_not(h2.GetFileSignature() == sig);
97
 
//         ensure_equals(h2.GetFileSignature().size(), 4);
98
 
//         ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
99
 
//     }
100
 
// 
101
 
//     // Test Get/SetFileSourceId
102
 
//     template<>
103
 
//     template<>
104
 
//     void to::test<5>()
105
 
//     {
106
 
//         using liblas::LASHeader;
107
 
//         using liblas::uint16_t;
108
 
// 
109
 
//         uint16_t const id1 = 1;
110
 
//         uint16_t const id2 = 65535;
111
 
//         uint16_t const overflowed = 0;
112
 
// 
113
 
//         LASHeader h1;
114
 
//         h1.SetFileSourceId(id1);
115
 
//         ensure_equals(h1.GetFileSourceId(), id1);
116
 
//         h1.SetFileSourceId(id2);
117
 
//         ensure_equals(h1.GetFileSourceId(), id2);
118
 
// 
119
 
// #ifdef _MSC_VER
120
 
// # pragma warning(push)
121
 
// # pragma warning(disable: 4305) //  truncation from 'int' to 'liblas::uint16_t'
122
 
// # pragma warning(disable: 4309) // conditional expression is constant.
123
 
// #endif
124
 
//         // Unsigned overflow
125
 
//         // Likely compiler warning: truncation from int to liblas::uint16_t
126
 
//         h1.SetFileSourceId(id2 + 1);
127
 
//         ensure_equals(h1.GetFileSourceId(), overflowed);
128
 
// 
129
 
// #ifdef _MSC_VER
130
 
// # pragma warning(push)
131
 
// #endif
132
 
//     }
133
 
// 
134
 
//     // Test GetReserved
135
 
//     template<>
136
 
//     template<>
137
 
//     void to::test<6>()
138
 
//     {
139
 
//         liblas::LASHeader h;
140
 
//         ensure_equals(h.GetReserved(), 0);
141
 
//     }
142
 
// 
143
 
//     // Test Set/GetProjectId
144
 
//     template<>
145
 
//     template<>
146
 
//     void to::test<7>()
147
 
//     {
148
 
//         std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6");
149
 
//         liblas::guid id(strid.c_str());
150
 
// 
151
 
//         liblas::LASHeader h;
152
 
//         h.SetProjectId(id);
153
 
//         
154
 
//         ensure_not(h.GetProjectId().is_null());
155
 
//         ensure_equals(h.GetProjectId(), id);
156
 
//     }
157
 
// 
158
 
//     // Test handling minor/major version
159
 
//     template<>
160
 
//     template<>
161
 
//     void to::test<8>()
162
 
//     {
163
 
//         liblas::LASHeader h;
164
 
// 
165
 
//         h.SetVersionMajor(1);
166
 
//         h.SetVersionMinor(0);
167
 
//         ensure_equals(h.GetVersionMajor(), 1);
168
 
//         ensure_equals(h.GetVersionMinor(), 0);
169
 
// 
170
 
//         h.SetVersionMajor(1);
171
 
//         h.SetVersionMinor(1);
172
 
//         ensure_equals(h.GetVersionMajor(), 1);
173
 
//         ensure_equals(h.GetVersionMinor(), 1);
174
 
// 
175
 
//         try
176
 
//         {
177
 
//             h.SetVersionMajor(2);
178
 
//             ensure("std::out_of_range not thrown", false);
179
 
//         }
180
 
//         catch (std::out_of_range const& e)
181
 
//         {
182
 
//             ensure(e.what(), true);
183
 
//         }
184
 
// 
185
 
//         try
186
 
//         {
187
 
//             h.SetVersionMinor(3);
188
 
//             ensure("std::out_of_range not thrown", false);
189
 
//         }
190
 
//         catch (std::out_of_range const& e)
191
 
//         {
192
 
//             ensure(e.what(), true);
193
 
//         }
194
 
//     }
195
 
// 
196
 
//     // Test Get/SetSystemId
197
 
//     template<>
198
 
//     template<>
199
 
//     void to::test<9>()
200
 
//     {
201
 
//         using liblas::LASHeader;
202
 
// 
203
 
//         std::string sysid1("Short Sys Id"); // 12 bytes
204
 
//         std::string::size_type const len1 = sysid1.size();
205
 
//         std::string sysid2("Long System Identifier - XXX YYY"); // 32 bytes
206
 
//         std::string::size_type const len2 = sysid2.size();
207
 
// 
208
 
//         LASHeader h;
209
 
// 
210
 
//         h.SetSystemId(sysid1);
211
 
//         ensure_equals(h.GetSystemId(), sysid1);
212
 
//         ensure_equals(h.GetSystemId().size(), len1);
213
 
//         ensure_equals(h.GetSystemId(true).size(), 32);
214
 
// 
215
 
//         h.SetSystemId(sysid2);
216
 
//         ensure_equals(h.GetSystemId(), sysid2);
217
 
//         ensure_equals(h.GetSystemId().size(), len2);
218
 
//         ensure_equals(h.GetSystemId(true).size(), 32);
219
 
//     }
220
 
// 
221
 
//     // Test Get/SetSoftwareId
222
 
//     template<>
223
 
//     template<>
224
 
//     void to::test<10>()
225
 
//     {
226
 
//         using liblas::LASHeader;
227
 
// 
228
 
//         std::string softid1("Short Soft Id"); // 13 bytes
229
 
//         std::string::size_type const len1 = softid1.size();
230
 
//         std::string softid2("Long Software Identifier - XX YY"); // 32 bytes
231
 
//         std::string::size_type const len2 = softid2.size();
232
 
// 
233
 
//         LASHeader h;
234
 
//         h.SetSoftwareId(softid1);
235
 
//         ensure_equals(h.GetSoftwareId(), softid1);
236
 
//         ensure_equals(h.GetSoftwareId().size(), len1);
237
 
//         ensure_equals(h.GetSoftwareId(true).size(), 32);
238
 
// 
239
 
//         h.SetSoftwareId(softid2);
240
 
//         ensure_equals(h.GetSoftwareId(), softid2);
241
 
//         ensure_equals(h.GetSoftwareId().size(), len2);
242
 
//         ensure_equals(h.GetSoftwareId(true).size(), 32);
243
 
//     }
244
 
// 
245
 
//     // Test GetPointRecordsByReturnCount
246
 
//     template<>
247
 
//     template<>
248
 
//     void to::test<11>()
249
 
//     {
250
 
//         liblas::LASHeader h;
251
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
252
 
// 
253
 
//         h.SetPointRecordsByReturnCount(0, 100);
254
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
255
 
//         ensure_equals(h.GetPointRecordsByReturnCount().at(0), 100);
256
 
// 
257
 
//         h.SetPointRecordsByReturnCount(1, 101);
258
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
259
 
//         ensure_equals(h.GetPointRecordsByReturnCount().at(1), 101);
260
 
// 
261
 
//         h.SetPointRecordsByReturnCount(2, 102);
262
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
263
 
//         ensure_equals(h.GetPointRecordsByReturnCount().at(2), 102);
264
 
// 
265
 
//         h.SetPointRecordsByReturnCount(3, 103);
266
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
267
 
//         ensure_equals(h.GetPointRecordsByReturnCount().at(3), 103);
268
 
// 
269
 
//         h.SetPointRecordsByReturnCount(4, 104);
270
 
//         ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
271
 
//         ensure_equals(h.GetPointRecordsByReturnCount().at(4), 104);
272
 
// 
273
 
//         try
274
 
//         {
275
 
//             // 5 is out of range
276
 
//             h.SetPointRecordsByReturnCount(5, 500);
277
 
//             ensure("std::out_of_range not thrown", false);
278
 
//         }
279
 
//         catch (std::out_of_range const& e)
280
 
//         {
281
 
//             ensure(e.what(), true);
282
 
//         }
283
 
//     }
284
 
 
285
 
}
286