1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5
* Purpose: Test cases of LASHeader class, .NET/Mono bindings
6
* Author: Martin Vales, martin_gnu@mundo-r.com
8
******************************************************************************
9
* Copyright (c) 2008, Martin Vales
11
* All rights reserved.
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following
17
* * Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* * Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in
21
* the documentation and/or other materials provided
22
* with the distribution.
23
* * Neither the name of the Martin Isenburg or Iowa Department
24
* of Natural Resources nor the names of its contributors may be
25
* used to endorse or promote products derived from this software
26
* without specific prior written permission.
28
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
40
****************************************************************************/
43
using System.Collections.Generic;
45
using NUnit.Framework;
51
public class LASHeaderTest
54
protected void SetUp()
59
public void CopyConstructor()
61
LASHeader header = new LASHeader();
62
// string sig = "LASF and garbage";
63
// header.FileSignature = sig;
64
// Assert.AreEqual(header.FileSignature.Length,4);
66
Assert.AreEqual(1, 1);
67
//h1.SetFileSignature(sig);
68
//ensure_not(h1.GetFileSignature() == sig);
69
//ensure_equals(h1.GetFileSignature().size(), 4);
70
//ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
74
//ensure_not(h2.GetFileSignature() == sig);
75
//ensure_equals(h2.GetFileSignature().size(), 4);
76
//ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
80
public void FileSignature()
82
LASHeader header = new LASHeader();
83
// string sig = "LASF and garbage";
85
Assert.AreEqual(header.FileSignature.Length, 4);
86
Assert.AreEqual(header.FileSignature, "LASF");
88
// I can not set FileSignature from c# API because i am a bad guy.
89
//header.FileSignature = "LASF";
93
public void FileSourceId()
95
LASHeader h1 = new LASHeader();
99
UInt16 overflowed = 0;
101
h1.FileSourceId = id1;
102
Assert.AreEqual(h1.FileSourceId, id1);
103
h1.FileSourceId = id2;
104
Assert.AreEqual(h1.FileSourceId, id2);
107
// Likely compiler warning: truncation from int to liblas::uint16_t
108
h1.FileSourceId = (ushort)(id2 + 1);
109
Assert.AreEqual(h1.FileSourceId, overflowed);
113
public void Reserved()
115
LASHeader h = new LASHeader();
117
Assert.AreEqual(h.Reserved, 0);
121
public void ProjectId()
123
LASHeader h = new LASHeader();
125
//string strid="030B4A82-1B7C-11CF-9D53-00AA003C9CB6";
126
// Assert.AreEqual(h.Reserved, 0);
127
// liblas::guid id(strid.c_str());
129
// std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6");
130
//liblas::guid id(strid.c_str());
132
//liblas::LASHeader h;
133
//h.SetProjectId(id);
135
//ensure_not(h.GetProjectId().is_null());
136
//ensure_equals(h.GetProjectId(), id);
140
public void MinorMajorVersion()
142
LASHeader h = new LASHeader();
145
Assert.AreEqual(h.VersionMinor, 0);
146
Assert.AreEqual(h.VersionMajor, 1);
150
Assert.AreEqual(h.VersionMinor, 1);
151
Assert.AreEqual(h.VersionMajor, 1);
156
//don�t get the next line...
157
Assert.AreEqual(2, 5);
159
catch (LASException e)
161
Assert.AreEqual(e.Message, "Exception in Set Header VersionMajor.");
167
//don�t get the next line...
168
Assert.AreEqual(2, 5);
170
catch (LASException e)
172
Assert.AreEqual(e.Message, "Exception in Set Header VersionMinor.");
177
public void SoftwareId()
179
LASHeader h = new LASHeader();
181
string softid1 = "Short Soft Id"; // 13 bytes
182
int len1 = softid1.Length;
183
string softid2 = "Long Software Identifier - XX YY"; // 32 bytes
184
int len2 = softid2.Length;
186
h.SoftwareId = softid1;
187
Assert.AreEqual(h.SoftwareId, softid1);
188
Assert.AreEqual(h.SoftwareId.Length, len1);
189
// Assert.AreEqual(h.GetSoftwareId(true).size(), 32);
191
h.SoftwareId = softid2;
192
Assert.AreEqual(h.SoftwareId, softid2);
193
Assert.AreEqual(h.SoftwareId.Length, len2);
194
// Assert.AreEqual(h.GetSoftwareId(true).size(), 32);
198
public void PointRecordsByReturnCount()
200
LASHeader h = new LASHeader();
201
// Assert.AreEqual(h.GetPointRecordsByReturnCount(5),5);
203
h.SetPointRecordsByReturnCount(0, 100);
204
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
205
Assert.AreEqual(h.GetPointRecordsByReturnCount(0), 100);
207
h.SetPointRecordsByReturnCount(1, 101);
208
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
209
Assert.AreEqual(h.GetPointRecordsByReturnCount(1), 101);
211
h.SetPointRecordsByReturnCount(2, 102);
212
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
213
Assert.AreEqual(h.GetPointRecordsByReturnCount(2), 102);
215
h.SetPointRecordsByReturnCount(3, 103);
216
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
217
Assert.AreEqual(h.GetPointRecordsByReturnCount(3), 103);
219
h.SetPointRecordsByReturnCount(4, 104);
220
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
221
Assert.AreEqual(h.GetPointRecordsByReturnCount(4), 104);
226
h.SetPointRecordsByReturnCount(5, 500);
227
//don�t get the next line...
228
Assert.AreEqual(2, 5);
230
catch (LASException e)
232
Assert.AreEqual(e.Message, "Exception in Set Header SetPointRecordsByReturnCount.");