[Thermo] Check composition strings for invalid float literals
This commit is contained in:
parent
14fe11d661
commit
4a6dd84f81
2 changed files with 12 additions and 2 deletions
|
|
@ -69,6 +69,16 @@ class TestThermoPhase(utilities.CanteraTest):
|
|||
|
||||
self.assertRaises(Exception, set_bad)
|
||||
|
||||
def test_setCompositionStringBad(self):
|
||||
X0 = self.phase.X
|
||||
with self.assertRaises(Exception):
|
||||
self.phase.X = 'H2:1.0, O2:asdf'
|
||||
self.assertArrayNear(X0, self.phase.X)
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
self.phase.X = 'H2:1e-x4'
|
||||
self.assertArrayNear(X0, self.phase.X)
|
||||
|
||||
def test_report(self):
|
||||
report = self.phase.report()
|
||||
self.assertTrue(self.phase.name in report)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ compositionMap parseCompString(const std::string& ss,
|
|||
if (icolon != std::string::npos) {
|
||||
std::string name = stripws(s.substr(0, icolon));
|
||||
if (iend != std::string::npos) {
|
||||
num = s.substr(icolon+1, iend-icolon);
|
||||
num = s.substr(icolon+1, iend-icolon-1);
|
||||
s = s.substr(iend+1, s.size());
|
||||
} else {
|
||||
num = s.substr(icolon+1, s.size());
|
||||
|
|
@ -146,7 +146,7 @@ compositionMap parseCompString(const std::string& ss,
|
|||
throw CanteraError("parseCompString",
|
||||
"unknown species " + name);
|
||||
}
|
||||
x[name] = fpValue(num);
|
||||
x[name] = fpValueCheck(num);
|
||||
} else {
|
||||
s = "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue