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

Commit ec8b2219 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add test on tensor with fixed size

parent a900bca6
Pipeline #93314 passed with stages
in 4 minutes and 21 seconds
......@@ -13,4 +13,6 @@ add_subdirectory(TEST_BASE_CONFIG)
cmake_minimum_required(VERSION 2.8)
call_generator(test_table_config_fixed_size_lib configTableFixedSize.ph5)
add_executable(test_table_config_fixed_size main.cpp)
target_link_libraries(test_table_config_fixed_size test_table_config_fixed_size_lib ${HDF5_CXX_LIBRARIES})
add_test(NAME TestTableConfigFixedSize
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_table_config_fixed_size
///Table of types
///Event id
size_t eventId;
double timestamp;
///Short value
Tensor(float, 3) tabVertex;
Auteur : Pierre Aubert
Mail :
Licence : CeCILL-C
#include "configTableFixedSize.h"
///Test to write data
/** @param fileName : name of the file to be written
* @return true on success, false otherwise
bool testWriteData(const std::string & fileName){
TableVertex table;
size_t nbRow(10lu);
//Let's set some values in the Table
for(size_t i(0lu); i < nbRow; ++i){
table.setEventId(i, i);
table.setTimestamp(i, 2lu*i);
float * tabVertex = table.getTabVertex(i);
tabVertex[0lu] = i;
tabVertex[1lu] = 2lu*i;
tabVertex[2lu] = 3lu*i;
//Now let's open a file
H5::H5File file(fileName, H5F_ACC_TRUNC);
//And write our table directly in it
//We can also explicitly cloase the file, otherwise it will do it automatically
return true;
///Test to read data
/** @param fileName : name of the file to be read
* @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;
//Now we can close the file and use the Table directly
//Get the number of rows and number of columns
size_t nbRow = table.getNbRow();
bool b(true);
for(size_t i(0lu); i < nbRow; ++i){
b &= table.getEventId(i) == i;
b &= table.getTimestamp(i) == 2lu*i;
float * tabVertex = table.getTabVertex(i);
b &= tabVertex[0lu] == i;
b &= tabVertex[1lu] == 2lu*i;
b &= tabVertex[2lu] == 3lu*i;
return b;
int main(int argc, char** argv){
std::string fileName("configTable.h5");
std::cerr << "Cannot write file '"<<fileName<<"'" << std::endl;
return -1;
std::cerr << "Cannot read file '"<<fileName<<"'" << std::endl;
return -1;
return 0;
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