1+ /*
2+ * Copyright (c) Simverge Software LLC - All Rights Reserved
3+ */
4+
5+ #include <stdlib.h>
6+ #include <stdio.h>
7+ #include <assert.h>
8+
9+ #include "greatest.h"
10+
11+ #include <pdal/capi/Pipeline.h>
12+ #include <pdal/capi/PointLayout.h>
13+ #include <pdal/capi/PointView.h>
14+ #include <pdal/capi/PointViewCollection.h>
15+
16+ SUITE(PointLayoutTest);
17+
18+ static PDALPipelinePtr gPipeline = NULL;
19+ static PDALPointViewPtr gPointView = NULL;
20+
21+ static void setupPointLayoutTest(void *arg)
22+ {
23+ FILE *file = fopen("@CMAKE_BINARY_DIR@/data/simple-reproject.json", "rb");
24+ char *json = NULL;
25+
26+ if (file)
27+ {
28+ fseek(file, 0, SEEK_END);
29+ long length = ftell(file);
30+ fseek(file, 0, SEEK_SET);
31+ char *json = malloc(length + 1);
32+
33+ if (json)
34+ {
35+ fread(json, 1, length, file);
36+ json[length] = '\0';
37+ gPipeline = PDALCreatePipeline(json);
38+
39+ if (gPipeline && PDALExecutePipeline(gPipeline))
40+ {
41+ PDALPointViewCollectionPtr views = PDALGetPointViews(gPipeline);
42+
43+ if (PDALHasNextPointView(views))
44+ {
45+ gPointView = PDALGetNextPointView(views);
46+ }
47+ }
48+
49+ free(json);
50+ }
51+
52+ fclose(file);
53+ }
54+ }
55+
56+ static void teardownPointLayoutTest(void *arg)
57+ {
58+ PDALDisposePointView(gPointView);
59+ PDALDisposePipeline(gPipeline);
60+ }
61+
62+ TEST testPDALGetDimSize(void)
63+ {
64+ size_t size = PDALGetDimSize(NULL, NULL);
65+ ASSERT_EQ(0, size);
66+
67+ int numTypes = 3;
68+ const char *types[] = {"X", "Y", "Z"};
69+
70+ for (int i = 0; i < numTypes; ++i)
71+ {
72+ size = PDALGetDimSize(NULL, types[i]);
73+ ASSERT_EQ(0, size);
74+ }
75+
76+ PASS();
77+ }
78+
79+ TEST testPDALGetDimPackedOffset(void)
80+ {
81+ PASS();
82+ }
83+
84+ TEST testPDALGetPointSize(void)
85+ {
86+ PASS();
87+ }
88+
89+ GREATEST_SUITE(PointLayoutTest)
90+ {
91+ SET_SETUP(setupPointLayoutTest, NULL);
92+ SET_TEARDOWN(teardownPointLayoutTest, NULL);
93+
94+ RUN_TEST(testPDALGetDimSize);
95+ RUN_TEST(testPDALGetDimPackedOffset);
96+ RUN_TEST(testPDALGetPointSize);
97+
98+ SET_SETUP(NULL, NULL);
99+ SET_TEARDOWN(NULL, NULL);
100+ }
0 commit comments