Commit 72ed8f2a authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Update test

parent 4dda7236
Pipeline #101275 passed with stages
in 7 minutes and 31 seconds
......@@ -27,12 +27,8 @@ bool testWriteData(const std::string & fileName){
}
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......
......@@ -32,12 +32,8 @@ bool testWriteData(const std::string & fileName){
}
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......@@ -46,14 +42,10 @@ bool testWriteData(const std::string & fileName){
* @return true on success, false otherwise
*/
bool testReadData(const std::string & fileName){
//First let's open a file in read only mode (better for concurencial access)
H5::H5File file(fileName, H5F_ACC_RDONLY);
//Let's create our table
TableEvent table;
//Add read the file
table.read(file);
//Now we can close the file and use the Table directly
file.close();
table.read(fileName);
//Get the number of rows and number of columns
size_t nbRow = table.getNbEntries(), nbPixel = table.getNbPixel(), nbSlice = table.getNbSlice();
......
......@@ -26,12 +26,8 @@ bool testWriteData(const std::string & fileName){
tabVertex[2lu] = 3lu*i;
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......@@ -40,14 +36,10 @@ bool testWriteData(const std::string & fileName){
* @return true on success, false otherwise
*/
bool testReadData(const std::string & fileName){
//First let's open a file in read only mode (better for concurencial access)
H5::H5File file(fileName, H5F_ACC_RDONLY);
//Let's create our table
TableVertex table;
//Add read the file
table.read(file);
//Now we can close the file and use the Table directly
file.close();
table.read(fileName);
//Get the number of rows and number of columns
size_t nbRow = table.getNbEntries();
......@@ -64,16 +56,44 @@ bool testReadData(const std::string & fileName){
return b;
}
///Test to read data
/** @param fileName : name of the file to be read
* @param offset : offset of the first row to be read
* @param nbRow : number of rows to be read
* @return true on success, false otherwise
*/
bool testReadBlockData(const std::string & fileName, size_t offset, size_t nbRow){
//Let's create our table
TableVertex table;
//Add read the file
table.read(fileName, offset, nbRow);
//Get the number of rows and number of columns
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getEventId(i) == (i + offset);
b &= table.getTimestamp(i) == 2lu*(i + offset);
float * tabVertex = table.getTabVertex(i);
b &= tabVertex[0lu] == (i + offset);
b &= tabVertex[1lu] == 2lu*(i + offset);
b &= tabVertex[2lu] == 3lu*(i + offset);
}
return b;
}
int main(int argc, char** argv){
std::string fileName("configTable.h5");
if(!testWriteData(fileName)){
std::cerr << "Cannot write file '"<<fileName<<"'" << std::endl;
return -1;
}
if(!testReadData(fileName)){
std::cerr << "Cannot read file '"<<fileName<<"'" << std::endl;
return -1;
}
return 0;
bool b(true);
b &= testWriteData(fileName);
b &= testReadData(fileName);
b &= testReadBlockData(fileName, 0lu, 10lu);
b &= testReadBlockData(fileName, 1lu, 5lu);
b &= testReadBlockData(fileName, 3lu, 4lu);
b &= testReadBlockData(fileName, 5lu, 5lu);
b &= testReadBlockData(fileName, 2lu, 8lu);
return b - 1;
}
......@@ -27,12 +27,8 @@ bool testWriteData(const std::string & fileName){
}
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......@@ -41,14 +37,10 @@ bool testWriteData(const std::string & fileName){
* @return true on success, false otherwise
*/
bool testReadData(const std::string & fileName){
//First let's open a file in read only mode (better for concurencial access)
H5::H5File file(fileName, H5F_ACC_RDONLY);
//Let's create our table
TableVertex table;
//Add read the file
table.read(file);
//Now we can close the file and use the Table directly
file.close();
table.read(fileName);
//Get the number of rows and number of columns
size_t nbRow = table.getNbEntries();
......@@ -66,16 +58,42 @@ bool testReadData(const std::string & fileName){
return b;
}
///Test to read data
/** @param fileName : name of the file to be read
* @param offset : offset of the first row to be read
* @param nbRow : number of rows to be read
* @return true on success, false otherwise
*/
bool testReadBlockData(const std::string & fileName, size_t offset, size_t nbRow){
//Let's create our table
TableVertex table;
//Add read the file
table.read(fileName, offset, nbRow);
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getEventId(i) == (i + offset);
b &= table.getTimestamp(i) == 2lu*(i + offset);
float * tabVertex = table.getTabVertex(i);
size_t nbVal(TABLEVERTEX_TABVERTEX_0*TABLEVERTEX_TABVERTEX_1);
for(size_t j(0lu); j < nbVal; ++j){
b &= tabVertex[j] == (i + offset)*(j + 1lu);
}
}
return b;
}
int main(int argc, char** argv){
std::string fileName("configTable.h5");
if(!testWriteData(fileName)){
std::cerr << "Cannot write file '"<<fileName<<"'" << std::endl;
return -1;
}
if(!testReadData(fileName)){
std::cerr << "Cannot read file '"<<fileName<<"'" << std::endl;
return -1;
}
bool b(true);
b &= testWriteData(fileName);
b &= testReadData(fileName);
b &= testReadBlockData(fileName, 0lu, 10lu);
b &= testReadBlockData(fileName, 1lu, 5lu);
b &= testReadBlockData(fileName, 3lu, 4lu);
b &= testReadBlockData(fileName, 5lu, 5lu);
b &= testReadBlockData(fileName, 2lu, 8lu);
return 0;
}
......@@ -25,13 +25,8 @@ bool testWriteData(const std::string & fileName){
table.setValUInt(i, 5lu*i);
table.setValChar(i, i);
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......@@ -40,15 +35,11 @@ bool testWriteData(const std::string & fileName){
* @return true on success, false otherwise
*/
bool testReadData(const std::string & fileName){
//First let's open a file in read only mode (better for concurencial access)
H5::H5File file(fileName, H5F_ACC_RDONLY);
//Let's create our table
TableType table;
//Add read the file
table.read(file);
//Now we can close the file and use the Table directly
file.close();
table.read(fileName);
//Get the number of rows and number of columns
size_t nbRow = table.getNbEntries();
bool b(true);
......@@ -64,16 +55,41 @@ bool testReadData(const std::string & fileName){
return b;
}
///Test to read data
/** @param fileName : name of the file to be read
* @param offset : offset of the first row to be read
* @param nbRow : number of rows to be read
* @return true on success, false otherwise
*/
bool testReadBlockData(const std::string & fileName, size_t offset, size_t nbRow){
//Let's create our table
TableType table;
//Add read the file
table.read(fileName, offset, nbRow);
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getValFloat(i) == (i + offset);
b &= table.getValDouble(i) == 2lu*(i + offset);
b &= table.getValInt(i) == (int)(3lu*(i + offset));
b &= table.getValShort(i) == (short)(4lu*(i + offset));
b &= table.getValUInt(i) == 5lu*(i + offset);
b &= table.getValChar(i) == (char)(i + offset);
}
return b;
}
int main(int argc, char** argv){
std::string fileName("configType.h5");
if(!testWriteData(fileName)){
std::cerr << "Cannot write file '"<<fileName<<"'" << std::endl;
return -1;
}
if(!testReadData(fileName)){
std::cerr << "Cannot read file '"<<fileName<<"'" << std::endl;
return -1;
}
return 0;
bool b(true);
b &= testWriteData(fileName);
b &= testReadData(fileName);
b &= testReadBlockData(fileName, 0lu, 10lu);
b &= testReadBlockData(fileName, 1lu, 5lu);
b &= testReadBlockData(fileName, 3lu, 4lu);
b &= testReadBlockData(fileName, 5lu, 5lu);
b &= testReadBlockData(fileName, 2lu, 8lu);
return b - 1;
}
......@@ -26,12 +26,8 @@ bool testWriteData(const std::string & fileName){
table.setValChar(i, i);
}
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
table.write(file);
//We can also explicitly cloase the file, otherwise it will do it automatically
file.close();
table.write(fileName);
return true;
}
......@@ -40,14 +36,10 @@ bool testWriteData(const std::string & fileName){
* @return true on success, false otherwise
*/
bool testReadData(const std::string & fileName){
//First let's open a file in read only mode (better for concurencial access)
H5::H5File file(fileName, H5F_ACC_RDONLY);
//Let's create our table
TableType table;
//Add read the file
table.read(file);
//Now we can close the file and use the Table directly
file.close();
table.read(fileName);
//Get the number of rows and number of columns
size_t nbRow = table.getNbEntries();
......@@ -64,16 +56,42 @@ bool testReadData(const std::string & fileName){
return b;
}
///Test to read data
/** @param fileName : name of the file to be read
* @param offset : offset of the first row to be read
* @param nbRow : number of rows to be read
* @return true on success, false otherwise
*/
bool testReadBlockData(const std::string & fileName, size_t offset, size_t nbRow){
//Let's create our table
TableType table;
//Add read the file
table.read(fileName, offset, nbRow);
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getValFloat(i) == (i + offset);
b &= table.getValDouble(i) == 2lu*(i + offset);
b &= table.getValInt(i) == (int)(3lu*(i + offset));
b &= table.getValShort(i) == (short)(4lu*(i + offset));
b &= table.getValUInt(i) == 5lu*(i + offset);
b &= table.getValChar(i) == (char)(i + offset);
}
return b;
}
int main(int argc, char** argv){
std::string fileName("configType.h5");
if(!testWriteData(fileName)){
std::cerr << "Cannot write file '"<<fileName<<"'" << std::endl;
return -1;
}
if(!testReadData(fileName)){
std::cerr << "Cannot read file '"<<fileName<<"'" << std::endl;
return -1;
}
return 0;
bool b(true);
b &= testWriteData(fileName);
b &= testReadData(fileName);
b &= testReadBlockData(fileName, 0lu, 10lu);
b &= testReadBlockData(fileName, 1lu, 5lu);
b &= testReadBlockData(fileName, 3lu, 4lu);
b &= testReadBlockData(fileName, 5lu, 5lu);
b &= testReadBlockData(fileName, 2lu, 8lu);
return b - 1;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment