1313
1414SUITE(PointViewCollectionTest);
1515
16+ static PDALPipelinePtr gPipeline = NULL;
1617static PDALPointViewCollectionPtr gPointViewCollection = NULL;
1718
1819static void setupPointViewCollectionTest(void *arg)
@@ -31,22 +32,25 @@ static void setupPointViewCollectionTest(void *arg)
3132 {
3233 fread(json, 1, length, file);
3334 json[length] = '\0';
34- }
3535
36- fclose(file);
37- }
36+ gPipeline = PDALCreatePipeline(json);
3837
39- PDALPipelinePtr pipeline = PDALCreatePipeline(json);
38+ if (gPipeline && PDALExecutePipeline(gPipeline))
39+ {
40+ gPointViewCollection = PDALGetPointViews(gPipeline);
41+ }
4042
41- if (pipeline && PDALExecutePipeline(pipeline))
42- {
43- gPointViewCollection = PDALGetPointViews(pipeline);
43+ free(json);
44+ }
45+
46+ fclose(file);
4447 }
4548}
4649
4750static void teardownPointViewCollectionTest(void *arg)
4851{
4952 PDALDisposePointViewCollection(gPointViewCollection);
53+ PDALDisposePipeline(gPipeline);
5054}
5155
5256TEST testPDALHasNextPointView(void)
@@ -61,28 +65,35 @@ TEST testPDALHasNextPointView(void)
6165 PASS();
6266}
6367
64- TEST testPDALNextPointView (void)
68+ TEST testPDALGetNextPointView (void)
6569{
70+ PDALPointViewPtr view = PDALGetNextPointView(NULL);
71+ ASSERT_EQ(NULL, view);
72+
6673 ASSERT_FALSE(gPointViewCollection == NULL);
74+ PDALResetPointViewCollection(gPointViewCollection);
6775 bool hasNext = PDALHasNextPointView(gPointViewCollection);
6876 ASSERT_FALSE(!hasNext);
6977
70- PDALPointViewPtr view = PDALGetNextPointView(gPointViewCollection);
78+ view = PDALGetNextPointView(gPointViewCollection);
7179 ASSERT_FALSE(view == NULL);
7280
7381 if (PDALHasNextPointView(gPointViewCollection))
7482 {
7583 PDALPointViewPtr anotherView = PDALGetNextPointView(gPointViewCollection);
7684 ASSERT_FALSE(anotherView == NULL);
7785 ASSERT_FALSE(anotherView == view);
86+ PDALDisposePointView(anotherView);
7887 }
7988
89+ PDALDisposePointView(view);
8090 PASS();
8191}
8292
8393TEST testPDALResetPointViewCollection(void)
8494{
8595 ASSERT_FALSE(gPointViewCollection == NULL);
96+ PDALResetPointViewCollection(gPointViewCollection);
8697 bool hasNext = PDALHasNextPointView(gPointViewCollection);
8798 ASSERT_FALSE(!hasNext);
8899
@@ -94,15 +105,20 @@ TEST testPDALResetPointViewCollection(void)
94105 PDALPointViewPtr anotherView = PDALGetNextPointView(gPointViewCollection);
95106 ASSERT_FALSE(anotherView == NULL);
96107 ASSERT_FALSE(anotherView == view);
108+ PDALDisposePointView(anotherView);
97109 }
98110
111+ PDALDisposePointView(view);
112+
99113 view = PDALGetNextPointView(gPointViewCollection);
100114 ASSERT_EQ(NULL, view);
115+ PDALDisposePointView(view);
101116
102117 PDALResetPointViewCollection(gPointViewCollection);
103118
104119 view = PDALGetNextPointView(gPointViewCollection);
105120 ASSERT_FALSE(view == NULL);
121+ PDALDisposePointView(view);
106122
107123 PASS();
108124}
@@ -113,7 +129,7 @@ GREATEST_SUITE(PointViewCollectionTest)
113129 SET_TEARDOWN(teardownPointViewCollectionTest, NULL);
114130
115131 RUN_TEST(testPDALHasNextPointView);
116- RUN_TEST(testPDALNextPointView );
132+ RUN_TEST(testPDALGetNextPointView );
117133 RUN_TEST(testPDALResetPointViewCollection);
118134
119135 SET_SETUP(NULL, NULL);
0 commit comments