From 43546f870f1b372f6bdc83325c60dab53a1cbbe8 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 2 Apr 2014 15:26:31 +0000 Subject: [PATCH] fpValueCheck detects (invalid) decimal ponts in exponents --- interfaces/cython/cantera/test/test_thermo.py | 4 ++++ src/base/stringUtils.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 5c101a9ff..9811c0966 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -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) diff --git a/src/base/stringUtils.cpp b/src/base/stringUtils.cpp index f014eecbd..94a433afc 100644 --- a/src/base/stringUtils.cpp +++ b/src/base/stringUtils.cpp @@ -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';