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
4dda7236
Commit
4dda7236
authored
Jan 27, 2021
by
Pierre Aubert
Browse files
Add base config test
parent
4930bb1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
14 deletions
+38
-14
TESTS/TEST_BASE_CONFIG/main.cpp
TESTS/TEST_BASE_CONFIG/main.cpp
+38
-14
No files found.
TESTS/TEST_BASE_CONFIG/main.cpp
View file @
4dda7236
...
...
@@ -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
&=
testRead
Block
Data
(
fileName
,
1lu
,
5lu
);
b
&=
testReadBlockData
(
fileName
,
3lu
,
4lu
)
;
b
&=
testReadBlockData
(
fileName
,
5lu
,
5lu
)
;
b
&=
testReadBlockData
(
fileName
,
2lu
,
8lu
);
return
b
-
1
;
}
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