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.
This commit is contained in:
Ray Speth 2012-01-09 17:35:28 +00:00
parent 7ac1cb4dd4
commit b88846e5e0
32 changed files with 98 additions and 11 deletions

View file

@ -11,6 +11,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int numSucc = 0; int numSucc = 0;
int numFail = 0; int numFail = 0;
try { try {

View file

@ -18,6 +18,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
IdealGasMix g("gri30.xml", "gri30_mix"); IdealGasMix g("gri30.xml", "gri30_mix");
double pres = 1.0E5; double pres = 1.0E5;

View file

@ -15,6 +15,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
#ifdef DEBUG_CHEMEQUIL #ifdef DEBUG_CHEMEQUIL
ChemEquil_print_lvl = 0; ChemEquil_print_lvl = 0;
#endif #endif

View file

@ -7,6 +7,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
IdealGasMix g("red1.xml", "gri30_mix"); IdealGasMix g("red1.xml", "gri30_mix");

View file

@ -18,6 +18,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
IdealGasMix g("bad_air.xml", "air"); IdealGasMix g("bad_air.xml", "air");
double pres = 1.0E5; double pres = 1.0E5;

View file

@ -38,7 +38,9 @@ void printDbl(double val) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {

View file

@ -26,6 +26,9 @@ void printUsage() {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
// int solver = 2; // int solver = 2;
int numSucc = 0; int numSucc = 0;
int numFail = 0; int numFail = 0;

View file

@ -13,6 +13,9 @@ using namespace std;
using namespace Cantera; using namespace Cantera;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
PrintCtrl::GlobalCrop = PrintCtrl::GCT_CROP; PrintCtrl::GlobalCrop = PrintCtrl::GCT_CROP;
Cantera::IdealSolnGasVPSS gg("silane.xml", "silane"); Cantera::IdealSolnGasVPSS gg("silane.xml", "silane");

View file

@ -48,7 +48,9 @@ void pAtable(HMWSoln *HMW) {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int retn = 0; int retn = 0;
try { try {

View file

@ -49,6 +49,10 @@ void pAtable(HMWSoln *HMW) {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int retn = 0; int retn = 0;
try { try {

View file

@ -44,7 +44,10 @@ static void printUsage()
using namespace Cantera; using namespace Cantera;
int main(int argc, char** argv) { 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 // look for command-line options
if (argc > 1) { if (argc > 1) {
string tok; string tok;

View file

@ -47,6 +47,9 @@ static void printUsage()
using namespace Cantera; using namespace Cantera;
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile; string infile;
// look for command-line options // look for command-line options
if (argc > 1) { if (argc > 1) {

View file

@ -47,6 +47,9 @@ static void printUsage()
using namespace Cantera; using namespace Cantera;
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile; string infile;
// look for command-line options // look for command-line options
if (argc > 1) { if (argc > 1) {

View file

@ -7,7 +7,9 @@
using namespace std; using namespace std;
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
WaterPropsIAPWSphi *phi = new WaterPropsIAPWSphi(); WaterPropsIAPWSphi *phi = new WaterPropsIAPWSphi();
phi->check1(); phi->check1();

View file

@ -20,7 +20,9 @@ double numdpdt(WaterPropsIAPWS *water, double T, double pres) {
} }
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double dens, u, s, h; double dens, u, s, h;
WaterPropsIAPWS *water = new WaterPropsIAPWS(); WaterPropsIAPWS *water = new WaterPropsIAPWS();

View file

@ -9,7 +9,9 @@ using namespace std;
using namespace Cantera; using namespace Cantera;
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double dens, u, s, h, cv, cp, pres; double dens, u, s, h, cv, cp, pres;
WaterPropsIAPWS *water = new WaterPropsIAPWS(); WaterPropsIAPWS *water = new WaterPropsIAPWS();

View file

@ -23,7 +23,9 @@ double tvalue(double val, double atol = 1.0E-9) {
} }
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres; double pres;
try { try {
Cantera::VPStandardStateTP *nnn = 0; Cantera::VPStandardStateTP *nnn = 0;

View file

@ -21,7 +21,9 @@ double tvalue(double val, double atol = 1.0E-9) {
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres; double pres;
try { try {
WaterSSTP *w = new WaterSSTP("waterTPphase.xml",""); WaterSSTP *w = new WaterSSTP("waterTPphase.xml","");

View file

@ -37,7 +37,9 @@ exfun fex[] = {kinetics_example1, kinetics_example2, kinetics_example3,
// main program // main program
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int example_num = 0; int example_num = 0;
cout << endl cout << endl
<< "-----------------------------------" << endl << "-----------------------------------" << endl

View file

@ -41,6 +41,9 @@ void printDbl(double val) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int i, k; int i, k;
string infile = "diamond.xml"; string infile = "diamond.xml";

View file

@ -50,6 +50,9 @@ void printDbl(double val) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int i, k; int i, k;
string infile = "frac.xml"; string infile = "frac.xml";
double x[10], kc[10]; double x[10], kc[10];

View file

@ -41,6 +41,9 @@ void printDbl(double val) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int i, k; int i, k;
string infile = "diamond.cti"; string infile = "diamond.cti";

View file

@ -16,6 +16,9 @@ using namespace std;
# #
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
int i; int i;
string infile = "noxNeg.cti"; string infile = "noxNeg.cti";

View file

@ -50,6 +50,9 @@ void printDbl(double val) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int k; int k;
string infile = "diamond.xml"; string infile = "diamond.xml";

View file

@ -57,6 +57,9 @@ static double cutoff (double val, double atol=1.0E-15) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int k; int k;
string infile = "diamond.xml"; string infile = "diamond.xml";

View file

@ -8,6 +8,9 @@ using namespace Cantera;
using namespace std; using namespace std;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
int i; int i;
std::string infile = "noxNeg.xml"; std::string infile = "noxNeg.xml";

View file

@ -284,7 +284,9 @@ void doLogger() {
} }
int main() { int main() {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
// How to connect to a file: // How to connect to a file:
// ofstream fff("redirect.txt"); // ofstream fff("redirect.txt");
// ostream ffs(fff.rdbuf()); // ostream ffs(fff.rdbuf());

View file

@ -18,7 +18,9 @@ double tvalue(double val, double atol = 1.0E-9) {
int main () { int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres; double pres;
try { try {

View file

@ -78,6 +78,9 @@ int openRankine(int np, void* p) {
} }
int main() { int main() {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
return openRankine(0, 0); return openRankine(0, 0);
} }

View file

@ -18,6 +18,9 @@ using namespace Cantera;
using namespace Cantera_CXX; using namespace Cantera_CXX;
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try { try {
IdealGasMix g("silane.xml", "silane"); IdealGasMix g("silane.xml", "silane");
g.setState_TPX(1500.0, 100.0, "SIH4:0.01, H2:0.99"); g.setState_TPX(1500.0, 100.0, "SIH4:0.01, H2:0.99");

View file

@ -157,6 +157,9 @@ void printSurf(ostream &oooo,
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile; string infile;
int ioflag = 1; int ioflag = 1;
int i, k; int i, k;

View file

@ -77,6 +77,9 @@ string getp(int& i, int argc, char** args) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile="chem.inp", dbfile="", trfile="", logfile; string infile="chem.inp", dbfile="", trfile="", logfile;
string idtag = "gas"; string idtag = "gas";
bool debug = false; bool debug = false;