From b88846e5e03352c101ad98875ca864bf9016c03b Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 9 Jan 2012 17:35:28 +0000 Subject: [PATCH] Fixed C++ tests that were failing under Windows Visual Studio defaults to 3-digit exponents when printing in scientific notation. The tests now use a MSVC-specific function to change this behavior when necessary. --- test_problems/ChemEquil_gri_matrix/gri_matrix.cpp | 3 +++ test_problems/ChemEquil_gri_pairs/gri_pairs.cpp | 3 +++ test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp | 3 +++ test_problems/ChemEquil_red1/basopt_red1.cpp | 3 +++ test_problems/CpJump/CpJump.cpp | 3 +++ test_problems/NASA9poly_test/NASA9poly_test.cpp | 4 +++- test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp | 3 +++ test_problems/VPsilane_test/silane_equil.cpp | 3 +++ test_problems/cathermo/HMW_test_1/HMW_test_1.cpp | 4 +++- test_problems/cathermo/HMW_test_3/HMW_test_3.cpp | 4 ++++ test_problems/cathermo/VPissp/ISSPTester.cpp | 5 ++++- test_problems/cathermo/ims/IMSTester.cpp | 3 +++ test_problems/cathermo/issp/ISSPTester.cpp | 3 +++ test_problems/cathermo/testIAPWS/testIAPWSphi.cpp | 4 +++- test_problems/cathermo/testIAPWSPres/testPress.cpp | 4 +++- test_problems/cathermo/testIAPWSTripP/testTripleP.cpp | 4 +++- test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp | 4 +++- test_problems/cathermo/testWaterTP/testWaterSSTP.cpp | 4 +++- test_problems/cxx_ex/examples.cpp | 4 +++- test_problems/diamondSurf/runDiamond.cpp | 3 +++ test_problems/fracCoeff/fracCoeff.cpp | 3 +++ test_problems/min_python/minDiamond/runDiamond.cpp | 3 +++ test_problems/min_python/negATest/negATest.cpp | 3 +++ test_problems/mixGasTransport/mixGasTransport.cpp | 3 +++ test_problems/multiGasTransport/multiGasTransport.cpp | 3 +++ test_problems/negATest/negATest.cpp | 3 +++ test_problems/printUtilUnitTest/pUtest.cpp | 4 +++- test_problems/pureFluidTest/testPureWater.cpp | 4 +++- test_problems/rankine_democxx/rankine.cpp | 3 +++ test_problems/silane_equil/silane_equil.cpp | 3 +++ test_problems/surfSolverTest/surfaceSolver.cpp | 3 +++ tools/src/ck2cti.cpp | 3 +++ 32 files changed, 98 insertions(+), 11 deletions(-) diff --git a/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp b/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp index abc43a00d..2475076a2 100644 --- a/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp +++ b/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp @@ -11,6 +11,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int numSucc = 0; int numFail = 0; try { diff --git a/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp b/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp index 5ea1b9952..c13c29f0a 100644 --- a/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp +++ b/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp @@ -18,6 +18,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { IdealGasMix g("gri30.xml", "gri30_mix"); double pres = 1.0E5; diff --git a/test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp b/test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp index f0d614a9b..e778b5b24 100644 --- a/test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp +++ b/test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp @@ -15,6 +15,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif #ifdef DEBUG_CHEMEQUIL ChemEquil_print_lvl = 0; #endif diff --git a/test_problems/ChemEquil_red1/basopt_red1.cpp b/test_problems/ChemEquil_red1/basopt_red1.cpp index d24d118d1..4143020f8 100644 --- a/test_problems/ChemEquil_red1/basopt_red1.cpp +++ b/test_problems/ChemEquil_red1/basopt_red1.cpp @@ -7,6 +7,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { IdealGasMix g("red1.xml", "gri30_mix"); diff --git a/test_problems/CpJump/CpJump.cpp b/test_problems/CpJump/CpJump.cpp index 0a1f6b215..5a044f432 100644 --- a/test_problems/CpJump/CpJump.cpp +++ b/test_problems/CpJump/CpJump.cpp @@ -18,6 +18,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { IdealGasMix g("bad_air.xml", "air"); double pres = 1.0E5; diff --git a/test_problems/NASA9poly_test/NASA9poly_test.cpp b/test_problems/NASA9poly_test/NASA9poly_test.cpp index 55a2acdcd..f28bc6ff3 100644 --- a/test_problems/NASA9poly_test/NASA9poly_test.cpp +++ b/test_problems/NASA9poly_test/NASA9poly_test.cpp @@ -38,7 +38,9 @@ void printDbl(double val) { } int main(int argc, char** argv) { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { diff --git a/test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp b/test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp index 58f87c4cf..346ad99dd 100644 --- a/test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp +++ b/test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp @@ -26,6 +26,9 @@ void printUsage() { } int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif // int solver = 2; int numSucc = 0; int numFail = 0; diff --git a/test_problems/VPsilane_test/silane_equil.cpp b/test_problems/VPsilane_test/silane_equil.cpp index 19ac1679b..d305f6693 100644 --- a/test_problems/VPsilane_test/silane_equil.cpp +++ b/test_problems/VPsilane_test/silane_equil.cpp @@ -13,6 +13,9 @@ using namespace std; using namespace Cantera; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { PrintCtrl::GlobalCrop = PrintCtrl::GCT_CROP; Cantera::IdealSolnGasVPSS gg("silane.xml", "silane"); diff --git a/test_problems/cathermo/HMW_test_1/HMW_test_1.cpp b/test_problems/cathermo/HMW_test_1/HMW_test_1.cpp index 6da12279a..9a9e73e23 100644 --- a/test_problems/cathermo/HMW_test_1/HMW_test_1.cpp +++ b/test_problems/cathermo/HMW_test_1/HMW_test_1.cpp @@ -48,7 +48,9 @@ void pAtable(HMWSoln *HMW) { int main(int argc, char **argv) { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int retn = 0; try { diff --git a/test_problems/cathermo/HMW_test_3/HMW_test_3.cpp b/test_problems/cathermo/HMW_test_3/HMW_test_3.cpp index 71848f402..dc8d3eb7b 100644 --- a/test_problems/cathermo/HMW_test_3/HMW_test_3.cpp +++ b/test_problems/cathermo/HMW_test_3/HMW_test_3.cpp @@ -49,6 +49,10 @@ void pAtable(HMWSoln *HMW) { int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + int retn = 0; try { diff --git a/test_problems/cathermo/VPissp/ISSPTester.cpp b/test_problems/cathermo/VPissp/ISSPTester.cpp index e9ced744a..d1f12bf7e 100644 --- a/test_problems/cathermo/VPissp/ISSPTester.cpp +++ b/test_problems/cathermo/VPissp/ISSPTester.cpp @@ -44,7 +44,10 @@ static void printUsage() using namespace Cantera; int main(int argc, char** argv) { - string infile; +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + string infile; // look for command-line options if (argc > 1) { string tok; diff --git a/test_problems/cathermo/ims/IMSTester.cpp b/test_problems/cathermo/ims/IMSTester.cpp index 686a5267e..cd0cde7b6 100644 --- a/test_problems/cathermo/ims/IMSTester.cpp +++ b/test_problems/cathermo/ims/IMSTester.cpp @@ -47,6 +47,9 @@ static void printUsage() using namespace Cantera; int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif string infile; // look for command-line options if (argc > 1) { diff --git a/test_problems/cathermo/issp/ISSPTester.cpp b/test_problems/cathermo/issp/ISSPTester.cpp index 00d2c33cb..2ec73868c 100644 --- a/test_problems/cathermo/issp/ISSPTester.cpp +++ b/test_problems/cathermo/issp/ISSPTester.cpp @@ -47,6 +47,9 @@ static void printUsage() using namespace Cantera; int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif string infile; // look for command-line options if (argc > 1) { diff --git a/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp b/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp index 64171e746..3d32048db 100644 --- a/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp +++ b/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp @@ -7,7 +7,9 @@ using namespace std; int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif WaterPropsIAPWSphi *phi = new WaterPropsIAPWSphi(); phi->check1(); diff --git a/test_problems/cathermo/testIAPWSPres/testPress.cpp b/test_problems/cathermo/testIAPWSPres/testPress.cpp index 3b084e4f6..933951038 100644 --- a/test_problems/cathermo/testIAPWSPres/testPress.cpp +++ b/test_problems/cathermo/testIAPWSPres/testPress.cpp @@ -20,7 +20,9 @@ double numdpdt(WaterPropsIAPWS *water, double T, double pres) { } int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif double dens, u, s, h; WaterPropsIAPWS *water = new WaterPropsIAPWS(); diff --git a/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp b/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp index f31a7faf0..f5bed6b56 100644 --- a/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp +++ b/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp @@ -9,7 +9,9 @@ using namespace std; using namespace Cantera; int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif double dens, u, s, h, cv, cp, pres; WaterPropsIAPWS *water = new WaterPropsIAPWS(); diff --git a/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp b/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp index 144ac791e..512ecaf3d 100644 --- a/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp +++ b/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp @@ -23,7 +23,9 @@ double tvalue(double val, double atol = 1.0E-9) { } int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif double pres; try { Cantera::VPStandardStateTP *nnn = 0; diff --git a/test_problems/cathermo/testWaterTP/testWaterSSTP.cpp b/test_problems/cathermo/testWaterTP/testWaterSSTP.cpp index c134b56f6..f564fdc9b 100644 --- a/test_problems/cathermo/testWaterTP/testWaterSSTP.cpp +++ b/test_problems/cathermo/testWaterTP/testWaterSSTP.cpp @@ -21,7 +21,9 @@ double tvalue(double val, double atol = 1.0E-9) { int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif double pres; try { WaterSSTP *w = new WaterSSTP("waterTPphase.xml",""); diff --git a/test_problems/cxx_ex/examples.cpp b/test_problems/cxx_ex/examples.cpp index d33460d72..b4f7c8c7e 100755 --- a/test_problems/cxx_ex/examples.cpp +++ b/test_problems/cxx_ex/examples.cpp @@ -37,7 +37,9 @@ exfun fex[] = {kinetics_example1, kinetics_example2, kinetics_example3, // main program int main(int argc, char** argv) { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int example_num = 0; cout << endl << "-----------------------------------" << endl diff --git a/test_problems/diamondSurf/runDiamond.cpp b/test_problems/diamondSurf/runDiamond.cpp index 0b33f321e..e56674078 100644 --- a/test_problems/diamondSurf/runDiamond.cpp +++ b/test_problems/diamondSurf/runDiamond.cpp @@ -41,6 +41,9 @@ void printDbl(double val) { } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int i, k; string infile = "diamond.xml"; diff --git a/test_problems/fracCoeff/fracCoeff.cpp b/test_problems/fracCoeff/fracCoeff.cpp index e32e1aded..5c7881748 100644 --- a/test_problems/fracCoeff/fracCoeff.cpp +++ b/test_problems/fracCoeff/fracCoeff.cpp @@ -50,6 +50,9 @@ void printDbl(double val) { } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int i, k; string infile = "frac.xml"; double x[10], kc[10]; diff --git a/test_problems/min_python/minDiamond/runDiamond.cpp b/test_problems/min_python/minDiamond/runDiamond.cpp index bb73575fb..75c8d082f 100644 --- a/test_problems/min_python/minDiamond/runDiamond.cpp +++ b/test_problems/min_python/minDiamond/runDiamond.cpp @@ -41,6 +41,9 @@ void printDbl(double val) { } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int i, k; string infile = "diamond.cti"; diff --git a/test_problems/min_python/negATest/negATest.cpp b/test_problems/min_python/negATest/negATest.cpp index bde06dfc4..2ea7f737f 100644 --- a/test_problems/min_python/negATest/negATest.cpp +++ b/test_problems/min_python/negATest/negATest.cpp @@ -16,6 +16,9 @@ using namespace std; # int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { int i; string infile = "noxNeg.cti"; diff --git a/test_problems/mixGasTransport/mixGasTransport.cpp b/test_problems/mixGasTransport/mixGasTransport.cpp index f742a0f17..8f4119dbd 100644 --- a/test_problems/mixGasTransport/mixGasTransport.cpp +++ b/test_problems/mixGasTransport/mixGasTransport.cpp @@ -50,6 +50,9 @@ void printDbl(double val) { } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int k; string infile = "diamond.xml"; diff --git a/test_problems/multiGasTransport/multiGasTransport.cpp b/test_problems/multiGasTransport/multiGasTransport.cpp index e2f6ddc9e..4880ec637 100644 --- a/test_problems/multiGasTransport/multiGasTransport.cpp +++ b/test_problems/multiGasTransport/multiGasTransport.cpp @@ -57,6 +57,9 @@ static double cutoff (double val, double atol=1.0E-15) { } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif int k; string infile = "diamond.xml"; diff --git a/test_problems/negATest/negATest.cpp b/test_problems/negATest/negATest.cpp index 58e3198af..0b8f0403a 100644 --- a/test_problems/negATest/negATest.cpp +++ b/test_problems/negATest/negATest.cpp @@ -8,6 +8,9 @@ using namespace Cantera; using namespace std; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { int i; std::string infile = "noxNeg.xml"; diff --git a/test_problems/printUtilUnitTest/pUtest.cpp b/test_problems/printUtilUnitTest/pUtest.cpp index 99b35ce9d..9e7df53df 100644 --- a/test_problems/printUtilUnitTest/pUtest.cpp +++ b/test_problems/printUtilUnitTest/pUtest.cpp @@ -284,7 +284,9 @@ void doLogger() { } int main() { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif // How to connect to a file: // ofstream fff("redirect.txt"); // ostream ffs(fff.rdbuf()); diff --git a/test_problems/pureFluidTest/testPureWater.cpp b/test_problems/pureFluidTest/testPureWater.cpp index 18883d38d..b4b6f3db3 100644 --- a/test_problems/pureFluidTest/testPureWater.cpp +++ b/test_problems/pureFluidTest/testPureWater.cpp @@ -18,7 +18,9 @@ double tvalue(double val, double atol = 1.0E-9) { int main () { - +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif double pres; try { diff --git a/test_problems/rankine_democxx/rankine.cpp b/test_problems/rankine_democxx/rankine.cpp index ebbd92036..78f99cc81 100644 --- a/test_problems/rankine_democxx/rankine.cpp +++ b/test_problems/rankine_democxx/rankine.cpp @@ -78,6 +78,9 @@ int openRankine(int np, void* p) { } int main() { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { return openRankine(0, 0); } diff --git a/test_problems/silane_equil/silane_equil.cpp b/test_problems/silane_equil/silane_equil.cpp index 145b6dcb6..dd697ad02 100644 --- a/test_problems/silane_equil/silane_equil.cpp +++ b/test_problems/silane_equil/silane_equil.cpp @@ -18,6 +18,9 @@ using namespace Cantera; using namespace Cantera_CXX; int main(int argc, char **argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif try { IdealGasMix g("silane.xml", "silane"); g.setState_TPX(1500.0, 100.0, "SIH4:0.01, H2:0.99"); diff --git a/test_problems/surfSolverTest/surfaceSolver.cpp b/test_problems/surfSolverTest/surfaceSolver.cpp index 3474a45e5..fd0467fa6 100644 --- a/test_problems/surfSolverTest/surfaceSolver.cpp +++ b/test_problems/surfSolverTest/surfaceSolver.cpp @@ -157,6 +157,9 @@ void printSurf(ostream &oooo, } int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif string infile; int ioflag = 1; int i, k; diff --git a/tools/src/ck2cti.cpp b/tools/src/ck2cti.cpp index 763721bfd..b53f1bc3b 100644 --- a/tools/src/ck2cti.cpp +++ b/tools/src/ck2cti.cpp @@ -77,6 +77,9 @@ string getp(int& i, int argc, char** args) { int main(int argc, char** argv) { +#ifdef _MSC_VER + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif string infile="chem.inp", dbfile="", trfile="", logfile; string idtag = "gas"; bool debug = false;