Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82426244
database_writer.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Sep 11, 08:39
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Sep 13, 08:39 (2 d)
Engine
blob
Format
Raw Data
Handle
20698874
Attached To
rSPECMICP SpecMiCP / ReactMiCP
database_writer.cpp
View Options
#include "catch.hpp"
#include "database/database.hpp"
#include "database/reader.hpp"
#include "database/writer.hpp"
#include <string>
#include <istream>
#include <sstream>
#include "str_database.hpp"
using
namespace
specmicp
;
using
namespace
specmicp
::
database
;
#include "utils/timer.hpp"
#include <iostream>
TEST_CASE
(
"Database writer"
,
"[writer]"
)
{
SECTION
(
"Good database"
)
{
Database
db_manager
;
std
::
istringstream
input
(
good_test_database
);
db_manager
.
parse_database
(
input
);
Timer
timer
;
db_manager
.
save
(
"out_test_database.js"
);
timer
.
stop
();
std
::
cout
<<
"Writing db : "
<<
timer
.
elapsed_time
()
<<
" s"
<<
std
::
endl
;
Database
db_manager2
(
"out_test_database.js"
);
RawDatabasePtr
db1
=
db_manager
.
get_database
();
RawDatabasePtr
db2
=
db_manager
.
get_database
();
REQUIRE
(
db1
->
is_valid
());
REQUIRE
(
db2
->
is_valid
());
// check taht all the species are here
CHECK
(
db1
->
components
.
get_hash
()
==
db2
->
components
.
get_hash
());
CHECK
(
db1
->
aqueous
.
get_hash
()
==
db2
->
aqueous
.
get_hash
());
CHECK
(
db1
->
minerals
.
get_hash
()
==
db2
->
minerals
.
get_hash
());
CHECK
(
db1
->
minerals_kinetic
.
get_hash
()
==
db2
->
minerals_kinetic
.
get_hash
());
CHECK
(
db1
->
gas
.
get_hash
()
==
db2
->
gas
.
get_hash
());
CHECK
(
db1
->
sorbed
.
get_hash
()
==
db2
->
sorbed
.
get_hash
());
CHECK
(
db1
->
nu_aqueous
(
db1
->
get_id_aqueous
(
"A1"
),
db1
->
get_id_component
(
"C1[-]"
))
==
db2
->
nu_aqueous
(
db2
->
get_id_aqueous
(
"A1"
),
db2
->
get_id_component
(
"C1[-]"
)));
CHECK
(
db1
->
nu_mineral
(
db1
->
get_id_mineral
(
"M2"
),
db1
->
get_id_component
(
"C2[+]"
))
==
db2
->
nu_mineral
(
db2
->
get_id_mineral
(
"M2"
),
db2
->
get_id_component
(
"C2[+]"
)));
CHECK
(
db1
->
nu_mineral_kinetic
(
db1
->
get_id_mineral_kinetic
(
"MK1"
),
db1
->
get_id_component
(
"C3"
))
==
db2
->
nu_mineral_kinetic
(
db2
->
get_id_mineral_kinetic
(
"MK1"
),
db2
->
get_id_component
(
"C3"
)));
CHECK
(
db1
->
logk_gas
(
0
)
==
db2
->
logk_gas
(
0
));
CHECK
(
db1
->
nb_sorption_sites
(
0
)
==
db2
->
nb_sorption_sites
(
0
));
}
}
Event Timeline
Log In to Comment