Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixHDF5
Commits
99f63c48
Commit
99f63c48
authored
Nov 25, 2020
by
Pierre Aubert
Browse files
Add test on getRow
parent
9cd9377f
Pipeline
#92669
passed with stages
in 2 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
+8
-0
TESTS/TEST_TABLE_CONFIG/main_full.cpp
TESTS/TEST_TABLE_CONFIG/main_full.cpp
+93
-0
No files found.
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
View file @
99f63c48
...
...
@@ -12,3 +12,11 @@ add_test(NAME TestTableConfig
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_table_config
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
add_executable
(
test_table_config_full main_full.cpp
)
target_link_libraries
(
test_table_config_full test_table_config_lib
${
HDF5_CXX_LIBRARIES
}
)
add_test
(
NAME TestTableConfigFull
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_table_config_full
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
TESTS/TEST_TABLE_CONFIG/main_full.cpp
0 → 100644
View file @
99f63c48
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "configTable.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
){
TableEvent
table
;
size_t
nbRow
(
10lu
),
nbSlice
(
40lu
),
nbPixel
(
1855lu
);
table
.
setAllDim
(
nbPixel
,
nbSlice
);
table
.
resize
(
nbRow
);
//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
);
unsigned
short
*
waveform
=
table
.
getWaveform
(
i
);
for
(
size_t
j
(
0lu
);
j
<
nbSlice
;
++
j
){
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
waveform
[
j
*
nbPixel
+
k
]
=
29lu
*
(
i
*
nbRow
+
j
*
nbPixel
+
k
)
%
19lu
;
}
}
float
*
tabSignal
=
table
.
getCalibSignal
(
i
);
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
tabSignal
[
k
]
=
43lu
*
(
i
*
nbRow
+
k
)
%
17lu
;
}
}
//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
();
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
TableEvent
table
;
//Add read the file
table
.
read
(
file
);
//Now we can close the file and use the Table directly
file
.
close
();
//Get the number of rows and number of columns
size_t
nbRow
=
table
.
getNbRow
(),
nbPixel
=
table
.
getNbPixel
(),
nbSlice
=
table
.
getNbSlice
();
bool
b
(
true
);
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
size_t
eventId
(
0lu
);
double
timestamp
(
0.0
);
unsigned
short
*
waveform
=
NULL
;
float
*
tabSignal
=
NULL
;
table
.
getRow
(
i
,
eventId
,
timestamp
,
waveform
,
tabSignal
);
for
(
size_t
j
(
0lu
);
j
<
nbSlice
;
++
j
){
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
b
&=
waveform
[
j
*
nbPixel
+
k
]
==
29lu
*
(
i
*
nbRow
+
j
*
nbPixel
+
k
)
%
19lu
;
}
}
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
b
&=
tabSignal
[
k
]
==
43lu
*
(
i
*
nbRow
+
k
)
%
17lu
;
}
}
return
b
;
}
int
main
(
int
argc
,
char
**
argv
){
std
::
string
fileName
(
"configTable_full.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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment