Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 4dda7236 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add base config test

parent 4930bb1c
......@@ -41,14 +41,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
TableParameters 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(), nbCol = table.getNbCol();
......@@ -65,16 +61,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
TableParameters table;
//Add read the file
table.read(fileName, offset, nbRow);
//Get the number of rows and number of columns
size_t nbCol = table.getNbCol();
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getX(i) == (i + offset);
b &= table.getY(i) == 2lu*(i + offset);
float * ptrTab = table.getTabValue(i);
for(size_t j(0lu); j < nbCol; ++j){
b &= ptrTab[j] == (i + offset)*nbCol + j;
}
}
std::cout << "testReadBlockData : b = " << b << std::endl;
return b;
}
int main(int argc, char** argv){
std::string fileName("baseConfig.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