99#include "greatest.h"
1010
1111#include <pdal/capi/Pipeline.h>
12+ #include <pdal/capi/PointLayout.h>
1213#include <pdal/capi/PointView.h>
1314#include <pdal/capi/PointViewIterator.h>
1415
@@ -131,20 +132,82 @@ TEST testPDALGetPointViewSize(void)
131132{
132133 ASSERT_EQ(0, PDALGetPointViewSize(NULL));
133134
135+ PDALResetPointViewIterator(gPointViewIterator);
136+ bool hasNext = PDALHasNextPointView(gPointViewIterator);
137+ ASSERT(hasNext);
138+
139+ PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
140+ ASSERT(view);
141+
142+ size_t size = PDALGetPointViewSize(view);
143+ ASSERT(size > 0);
144+
145+ PDALDisposePointView(view);
134146 PASS();
135147}
136148
137149TEST testPDALIsPointViewEmpty(void)
138150{
139151 ASSERT(PDALIsPointViewEmpty(NULL));
140152
153+ PDALResetPointViewIterator(gPointViewIterator);
154+ bool hasNext = PDALHasNextPointView(gPointViewIterator);
155+ ASSERT(hasNext);
156+
157+ PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
158+ ASSERT(view);
159+
160+ ASSERT_FALSE(PDALIsPointViewEmpty(view));
161+ PDALDisposePointView(view);
162+
141163 PASS();
142164}
143165
144166TEST testPDALClonePointView(void)
145167{
146168 PDALResetPointViewIterator(gPointViewIterator);
169+ bool hasNext = PDALHasNextPointView(gPointViewIterator);
170+ ASSERT(hasNext);
147171
172+ PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
173+ ASSERT(view);
174+
175+ PDALPointLayoutPtr anotherView = PDALClonePointView(view);
176+
177+ ASSERT(anotherView);
178+ ASSERT(view != anotherView);
179+ ASSERT(PDALGetPointViewId(view) != PDALGetPointViewId(anotherView));
180+
181+ size_t capacity = 1024;
182+ char expected[1024];
183+ char actual[1024];
184+
185+ size_t expectedLength = PDALGetPointViewProj4(view, expected, capacity);
186+ ASSERT(expectedLength > 0 && expectedLength <= capacity);
187+ ASSERT(expected[0] != '\0');
188+
189+ size_t actualLength = PDALGetPointViewProj4(view, actual, capacity);
190+ ASSERT_EQ(expectedLength, actualLength);
191+ ASSERT_STR_EQ(expected, actual);
192+
193+ expectedLength = PDALGetPointViewWkt(view, expected, capacity, false);
194+ ASSERT(expectedLength > 0 && expectedLength <= capacity);
195+ ASSERT(expected[0] != '\0');
196+
197+ actualLength = PDALGetPointViewWkt(view, actual, capacity, false);
198+ ASSERT_EQ(expectedLength, actualLength);
199+ ASSERT_STR_EQ(expected, actual);
200+
201+ expectedLength = PDALGetPointViewWkt(view, expected, capacity, true);
202+ ASSERT(expectedLength > 0 && expectedLength <= capacity);
203+ ASSERT(expected[0] != '\0');
204+
205+ actualLength = PDALGetPointViewWkt(view, actual, capacity, true);
206+ ASSERT_EQ(expectedLength, actualLength);
207+ ASSERT_STR_EQ(expected, actual);
208+
209+ PDALDisposePointView(anotherView);
210+ PDALDisposePointView(view);
148211
149212 PASS();
150213}
@@ -158,22 +221,26 @@ TEST testPDALGetPointViewProj4(void)
158221 PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
159222 ASSERT(view);
160223
224+ size_t capacity = 1024;
161225 char proj[1024];
162- size_t size = PDALGetPointViewProj4(NULL, proj, 1024);
226+
227+ size_t size = PDALGetPointViewProj4(NULL, proj, capacity);
163228 ASSERT_EQ(0, size);
164229 ASSERT_EQ('\0', proj[0]);
165230
166- size = PDALGetPointViewProj4(view, NULL, 1024 );
231+ size = PDALGetPointViewProj4(view, NULL, capacity );
167232 ASSERT_EQ(0, size);
168233
169234 size = PDALGetPointViewProj4(view, proj, 0);
170235 ASSERT_EQ(0, size);
171236
172- size = PDALGetPointViewProj4(view, proj, 1024 );
173- ASSERT(size > 0 && size <= 1024 );
237+ size = PDALGetPointViewProj4(view, proj, capacity );
238+ ASSERT(size > 0 && size <= capacity );
174239 ASSERT_FALSE(proj[0] == '\0');
175240 ASSERT_STR_EQ("+proj=longlat +datum=WGS84 +no_defs", proj);
176241
242+ PDALDisposePointView(view);
243+
177244 PASS();
178245}
179246
@@ -186,19 +253,21 @@ TEST testPDALGetPointViewWkt(void)
186253 PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
187254 ASSERT(view);
188255
256+ size_t capacity = 1024;
189257 char wkt[1024];
190- size_t size = PDALGetPointViewWkt(NULL, wkt, 1024, false);
258+
259+ size_t size = PDALGetPointViewWkt(NULL, wkt, capacity, false);
191260 ASSERT_EQ(0, size);
192261 ASSERT_EQ('\0', wkt[0]);
193262
194- size = PDALGetPointViewWkt(view, NULL, 1024 , false);
263+ size = PDALGetPointViewWkt(view, NULL, capacity , false);
195264 ASSERT_EQ(0, size);
196265
197266 size = PDALGetPointViewWkt(view, wkt, 0, false);
198267 ASSERT_EQ(0, size);
199268
200- size = PDALGetPointViewWkt(view, wkt, 1024 , false);
201- ASSERT(size > 0 && size <= 1024 );
269+ size = PDALGetPointViewWkt(view, wkt, capacity , false);
270+ ASSERT(size > 0 && size <= capacity );
202271 ASSERT_FALSE(wkt[0] == '\0');
203272 ASSERT_STR_EQ(
204273 "GEOGCS[\"WGS 84\","
@@ -213,6 +282,15 @@ TEST testPDALGetPointViewWkt(void)
213282 wkt
214283 );
215284
285+
286+ char prettyWkt[1024];
287+ size_t prettySize = PDALGetPointViewWkt(view, prettyWkt, capacity, true);
288+ ASSERT(prettySize > 0 && prettySize <= capacity);
289+ ASSERT(size < prettySize);
290+ ASSERT(strcmp(wkt, prettyWkt) != 0);
291+
292+ PDALDisposePointView(view);
293+
216294 PASS();
217295}
218296
@@ -232,6 +310,8 @@ TEST testPDALGetPointViewLayout(void)
232310 layout = PDALGetPointViewLayout(view);
233311 ASSERT(layout);
234312
313+ PDALDisposePointView(view);
314+
235315 PASS();
236316}
237317
0 commit comments