@@ -172,7 +172,8 @@ TEST testPDALGetPointViewSize(void)
172172
173173TEST testPDALGetMeshSize(void)
174174{
175- ASSERT_EQ(0, PDALGetMeshSize(NULL));
175+ uint64_t size = PDALGetMeshSize(NULL);
176+ ASSERT(size == 0);
176177
177178 PDALResetPointViewIterator(gPointViewIterator);
178179 bool hasNext = PDALHasNextPointView(gPointViewIterator);
@@ -184,9 +185,9 @@ TEST testPDALGetMeshSize(void)
184185 // Dispose view before assertion to avoid CWE-404
185186 // See http://cwe.mitre.org/data/definitions/404.html
186187 // See https://scan4.coverity.com/doc/en/cov_checker_ref.html#static_checker_RESOURCE_LEAK
187- size_t size = PDALGetMeshSize(view);
188+ size = PDALGetMeshSize(view);
188189 PDALDisposePointView(view);
189- ASSERT(size == 0 );
190+ ASSERT(size == 2114 );
190191
191192
192193 PASS();
@@ -675,20 +676,55 @@ TEST testPDALGetAllPackedPoints(void)
675676 PASS();
676677}
677678
679+ TEST testPDALGetAllTriangles(void)
680+ {
681+ PDALResetPointViewIterator(gPointViewIterator);
682+ bool hasNext = PDALHasNextPointView(gPointViewIterator);
683+ ASSERT(hasNext);
684+
685+ PDALPointViewPtr view = PDALGetNextPointView(gPointViewIterator);
686+ ASSERT(view);
687+
688+ uint64_t numPoints = PDALGetMeshSize(view);
689+
690+ if (numPoints == 0)
691+ {
692+ PDALDisposePointView(view);
693+ FAILm("PDALGetMeshSize returned tri size of zero for a valid view");
694+ }
695+
696+ char *actualPoints = calloc(numPoints, 12);
697+
698+ if (!actualPoints)
699+ {
700+ PDALDisposePointView(view);
701+ FAILm("Could not allocate packed point list buffer");
702+ }
703+
704+ uint64_t actualSize = PDALGetAllTriangles(view, actualPoints);
705+ ASSERT_EQ(actualSize, 25368);
706+
707+ free(actualPoints);
708+ PDALDisposePointView(view);
709+ PASS();
710+ }
711+
678712GREATEST_SUITE(test_pdalc_pointview)
679713{
680714 SET_SETUP(setup_test_pdalc_pointview, NULL);
681715 SET_TEARDOWN(teardown_test_pdalc_pointview, NULL);
682716
683717 RUN_TEST(testPDALGetPointViewId);
684718 RUN_TEST(testPDALGetPointViewSize);
719+ RUN_TEST(testPDALGetMeshSize);
685720 RUN_TEST(testPDALIsPointViewEmpty);
686721 RUN_TEST(testPDALClonePointView);
687722 RUN_TEST(testPDALGetPointViewProj4);
688723 RUN_TEST(testPDALGetPointViewWkt);
689724 RUN_TEST(testPDALGetPointViewLayout);
690725 RUN_TEST(testPDALGetPackedPoint);
691726 RUN_TEST(testPDALGetAllPackedPoints);
727+ RUN_TEST(testPDALGetAllTriangles);
692728
693729 SET_SETUP(NULL, NULL);
694730 SET_TEARDOWN(NULL, NULL);
0 commit comments