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)
8
#include <liblas/classification.hpp>
18
struct lasclassification_data
20
typedef liblas::Classification::bitset_type bitset_type;
21
liblas::Classification m_default;
24
typedef test_group<lasclassification_data> tg;
25
typedef tg::object to;
27
tg test_group_lasclassification("liblas::Classification");
33
ensure_equals(m_default, bitset_type(0));
34
ensure_equals(m_default.GetClass(), 0);
35
ensure_not(m_default.IsSynthetic());
36
ensure_not(m_default.IsKeyPoint());
37
ensure_not(m_default.IsWithheld());
44
liblas::Classification c0(0);
46
ensure_equals(c0, m_default);
47
ensure_equals(c0, bitset_type(0));
48
ensure_equals(c0.GetClass(), 0);
49
ensure_not(c0.IsSynthetic());
50
ensure_not(c0.IsKeyPoint());
51
ensure_not(c0.IsWithheld());
58
liblas::Classification c31(0x1F);
60
ensure_not(c31 == m_default);
61
ensure_equals(c31.GetClass(), 31);
62
ensure_not(c31.IsSynthetic());
63
ensure_not(c31.IsKeyPoint());
64
ensure_not(c31.IsWithheld());
71
liblas::Classification c255(255);
72
ensure_equals(c255, bitset_type(255));
73
ensure_equals(c255.GetClass(), 31);
74
ensure(c255.IsSynthetic());
75
ensure(c255.IsKeyPoint());
76
ensure(c255.IsWithheld());
83
liblas::Classification c(31, false, false, false);
85
ensure_equals(c.GetClass(), 31);
86
ensure_not(c.IsSynthetic());
87
ensure_not(c.IsKeyPoint());
88
ensure_not(c.IsWithheld());
89
ensure_equals(c, bitset_type(std::string("00011111")));
96
liblas::Classification c(7, true, false, true);
98
ensure_equals(c.GetClass(), 7);
99
ensure_not(c.IsKeyPoint());
100
ensure(c.IsWithheld());
101
ensure(c.IsSynthetic());
102
ensure_equals(c, bitset_type(std::string("10100111")));
111
liblas::Classification c(255, true, true, true);
113
fail("std::out_of_range not thrown but expected");
115
catch (std::out_of_range const& e)
117
ensure(e.what(), true);
121
fail("unhandled exception expected");
129
liblas::Classification cpy(m_default);
131
ensure_equals(cpy, m_default);
138
liblas::Classification c(7, true, false, true);
139
liblas::Classification cpy(c);
141
ensure_equals(cpy.GetClass(), 7);
142
ensure_not(cpy.IsKeyPoint());
143
ensure(cpy.IsWithheld());
144
ensure(cpy.IsSynthetic());
145
ensure_equals(cpy, bitset_type(std::string("10100111")));
146
ensure_equals(cpy, c);
153
liblas::Classification cpy;
156
ensure_equals(cpy, m_default);
163
liblas::Classification c(7, true, false, true);
164
liblas::Classification cpy = c;
166
ensure_equals(cpy.GetClass(), 7);
167
ensure_not(cpy.IsKeyPoint());
168
ensure(cpy.IsWithheld());
169
ensure(cpy.IsSynthetic());
170
ensure_equals(cpy, bitset_type(std::string("10100111")));
171
ensure_equals(cpy, c);
179
liblas::Classification c;
182
ensure_equals(c.GetClass(), 0);
185
ensure_equals(c.GetClass(), 31);
187
ensure(c != m_default);
194
liblas::Classification c;
196
c.SetSynthetic(true);
197
ensure(c.IsSynthetic());
198
ensure(c != m_default);
200
c.SetSynthetic(false);
201
ensure_not(c.IsSynthetic());
202
ensure_equals(c, m_default);
204
c.SetSynthetic(true);
205
ensure(c.IsSynthetic());
206
ensure(c != m_default);
208
c.SetSynthetic(false);
209
ensure_not(c.IsSynthetic());
210
ensure_equals(c, m_default);
212
ensure_equals(c.GetClass(), 0);
219
liblas::Classification c;
222
ensure(c.IsKeyPoint());
223
ensure(c != m_default);
225
c.SetKeyPoint(false);
226
ensure_not(c.IsKeyPoint());
227
ensure_equals(c, m_default);
230
ensure(c.IsKeyPoint());
231
ensure(c != m_default);
233
c.SetKeyPoint(false);
234
ensure_not(c.IsKeyPoint());
235
ensure_equals(c, m_default);
237
ensure_equals(c.GetClass(), 0);
244
liblas::Classification c;
247
ensure(c.IsWithheld());
248
ensure(c != m_default);
250
c.SetWithheld(false);
251
ensure_not(c.IsWithheld());
252
ensure_equals(c, m_default);
255
ensure(c.IsWithheld());
256
ensure(c != m_default);
258
c.SetWithheld(false);
259
ensure_not(c.IsWithheld());
260
ensure_equals(c, m_default);
262
ensure_equals(c.GetClass(), 0);
269
liblas::Classification c;
272
ensure(c.IsKeyPoint());
273
ensure(c != m_default);
276
ensure(c.IsWithheld());
277
ensure(c.IsKeyPoint());
278
ensure(c != m_default);
280
c.SetSynthetic(true);
281
ensure(c.IsWithheld());
282
ensure(c.IsKeyPoint());
283
ensure(c.IsSynthetic());
284
ensure(c != m_default);
286
ensure_equals(c.GetClass(), 0);
293
liblas::Classification c;
296
c.SetSynthetic(true);
298
ensure(c.IsWithheld());
299
ensure(c.IsKeyPoint());
300
ensure(c.IsSynthetic());
301
ensure_not(c == m_default);
302
ensure_equals(c.GetClass(), 0);
304
c.SetKeyPoint(false);
305
c.SetSynthetic(false);
306
c.SetWithheld(false);
307
ensure_not(c.IsWithheld());
308
ensure_not(c.IsKeyPoint());
309
ensure_not(c.IsSynthetic());
310
ensure_equals(c.GetClass(), 0);
312
liblas::Classification::bitset_type bits1(c);
313
liblas::Classification::bitset_type bits2(m_default);
314
ensure_equals(c, m_default);
321
liblas::Classification c;
325
c.SetSynthetic(true);
327
ensure(c.IsWithheld());
328
ensure(c.IsKeyPoint());
329
ensure(c.IsSynthetic());
330
ensure_equals(c.GetClass(), 1);
331
ensure_not(c == m_default);
333
c.SetKeyPoint(false);
334
c.SetSynthetic(false);
336
c.SetWithheld(false);
337
ensure_not(c.IsWithheld());
338
ensure_not(c.IsKeyPoint());
339
ensure_not(c.IsSynthetic());
340
ensure_equals(c.GetClass(), 0);
342
liblas::Classification::bitset_type bits1(c);
343
liblas::Classification::bitset_type bits2(m_default);
344
ensure_equals(c, m_default);
351
std::string const sbits("00000000");
353
liblas::Classification c;
355
std::ostringstream oss;
357
ensure_equals(oss.str(), sbits);
364
std::string const sbits("00000011");
366
liblas::Classification c;
369
std::ostringstream oss;
371
ensure_equals(oss.str(), sbits);
378
std::string const sbits("10000001");
380
liblas::Classification c;
385
std::ostringstream oss;
387
ensure_equals(oss.str(), sbits);
394
std::string const sbits("10110000");
396
liblas::Classification c;
399
c.SetSynthetic(true);
400
c.SetKeyPoint(false);
403
std::ostringstream oss;
405
ensure_equals(oss.str(), sbits);
412
std::string const sbits("00000000");
413
liblas::Classification::bitset_type bits(sbits);
415
liblas::Classification c(bits);
416
ensure_equals(c, bits);
418
std::ostringstream oss;
420
ensure_equals(oss.str(), sbits);
427
std::string const sbits("00000011");
428
liblas::Classification::bitset_type bits(sbits);
430
liblas::Classification c(bits);
431
ensure_equals(c, bits);
433
std::ostringstream oss;
435
ensure_equals(oss.str(), sbits);
442
std::string const sbits("10000001");
443
liblas::Classification::bitset_type bits(sbits);
445
liblas::Classification c(bits);
446
ensure_equals(c, bits);
448
std::ostringstream oss;
450
ensure_equals(oss.str(), sbits);
457
std::string const sbits("10110000");
458
liblas::Classification::bitset_type bits(sbits);
460
liblas::Classification c(bits);
461
ensure_equals(c, bits);
463
std::ostringstream oss;
465
ensure_equals(oss.str(), sbits);
472
std::string const cn("Created, never classified");
473
ensure_equals(m_default.GetClassName(), cn);
480
std::string const cn("Low Point (noise)");
481
m_default.SetClass(7);
482
ensure_equals(m_default.GetClassName(), cn);
489
std::string const cn("Reserved for ASPRS Definition");
490
m_default.SetClass(31);
491
ensure_equals(m_default.GetClassName(), cn);
500
m_default.SetClass(32);
501
fail("std::out_of_range not thrown but expected");
503
catch (std::out_of_range const& e)
505
ensure(e.what(), true);
509
fail("unhandled exception expected");