Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GeoModel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GeoModelDev
GeoModel
Commits
e0245cbe
Commit
e0245cbe
authored
10 months ago
by
Riccardo Maria Bianchi
Committed by
Johannes Junggeburth
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean I/O tests and add better log messages
parent
f0c4a340
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!327
New schema for the GeoModel SQLite database and updated I/O
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMTests_IO.h
+23
-27
23 additions, 27 deletions
GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMTests_IO.h
with
23 additions
and
27 deletions
GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMTests_IO.h
+
23
−
27
View file @
e0245cbe
...
@@ -41,39 +41,26 @@ class TestIO {
...
@@ -41,39 +41,26 @@ class TestIO {
const
std
::
string
db1_name
=
"geometry_db_test_1.db"
;
const
std
::
string
db1_name
=
"geometry_db_test_1.db"
;
const
std
::
string
db2_name
=
"geometry_db_test_2.db"
;
const
std
::
string
db2_name
=
"geometry_db_test_2.db"
;
//-----------------------------------------------//
std
::
cout
<<
"1 -- Writing the geometry to file - 1st time"
<<
std
::
endl
;
// 1 -- Writing the geometry to file - 1st time
//-----------------------------------------------//
GMDBManager
db1
=
GeoModelIO
::
IO
::
saveToDB
(
world
,
db1_name
,
loglevel
,
forceDelete
);
GMDBManager
db1
=
GeoModelIO
::
IO
::
saveToDB
(
world
,
db1_name
,
loglevel
,
forceDelete
);
//-----------------------------------------------//
std
::
cout
<<
"2 -- Get number of nodes from the DB we just saved"
<<
std
::
endl
;
// 2 -- Get number of nodes from the DB we just saved
//-----------------------------------------------//
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_1
=
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_1
=
GeoModelIO
::
IO
::
countNodesFromDB
(
db1
);
GeoModelIO
::
IO
::
countNodesFromDB
(
db1
);
//-----------------------------------------------//
std
::
cout
<<
"3 -- Reading back the geometry from file"
<<
std
::
endl
;
// 3 -- Reading back the geometry from file
//-----------------------------------------------//
const
GeoVPhysVol
*
world2
=
GeoModelIO
::
IO
::
loadDB
(
db1_name
,
loglevel
);
const
GeoVPhysVol
*
world2
=
GeoModelIO
::
IO
::
loadDB
(
db1_name
,
loglevel
);
//-----------------------------------------------//
std
::
cout
<<
"4 -- Writing the geometry to file - 2nd time"
<<
std
::
endl
;
// 4 -- Writing the geometry to file - 2nd time
//-----------------------------------------------//
GMDBManager
db2
=
GeoModelIO
::
IO
::
saveToDB
(
world2
,
db2_name
,
loglevel
,
forceDelete
);
GMDBManager
db2
=
GeoModelIO
::
IO
::
saveToDB
(
world2
,
db2_name
,
loglevel
,
forceDelete
);
//-----------------------------------------------//
std
::
cout
<<
"5 -- Get number of nodes from the DB we created from the restored GeoModel tree"
<<
std
::
endl
;
// 5 -- Get number of nodes from the DB we created from the restored
// GeoModel tree
//-----------------------------------------------//
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_2
=
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_2
=
GeoModelIO
::
IO
::
countNodesFromDB
(
db2
);
GeoModelIO
::
IO
::
countNodesFromDB
(
db2
);
//-----------------------------------------------//
std
::
cout
<<
"6 -- Comparison"
<<
std
::
endl
;
// 6 -- Comparison
//-----------------------------------------------//
bool
testok
=
false
;
bool
testok
=
false
;
GeoModelIO
::
IO
::
checkTwoNodesMapsSameSize
(
mmap_1
,
mmap_2
);
if
(
mmap_1
==
mmap_2
)
{
if
(
mmap_1
==
mmap_2
)
{
if
(
loglevel
>=
1
)
{
if
(
loglevel
>=
1
)
{
std
::
cout
std
::
cout
...
@@ -94,6 +81,7 @@ class TestIO {
...
@@ -94,6 +81,7 @@ class TestIO {
if
(
loglevel
>=
2
)
{
if
(
loglevel
>=
2
)
{
GeoModelIO
::
IO
::
printCompareTwoNodesMaps
(
mmap_1
,
mmap_2
);
GeoModelIO
::
IO
::
printCompareTwoNodesMaps
(
mmap_1
,
mmap_2
);
}
}
GeoModelIO
::
IO
::
printDifferencesBetweenTwoNodesMaps
(
mmap_1
,
mmap_2
);
std
::
cout
<<
"----
\n
"
;
std
::
cout
<<
"----
\n
"
;
}
}
testok
=
false
;
testok
=
false
;
...
@@ -140,6 +128,7 @@ class TestIO {
...
@@ -140,6 +128,7 @@ class TestIO {
// TODO: add number-by-number comparison as with the other tests!!
// TODO: add number-by-number comparison as with the other tests!!
bool
testok
=
false
;
bool
testok
=
false
;
GeoModelIO
::
IO
::
checkTwoNodesMapsSameSize
(
mmap_1
,
mmap_2
);
if
(
mmap_1
==
mmap_2
)
{
if
(
mmap_1
==
mmap_2
)
{
if
(
loglevel
>=
1
)
{
if
(
loglevel
>=
1
)
{
std
::
cout
<<
"OK! The number of starting in-memory nodes is "
std
::
cout
<<
"OK! The number of starting in-memory nodes is "
...
@@ -151,15 +140,16 @@ class TestIO {
...
@@ -151,15 +140,16 @@ class TestIO {
}
else
{
}
else
{
if
(
loglevel
>=
1
)
{
if
(
loglevel
>=
1
)
{
std
::
cout
std
::
cout
<<
"!!! ERROR !!! The number of t
e
h starting in-memory "
<<
"!!! ERROR !!! The number of th
e
starting in-memory "
"nodes is DIFFERENT from "
"nodes is DIFFERENT from "
"the number of the restored in-memory nodes!!!
\n
"
;
"the number of the restored in-memory nodes!!!
\n
"
;
if
(
loglevel
>=
2
)
{
if
(
loglevel
>=
2
)
{
std
::
cout
<<
"Starting in-memory nodes:
\n
"
;
std
::
cout
<<
"
***
Starting in-memory nodes:
\n
"
;
GeoModelIO
::
IO
::
printNodesMap
(
mmap_1
);
GeoModelIO
::
IO
::
printNodesMap
(
mmap_1
);
std
::
cout
<<
"Restored in-memory nodes:
\n
"
;
std
::
cout
<<
"
***
Restored in-memory nodes:
\n
"
;
GeoModelIO
::
IO
::
printNodesMap
(
mmap_2
);
GeoModelIO
::
IO
::
printNodesMap
(
mmap_2
);
}
}
GeoModelIO
::
IO
::
printDifferencesBetweenTwoNodesMaps
(
mmap_1
,
mmap_2
);
std
::
cout
<<
"----
\n
"
;
std
::
cout
<<
"----
\n
"
;
}
}
testok
=
false
;
testok
=
false
;
...
@@ -196,6 +186,7 @@ class TestIO {
...
@@ -196,6 +186,7 @@ class TestIO {
read
.
setLogLevel
(
loglevel
);
read
.
setLogLevel
(
loglevel
);
}
}
// load the data from the DB
// load the data from the DB
std
::
cout
<<
"-- 1: load data from the DB"
<<
std
::
endl
;
read
.
loadDB
();
read
.
loadDB
();
// count all nodes loaded from the DB by the Read action
// count all nodes loaded from the DB by the Read action
...
@@ -205,14 +196,16 @@ class TestIO {
...
@@ -205,14 +196,16 @@ class TestIO {
GeoModelIO
::
IO
::
countLoadedNodesFromReadAction
(
read
);
GeoModelIO
::
IO
::
countLoadedNodesFromReadAction
(
read
);
// build the GeoModel tree from the loaded nodes
// build the GeoModel tree from the loaded nodes
std
::
cout
<<
"-- 2: build the GeoModel tree and restore it into memory"
<<
std
::
endl
;
const
GeoVPhysVol
*
rootVolume
=
read
.
buildGeoModel
();
const
GeoVPhysVol
*
rootVolume
=
read
.
buildGeoModel
();
// count the number of all
the
restored nodes;
// count the number of all restored nodes;
// i.e., the nodes of the restored in-memory GeoModel tree
// i.e., the nodes of the restored in-memory GeoModel tree
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_restored
=
std
::
map
<
std
::
string
,
unsigned
long
>
mmap_restored
=
GeoModelIO
::
IO
::
countTreeMemoryNodesFromVolume
(
rootVolume
);
GeoModelIO
::
IO
::
countTreeMemoryNodesFromVolume
(
rootVolume
);
bool
testok
=
false
;
bool
testok
=
false
;
GeoModelIO
::
IO
::
checkTwoNodesMapsSameSize
(
mmap_loaded
,
mmap_restored
);
if
(
mmap_loaded
==
mmap_restored
)
{
if
(
mmap_loaded
==
mmap_restored
)
{
if
(
loglevel
>=
1
)
{
if
(
loglevel
>=
1
)
{
std
::
cout
<<
"OK! The number of loaded nodes is equal to the "
std
::
cout
<<
"OK! The number of loaded nodes is equal to the "
...
@@ -225,11 +218,13 @@ class TestIO {
...
@@ -225,11 +218,13 @@ class TestIO {
"DIFFERENT from "
"DIFFERENT from "
"the number of restored nodes!!!
\n
"
;
"the number of restored nodes!!!
\n
"
;
if
(
loglevel
>=
2
)
{
if
(
loglevel
>=
2
)
{
std
::
cout
<<
"Loaded:
\n
"
;
std
::
cout
<<
"
\n
*** --
Loaded:
\n
"
;
GeoModelIO
::
IO
::
printNodesMap
(
mmap_loaded
);
GeoModelIO
::
IO
::
printNodesMap
(
mmap_loaded
);
std
::
cout
<<
"Restored:
\n
"
;
std
::
cout
<<
"
\n
*** --
Restored:
\n
"
;
GeoModelIO
::
IO
::
printNodesMap
(
mmap_restored
);
GeoModelIO
::
IO
::
printNodesMap
(
mmap_restored
);
}
}
GeoModelIO
::
IO
::
printDifferencesBetweenTwoNodesMaps
(
mmap_loaded
,
mmap_restored
);
std
::
cout
<<
"----
\n
"
;
}
}
testok
=
false
;
testok
=
false
;
}
}
...
@@ -275,7 +270,8 @@ class TestIO {
...
@@ -275,7 +270,8 @@ class TestIO {
std
::
cout
<<
"Single results:
\n
"
;
std
::
cout
<<
"Single results:
\n
"
;
for
(
auto
&
tt
:
tests
.
second
)
{
for
(
auto
&
tt
:
tests
.
second
)
{
std
::
cout
<<
"test: '"
<<
tt
.
first
<<
"' ==> "
<<
tt
.
second
std
::
cout
<<
"test: '"
<<
tt
.
first
<<
"' ==> "
<<
tt
.
second
<<
" ["
<<
(
testall
?
"PASSED."
:
"FAILED!"
)
<<
"]"
<<
" ["
<<
(
tt
.
second
?
"PASSED."
:
"FAILED!"
)
<<
"]"
<<
" -- [overall: "
<<
(
testall
?
"PASSED."
:
"FAILED!"
)
<<
"]"
<<
std
::
endl
;
<<
std
::
endl
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment