Skip to content
Snippets Groups Projects
Commit 4fe6905b authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Improved regtest

parent fa1e9281
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,29 @@ ...@@ -7,6 +7,29 @@
using namespace PLMD; using namespace PLMD;
void test_line(std::ostream & ofs,Plumed & p,const std::string & arg){
std::string cmd="readInputLine";
ofs<<cmd<<" "<<arg<<std::endl;
try{
p.cmd(cmd.c_str(),arg.c_str());
ofs<<"+++ !!!! uncatched !!!!"<<std::endl;
} catch(Exception&e) {
ofs<<"+++ catched"<<std::endl;
}
}
void test_this(std::ostream & ofs,Plumed & p,const std::string & cmd,const void*arg){
ofs<<cmd;
if(!arg) ofs<<" NULL";
ofs<<std::endl;
try{
p.cmd(cmd.c_str(),arg);
ofs<<"+++ !!!! uncatched !!!!"<<std::endl;
} catch(Exception&e) {
ofs<<"+++ catched"<<std::endl;
}
}
int main(){ int main(){
std::ofstream ofs("output"); std::ofstream ofs("output");
...@@ -14,16 +37,20 @@ int main(){ ...@@ -14,16 +37,20 @@ int main(){
{ {
// test a mistake in timer // test a mistake in timer
Stopwatch sw; Stopwatch sw;
try{ sw.pause(); ofs<<"pause"<<std::endl;
} catch(Exception& e) { ofs<<"E pause\n"; } try{
sw.pause();
ofs<<"+++ !!!! uncatched !!!!"<<std::endl;
} catch(Exception& e) {
ofs<<"+++ catched"<<std::endl;
}
} }
Plumed plumed; Plumed plumed;
// first try to wrongly set real precision // first try to wrongly set real precision
unsigned i=127; unsigned i=127;
try{ plumed.cmd("setRealPrecision",&i); test_this(ofs,plumed,"setRealPrecision",&i);
} catch(Exception&e){ ofs<<"E setRealPrecision"<<std::endl;}
int natoms=10; int natoms=10;
...@@ -42,38 +69,38 @@ int main(){ ...@@ -42,38 +69,38 @@ int main(){
// Each of them will raise an exception // Each of them will raise an exception
// Notice that name "d" will not be reserved and it will be possible // Notice that name "d" will not be reserved and it will be possible
// to use it later // to use it later
try{ plumed.cmd("readInputLine","d: DISTANCE ATOMS=1,2,3"); test_line(ofs,plumed,"d: DISTANCE ATOMS=1,2,3");
} catch(Exception& e) { ofs<<"E d:DISTANCE ATOMS=1,2,3"<<std::endl; } test_line(ofs,plumed,"d:DISTANCE ATOMS=1,2");
try{ plumed.cmd("readInputLine","d:DISTANCE ATOMS=1,2"); test_line(ofs,plumed,"d: DIST ANCE ATOMS=1,2");
} catch(Exception& e) { ofs<<"E d:DISTANCE ATOMS=1,2"<<std::endl; } test_line(ofs,plumed,"d: DISTANCE ATOMS=1,2 COMPONENTS SCALED_COMPONENTS");
try{ plumed.cmd("readInputLine","d: DIST ANCE ATOMS=1,2"); test_line(ofs,plumed,"d: GYRATION ATOMS=");
} catch(Exception& e) { ofs<<"E d: DIST ANCE ATOMS=1,2"<<std::endl; } test_line(ofs,plumed,"d: GYRATION ATOMS=1-4 TYPE=WHAT");
try{ plumed.cmd("readInputLine","d: ANGLE ATOMS=1,2,3,4,5"); test_line(ofs,plumed,"d: POSITION ATOM=1,2");
} catch(Exception& e) { ofs<<"E d: ANGLE ATOMS=1,2,3,4,5 "<<std::endl; } test_line(ofs,plumed,"d: PUCKERING ATOMS=1-4");
try{ plumed.cmd("readInputLine","d: COORDINATION GROUPA=1 GROUPB=2 R_0=0.5 NN=1.5"); test_line(ofs,plumed,"d: ANGLE ATOMS=1,2,3,4,5");
} catch(Exception& e) { ofs<<"E d: COORDINATION GROUPA=1 GROUPB=2 R_0=0.5 NN=1.5"<<std::endl; } test_line(ofs,plumed,"d: COORDINATION GROUPA=1 GROUPB=2 R_0=0.5 NN=1.5");
// these should not fail // these should not fail
plumed.cmd("readInputLine","d: DISTANCE ATOMS=1,2"); plumed.cmd("readInputLine","d: DISTANCE ATOMS=1,2");
plumed.cmd("readInputLine","d1: DISTANCE ATOMS={1 2}"); // check if braces are parsed correctly plumed.cmd("readInputLine","d1: DISTANCE ATOMS={1 2}"); // check if braces are parsed correctly
plumed.cmd("readInputLine","RESTRAINT ARG=d AT=0 KAPPA=1"); plumed.cmd("readInputLine","RESTRAINT ARG=d AT=0 KAPPA=1");
// Check stupid option to RESTART test_line(ofs,plumed,"METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT");
try{ plumed.cmd("readInputLine","METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT"); test_line(ofs,plumed,"METAD ARG=d PACE=1 SIGMA=1 TAU=5");
} catch(Exception& e) { ofs<<"E METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT"<<std::endl; } test_line(ofs,plumed,"COMBINE ARG=d,d1 COEFFICIENTS=3");
test_line(ofs,plumed,"COMBINE ARG=d,d1 COEFFICIENTS=3,3 PARAMETERS=1");
test_line(ofs,plumed,"COMBINE ARG=d,d1 COEFFICIENTS=3,3 PARAMETERS=1,2 POWERS=4");
// these should not fail // these should not fail
plumed.cmd("readInputLine","m1: METAD ARG=d PACE=1 SIGMA=5 HEIGHT=1 FILE=H1 FMT=%9.5f"); plumed.cmd("readInputLine","m1: METAD ARG=d PACE=1 SIGMA=5 HEIGHT=1 FILE=H1 FMT=%9.5f");
plumed.cmd("readInputLine","m2: METAD ARG=d PACE=2 SIGMA=5 HEIGHT=1 FILE=H2 FMT=%9.5f"); plumed.cmd("readInputLine","m2: METAD ARG=d PACE=2 SIGMA=5 HEIGHT=1 FILE=H2 FMT=%9.5f");
plumed.cmd("readInputLine","PRINT ARG=d,d1,m1.bias FILE=COLVAR FMT=%9.5f"); plumed.cmd("readInputLine","PRINT ARG=d,d1,m1.bias FILE=COLVAR FMT=%9.5f");
try{ plumed.cmd("something random here",NULL); test_this(ofs,plumed,"something random here",NULL);
} catch(Exception& e) { ofs<<"E random cmd"<<std::endl;}
for(int step=0;step<3;step++){ for(int step=0;step<3;step++){
// this should fail // this should fail
try{ plumed.cmd("setStep",NULL); test_this(ofs,plumed,"setStep",NULL);
} catch(Exception& e) { ofs<<"E cmd setStep NULL"<<std::endl;}
plumed.cmd("setStep",&step); plumed.cmd("setStep",&step);
plumed.cmd("setPositions",&positions[0]); plumed.cmd("setPositions",&positions[0]);
...@@ -86,8 +113,7 @@ int main(){ ...@@ -86,8 +113,7 @@ int main(){
plumed.cmd("calc"); plumed.cmd("calc");
// this should fail // this should fail
try{ plumed.cmd("setMasses",&masses[0]); test_this(ofs,plumed,"setMasses",&masses[0]);
} catch(Exception& e) { ofs<<"E setMasses called in wrong place"<<std::endl;}
} }
return 0; return 0;
......
E pause pause
E setRealPrecision +++ catched
E d:DISTANCE ATOMS=1,2,3 setRealPrecision
E d:DISTANCE ATOMS=1,2 +++ catched
E d: DIST ANCE ATOMS=1,2 readInputLine d: DISTANCE ATOMS=1,2,3
E d: ANGLE ATOMS=1,2,3,4,5 +++ catched
E d: COORDINATION GROUPA=1 GROUPB=2 R_0=0.5 NN=1.5 readInputLine d:DISTANCE ATOMS=1,2
E METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT +++ catched
E random cmd readInputLine d: DIST ANCE ATOMS=1,2
E cmd setStep NULL +++ catched
E setMasses called in wrong place readInputLine d: DISTANCE ATOMS=1,2 COMPONENTS SCALED_COMPONENTS
E cmd setStep NULL +++ catched
E setMasses called in wrong place readInputLine d: GYRATION ATOMS=
E cmd setStep NULL +++ catched
E setMasses called in wrong place readInputLine d: GYRATION ATOMS=1-4 TYPE=WHAT
+++ catched
readInputLine d: POSITION ATOM=1,2
+++ catched
readInputLine d: PUCKERING ATOMS=1-4
+++ catched
readInputLine d: ANGLE ATOMS=1,2,3,4,5
+++ catched
readInputLine d: COORDINATION GROUPA=1 GROUPB=2 R_0=0.5 NN=1.5
+++ catched
readInputLine METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT
+++ catched
readInputLine METAD ARG=d PACE=1 SIGMA=1 TAU=5
+++ catched
readInputLine COMBINE ARG=d,d1 COEFFICIENTS=3
+++ catched
readInputLine COMBINE ARG=d,d1 COEFFICIENTS=3,3 PARAMETERS=1
+++ catched
readInputLine COMBINE ARG=d,d1 COEFFICIENTS=3,3 PARAMETERS=1,2 POWERS=4
+++ catched
something random here NULL
+++ catched
setStep NULL
+++ catched
setMasses
+++ catched
setStep NULL
+++ catched
setMasses
+++ catched
setStep NULL
+++ catched
setMasses
+++ catched
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment