10#include "gtest/gtest.h"
19 std::ifstream jsondata(filename);
29 FAIL() <<
"Missing expected exception.";
31 catch (
const std::exception & err)
33 std::size_t pos = std::string(err.what()).find(msg);
34 ASSERT_TRUE(pos != std::string::npos);
38TEST(GeochemicalDatabaseValidatorTest, validateTestDB)
41 FileName filename =
"database/moose_testdb.json";
42 std::ifstream jsondata(filename);
52TEST(GeochemicalDatabaseValidatorTest, missingHeader)
54 const FileName filename =
"database/faultydbs/missing_header.json";
55 const std::string msg =
56 "The MOOSE database " + filename +
" does not have a required \"Header\" field";
60TEST(GeochemicalDatabaseValidatorTest, missingTemperature)
62 const FileName filename =
"database/faultydbs/missing_temperature.json";
63 const std::string msg =
64 "The MOOSE database " + filename +
" does not have a required \"Header:temperatures\" field";
68TEST(GeochemicalDatabaseValidatorTest, missingActivityModel)
70 const FileName filename =
"database/faultydbs/missing_activity.json";
71 const std::string msg =
"The MOOSE database " + filename +
72 " does not have a required \"Header:activity model\" field";
76TEST(GeochemicalDatabaseValidatorTest, missingLogKValue)
78 const FileName filename =
"database/faultydbs/missing_value.json";
79 const std::string msg =
80 "The number of values in the logk field of secondary species CO2(aq) in " + filename +
81 " is not equal to the number of temperature values";
85TEST(GeochemicalDatabaseValidatorTest, nonRealValue)
87 const FileName filename =
"database/faultydbs/nonreal_value.json";
88 const std::string msg =
"radius value \"4.5x\" of the secondary species CO3-- in "
89 "database/faultydbs/nonreal_value.json cannot be converted to Real";
93TEST(GeochemicalDatabaseValidatorTest, nonReaArraylValue)
95 const FileName filename =
"database/faultydbs/nonreal_arrayvalue.json";
96 const std::string msg =
"Array value \"abcd\" in the logk field of mineral species Calcite in "
97 "database/faultydbs/nonreal_arrayvalue.json cannot be converted to Real";
101TEST(GeochemicalDatabaseValidatorTest, nonReaWeight)
103 const FileName filename =
"database/faultydbs/nonreal_weight.json";
104 const std::string msg =
105 "Weight value \"1.xyz\" of constituent HCO3- of the secondary species CO3-- in "
106 "database/faultydbs/nonreal_weight.json cannot be converted to Real";
110TEST(GeochemicalDatabaseValidatorTest, nonReaNeutralSpeciesArray)
112 const FileName filename =
"database/faultydbs/nonreal_neutralspecies.json";
113 const std::string msg =
"Array value \".1967cg\" in the Header:neutral species:co2:a field of " +
114 filename +
" cannot be converted to Real";
118TEST(GeochemicalDatabaseValidatorTest, missingNeutralValue)
120 const FileName filename =
"database/faultydbs/missing_neutral_value.json";
121 const std::string msg =
"The number of values in the Header:neutral species:h2o:a field of " +
122 filename +
" is not equal to the number of temperature values";
126TEST(GeochemicalDatabaseValidatorTest, noCharge)
128 const FileName filename =
"database/faultydbs/no_charge.json";
129 const std::string msg =
"The secondary species CO3-- in " + filename +
" does not have a charge";
133TEST(GeochemicalDatabaseValidatorTest, noStoichiometry)
135 const FileName filename =
"database/faultydbs/no_stoi.json";
136 const std::string msg =
"The secondary species CO3-- in " + filename +
" does not have a species";
void testExceptionMessage(const FileName filename, const std::string msg)
TEST(GeochemicalDatabaseValidatorTest, validateTestDB)
const GeochemicalDatabaseReader database("database/moose_testdb.json", true, true, false)
void validate(const FileName filename, const nlohmann::json &db)
Validate the thermodynamic database.
Class for validating MOOSE geochemical database.