fpValueCheck detects (invalid) decimal ponts in exponents

This commit is contained in:
Ray Speth 2014-04-02 15:26:31 +00:00
parent 4a6dd84f81
commit 43546f870f
2 changed files with 8 additions and 0 deletions

View file

@ -79,6 +79,10 @@ class TestThermoPhase(utilities.CanteraTest):
self.phase.X = 'H2:1e-x4'
self.assertArrayNear(X0, self.phase.X)
with self.assertRaises(Exception):
self.phase.X = 'H2:1e-1.4'
self.assertArrayNear(X0, self.phase.X)
def test_report(self):
report = self.phase.report()
self.assertTrue(self.phase.name in report)

View file

@ -252,6 +252,10 @@ doublereal fpValueCheck(const std::string& val)
throw CanteraError("fpValueCheck",
"string has more than one .");
}
if (numExp > 0) {
throw CanteraError("fpValueCheck",
"string has decimal point in exponent");
}
} else if (ch == 'e' || ch == 'E' || ch == 'd' || ch == 'D') {
numExp++;
str[i] = 'E';