@@ -40,7 +40,8 @@ using namespace splash;
40
40
41
41
SimpleDataTest::SimpleDataTest () :
42
42
ctUInt32(),
43
- ctUInt64()
43
+ ctUInt64(),
44
+ ctBool()
44
45
{
45
46
dataCollector = new SerialDataCollector (10 );
46
47
srand (time (NULL ));
@@ -74,9 +75,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
74
75
// initial part of the test: data is written to the file, once with and once
75
76
// without borders
76
77
uint64_t *dataWrite = new uint64_t [bufferSize];
78
+ bool *boolWrite = new bool [bufferSize];
77
79
78
80
for (uint64_t i = 0 ; i < bufferSize; i++)
81
+ {
79
82
dataWrite[i] = i;
83
+ boolWrite[i] = ( i%2 == 0 );
84
+ }
80
85
81
86
dataCollector->write (10 , ctUInt64, dimensions, Selection (gridSize), " deep/folders/data" , dataWrite);
82
87
datasetNames.insert (" deep/folders/data" );
@@ -85,6 +90,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
85
90
borderSize), " deep/folders/data_without_borders" , dataWrite);
86
91
datasetNames.insert (" deep/folders/data_without_borders" );
87
92
93
+ dataCollector->write (10 , ctBool, dimensions, Selection (gridSize), " deep/folders/data_bool" , boolWrite);
94
+ datasetNames.insert (" deep/folders/data_bool" );
95
+
96
+ dataCollector->write (20 , ctBool, dimensions, Selection (gridSize, smallGridSize,
97
+ borderSize), " deep/folders/data_bool_without_borders" , boolWrite);
98
+ datasetNames.insert (" deep/folders/data_bool_without_borders" );
99
+
88
100
dataCollector->close ();
89
101
90
102
// first part of the test: read data with borders to a cleared
@@ -103,14 +115,17 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
103
115
int32_t *ids = NULL ;
104
116
size_t numIDs = 0 ;
105
117
dataCollector->getEntryIDs (NULL , &numIDs);
118
+ #if defined TESTS_DEBUG
119
+ printf (" number of entry IDs=%d\n " , numIDs);
120
+ #endif
106
121
CPPUNIT_ASSERT (numIDs == 2 );
107
122
ids = new int32_t [numIDs];
108
123
dataCollector->getEntryIDs (ids, NULL );
109
124
110
125
for (uint32_t j = 0 ; j < numIDs; ++j)
111
126
{
112
127
dataCollector->getEntriesForID (ids[j], NULL , &numEntries);
113
- CPPUNIT_ASSERT (numEntries == 1 );
128
+ CPPUNIT_ASSERT (numEntries == 2 );
114
129
entries = new DataCollector::DCEntry[numEntries];
115
130
dataCollector->getEntriesForID (ids[j], entries, NULL );
116
131
@@ -129,16 +144,23 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
129
144
delete[] ids;
130
145
131
146
uint64_t *dataRead = new uint64_t [bufferSize];
147
+ bool *boolRead = new bool [bufferSize];
132
148
for (uint64_t i = 0 ; i < bufferSize; i++)
149
+ {
133
150
dataRead[i] = UINT64_MAX;
151
+ boolRead[i] = false ;
152
+ }
134
153
135
154
Dimensions resultSize;
136
155
dataCollector->read (10 , " deep/folders/data" , resultSize, dataRead);
137
156
138
157
for (uint32_t i = 0 ; i < 3 ; i++)
139
158
CPPUNIT_ASSERT (resultSize[i] == gridSize[i]);
140
159
160
+ dataCollector->read (10 , " deep/folders/data_bool" , resultSize, boolRead);
161
+
141
162
for (uint64_t i = 0 ; i < bufferSize; i++)
163
+ {
142
164
if (dataRead[i] != dataWrite[i])
143
165
{
144
166
#if defined TESTS_DEBUG
@@ -147,6 +169,15 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
147
169
resultsCorrect = false ;
148
170
break ;
149
171
}
172
+ if (boolRead[i] != boolWrite[i])
173
+ {
174
+ #if defined TESTS_DEBUG
175
+ std::cout << i << " : " << boolRead[i] << " != exptected " << boolWrite[i] << std::endl;
176
+ #endif
177
+ resultsCorrect = false ;
178
+ break ;
179
+ }
180
+ }
150
181
151
182
delete[] dataRead;
152
183
@@ -157,8 +188,12 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
157
188
// locations in a cleared array (-1)
158
189
159
190
dataRead = new uint64_t [bufferSize];
191
+ boolRead = new bool [bufferSize];
160
192
for (uint64_t i = 0 ; i < bufferSize; i++)
193
+ {
161
194
dataRead[i] = UINT64_MAX;
195
+ boolRead[i] = false ;
196
+ }
162
197
163
198
dataCollector->read (20 , " deep/folders/data_without_borders" , gridSize, borderSize,
164
199
resultSize, NULL );
@@ -228,7 +263,9 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
228
263
}
229
264
230
265
delete[] dataRead;
266
+ delete[] boolRead;
231
267
delete[] dataWrite;
268
+ delete[] boolWrite;
232
269
233
270
dataCollector->close ();
234
271
0 commit comments