From 4718e4ab91c1d86b2adc920d321fe4ef0d02630c Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Sun, 2 Sep 2018 17:40:18 +0200 Subject: [PATCH] Added test for move semantics --- regtest/basic/rt-make-wrappers/COLVAR.reference | 4 ++++ regtest/basic/rt-make-wrappers/main.cpp | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/regtest/basic/rt-make-wrappers/COLVAR.reference b/regtest/basic/rt-make-wrappers/COLVAR.reference index b4d38c02e..1d11bf095 100644 --- a/regtest/basic/rt-make-wrappers/COLVAR.reference +++ b/regtest/basic/rt-make-wrappers/COLVAR.reference @@ -54,3 +54,7 @@ 0.000000 0.000000 #! FIELDS time d 0.000000 0.000000 +#! FIELDS time d + 0.000000 0.000000 +#! FIELDS time d + 0.000000 0.000000 diff --git a/regtest/basic/rt-make-wrappers/main.cpp b/regtest/basic/rt-make-wrappers/main.cpp index 047ece96b..e36280be4 100644 --- a/regtest/basic/rt-make-wrappers/main.cpp +++ b/regtest/basic/rt-make-wrappers/main.cpp @@ -137,13 +137,26 @@ int main(){ testmecpp(p); } + { +// test move semantics + PLMD::Plumed p; + PLMD::Plumed q(std::move(p)); + testmecpp(q); + } + + { + PLMD::Plumed p,q; + q=std::move(p); + testmecpp(q); + } + if(PLMD::Plumed::ginitialized()) return 0; PLMD::Plumed::gcreate(); if(!PLMD::Plumed::ginitialized()) return 0; // this requires move semantics and only works with C++11 - //PLMD::Plumed fromglobal(PLMD::Plumed::global()); + PLMD::Plumed fromglobal(PLMD::Plumed::global()); // here's a workaround for plumed 2.3: - PLMD::Plumed fromglobal(plumed_global()); + //PLMD::Plumed fromglobal(plumed_global()); testmecpp(fromglobal); PLMD::Plumed::gfinalize(); if(PLMD::Plumed::ginitialized()) return 0; -- GitLab