Skip to content

Commit a9b9bce

Browse files
committed
Add Bool SimpleTest
1 parent 72f83b2 commit a9b9bce

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/include/splash/basetypes/ColTypeBool.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class ColTypeBool : public CollectionType
3636
ColTypeBool()
3737
{
3838
this->type = H5Tenum_create(H5T_NATIVE_INT8);
39+
const char *names[2] = {"true", "false"};
40+
int64_t val[2] = {1, 0};
41+
H5Tenum_insert(this->type, names[0], &val[0]);
42+
H5Tenum_insert(this->type, names[1], &val[1]);
3943
}
4044

4145
~ColTypeBool()

tests/SimpleDataTest.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ using namespace splash;
4040

4141
SimpleDataTest::SimpleDataTest() :
4242
ctUInt32(),
43-
ctUInt64()
43+
ctUInt64(),
44+
ctBool()
4445
{
4546
dataCollector = new SerialDataCollector(10);
4647
srand(time(NULL));
@@ -74,9 +75,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
7475
// initial part of the test: data is written to the file, once with and once
7576
// without borders
7677
uint64_t *dataWrite = new uint64_t[bufferSize];
78+
bool *boolWrite = new bool[bufferSize];
7779

7880
for (uint64_t i = 0; i < bufferSize; i++)
81+
{
7982
dataWrite[i] = i;
83+
boolWrite[i] = ( i%2 == 0 );
84+
}
8085

8186
dataCollector->write(10, ctUInt64, dimensions, Selection(gridSize), "deep/folders/data", dataWrite);
8287
datasetNames.insert("deep/folders/data");
@@ -85,6 +90,13 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
8590
borderSize), "deep/folders/data_without_borders", dataWrite);
8691
datasetNames.insert("deep/folders/data_without_borders");
8792

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+
88100
dataCollector->close();
89101

90102
// first part of the test: read data with borders to a cleared
@@ -103,14 +115,16 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
103115
int32_t *ids = NULL;
104116
size_t numIDs = 0;
105117
dataCollector->getEntryIDs(NULL, &numIDs);
118+
printf("number of entry IDs=%d\n", numIDs);
106119
CPPUNIT_ASSERT(numIDs == 2);
107120
ids = new int32_t[numIDs];
108121
dataCollector->getEntryIDs(ids, NULL);
109122

110123
for (uint32_t j = 0; j < numIDs; ++j)
111124
{
112125
dataCollector->getEntriesForID(ids[j], NULL, &numEntries);
113-
CPPUNIT_ASSERT(numEntries == 1);
126+
printf("numEntries=%d\n", numEntries);
127+
CPPUNIT_ASSERT(numEntries == 2);
114128
entries = new DataCollector::DCEntry[numEntries];
115129
dataCollector->getEntriesForID(ids[j], entries, NULL);
116130

@@ -129,6 +143,7 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
129143
delete[] ids;
130144

131145
uint64_t *dataRead = new uint64_t[bufferSize];
146+
bool *boolRead = NULL;
132147
for (uint64_t i = 0; i < bufferSize; i++)
133148
dataRead[i] = UINT64_MAX;
134149

@@ -157,8 +172,12 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
157172
// locations in a cleared array (-1)
158173

159174
dataRead = new uint64_t[bufferSize];
175+
boolRead = new bool[bufferSize];
160176
for (uint64_t i = 0; i < bufferSize; i++)
177+
{
161178
dataRead[i] = UINT64_MAX;
179+
boolRead[i] = false;
180+
}
162181

163182
dataCollector->read(20, "deep/folders/data_without_borders", gridSize, borderSize,
164183
resultSize, NULL);
@@ -169,6 +188,20 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
169188
dataCollector->read(20, "deep/folders/data_without_borders", gridSize, borderSize,
170189
resultSize, dataRead);
171190

191+
/*
192+
dataCollector->read(20, "deep/folders/data_bool", gridSize, borderSize,
193+
resultSize, boolRead);
194+
195+
for (uint64_t i = 0; i < bufferSize; i++)
196+
{
197+
if (boolRead[i] % 2 != 0)
198+
{
199+
resultsCorrect = false;
200+
break;
201+
}
202+
}
203+
*/
204+
172205
// print out read and written data for debugging purposes
173206
#if defined TESTS_DEBUG
174207
for (size_t k = 0; k < gridSize[2]; k++)
@@ -228,7 +261,9 @@ bool SimpleDataTest::subtestWriteRead(Dimensions gridSize, Dimensions borderSize
228261
}
229262

230263
delete[] dataRead;
264+
delete[] boolRead;
231265
delete[] dataWrite;
266+
delete[] boolWrite;
232267

233268
dataCollector->close();
234269

tests/include/SimpleDataTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class SimpleDataTest : public CPPUNIT_NS::TestFixture
6363

6464
ColTypeUInt32 ctUInt32;
6565
ColTypeUInt64 ctUInt64;
66+
ColTypeBool ctBool;
6667
DataCollector *dataCollector;
6768
};
6869

0 commit comments

Comments
 (0)