diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d8762..78e8d5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,16 +34,46 @@ SET (APPLICATION_CODENAME "${PROJECT_NAME}") SET (APPLICATION_COPYRIGHT_YEARS "2015") SET (APPLICATION_VERSION_MAJOR 1) SET (APPLICATION_VERSION_MINOR 1) -SET (APPLICATION_VERSION_PATCH 1) +SET (APPLICATION_VERSION_PATCH 2) SET (APPLICATION_VERSION_TYPE SNAPSHOT) SET (APPLICATION_VERSION_STRING "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}-${APPLICATION_VERSION_TYPE}") SET (APPLICATION_ID "${APPLICATION_VENDOR_ID}.${PROJECT_NAME}") # -# Debugging Options -# -SET (CMAKE_VERBOSE_MAKEFILE 0) # Use 1 for debugging, 0 for release +# Compile options +# + +#define possible flags +SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse2 -mssse3 -fexpensive-optimizations ") +SET (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse2 -mssse3 -fexpensive-optimizations ") + +SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -DDEBUG ") +SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -DDEBUG ") + +#define value of CMAKE_BUILD_TYPE depending on input +IF(NOT CMAKE_BUILD_TYPE) +SET (CMAKE_BUILD_TYPE "Release") #default build type is Release +ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Release") +SET (CMAKE_BUILD_TYPE "Release") +ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug") +SET (CMAKE_BUILD_TYPE "Debug") +ELSE(NOT CMAKE_BUILD_TYPE) +MESSAGE(FATAL_ERROR "Invalid build type ${CMAKE_BUILD_TYPE} specified.") +ENDIF(NOT CMAKE_BUILD_TYPE) + +#output depending on build type +IF(CMAKE_BUILD_TYPE STREQUAL "Release") +SET (CMAKE_VERBOSE_MAKEFILE 0) +MESSAGE("Build type is ${CMAKE_BUILD_TYPE}") +MESSAGE("USING CXX COMPILER FLAGS ${CMAKE_CXX_FLAGS_RELEASE}") +MESSAGE("USING C COMPILER FLAGS ${CMAKE_C_FLAGS_RELEASE}") +ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug") +SET (CMAKE_VERBOSE_MAKEFILE 1) +MESSAGE("Build type is ${CMAKE_BUILD_TYPE}") +MESSAGE("USING CXX COMPILER FLAGS ${CMAKE_CXX_FLAGS_DEBUG}") +MESSAGE("USING C COMPILER FLAGS ${CMAKE_C_FLAGS_DEBUG}") +ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release") # # Project Output Paths diff --git a/README.md b/README.md index 8db4420..fef1fd7 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,15 @@ template metaprogramming in C++. # installs the library and headers sudo make install #only if you want to install the software after build ```` -* If you also want to compile and run the tests, there is a third option, which can be +* If you also want to compile and run the tests, there is another option, which can be passed to either the configure script (first build method), or to cmake (second build method) This option is -DLEMONADE_TESTS=ON . You need internet access, because the process will download the googletest library - +* Another option that can be passed is -DCMAKE_BUILD_TYPE=Release/Debug. The default value + is Release, which uses compiler flags for optimization. If the option "Debug" is chosen, + no compiler optimizations are used, compiler warnings are enabled by -Wall, and + debugging information is compiled into the binary with -g. Other flags then "Release", + or "Debug" are not allowed and will lead to termination and an error message by cmake. ## Getting Started diff --git a/configure b/configure index 691c5b5..8a47e88 100755 --- a/configure +++ b/configure @@ -7,16 +7,19 @@ function usage echo "-DINSTALLDIR_LEMONADE=/path/to/install/LeMonADE/" echo "-DBUILDDIR=/path/to/build/LeMonADE/" echo "-DLEMONADE_TESTS=ON/OFF" + echo "-DCMAKE_BUILD_TYPE=Release/Debug" echo "default build directory is ./build" echo "default install directory is /usr/local" echo "default option for tests is OFF" + echo "default option for build type is Release" } #default values for build directory and install prefix PWD_PATH=$(pwd) BUILDDIR="build" -INSTALLDIR_OPTION="-DINSTALLDIR_LEMONADE=/usr/local" -TEST_ARGUMENT="-DLEMONADE_TESTS=OFF" +#INSTALLDIR_OPTION="-DINSTALLDIR_LEMONADE=/usr/local" +#TEST_ARGUMENT="-DLEMONADE_TESTS=OFF" +CMAKE_ARGUMENTS="" #parse command line arguments for arg in "$@"; do @@ -27,7 +30,7 @@ for arg in "$@"; do ;; -DINSTALLDIR_LEMONADE=*) - INSTALLDIR_ARGUMENT=${arg} + CMAKE_ARGUMENTS+=${arg}" " INSTALLDIR=${arg#*=} echo "Install directory set to "$INSTALLDIR ;; @@ -38,10 +41,16 @@ for arg in "$@"; do ;; -DLEMONADE_TESTS=*) - TEST_ARGUMENT=${arg} + CMAKE_ARGUMENTS+=${arg}" " TESTOPTION=${arg#*=} echo "Compiling tests set to "$TESTOPTION ;; + + -DCMAKE_BUILD_TYPE=*) + CMAKE_ARGUMENTS+=${arg}" " + BUILDOPTION=${arg#*=} + echo "Build type set to "$BUILDOPTION + ;; * ) echo "unknown parameter" @@ -58,8 +67,9 @@ if [ ! -d $BUILDDIR ]; then mkdir -p $BUILDDIR fi +echo "Arguments passed to cmake are "${CMAKE_ARGUMENTS} -(cd $BUILDDIR >/dev/null 2>&1 && cmake $INSTALLDIR_ARGUMENT $TEST_ARGUMENT $PWD_PATH) +(cd $BUILDDIR >/dev/null 2>&1 && cmake $CMAKE_ARGUMENTS $PWD_PATH) ########### set up the wrapper makefile ################## @@ -77,7 +87,7 @@ all: ./${BUILDDIR}/Makefile .PHONY: all ./${BUILDDIR}/Makefile: - @ (cd ${BUILDDIR} >/dev/null 2>&1 && cmake ${INSTALLDIR_ARGUMENT} ${PWD_PATH}) + @ (cd ${BUILDDIR} >/dev/null 2>&1 && cmake ${CMAKE_ARGUMENTS} ${PWD_PATH}) clean: @- \$(MAKE) --silent -C ${BUILDDIR} clean || true diff --git a/include/LeMonADE/LeMonADE.h b/include/LeMonADE/LeMonADE.h deleted file mode 100644 index 8519dbb..0000000 --- a/include/LeMonADE/LeMonADE.h +++ /dev/null @@ -1,65 +0,0 @@ -/*-------------------------------------------------------------------------------- - ooo L attice-based | - o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the - o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers -oo---0---oo A lgorithm and | - o/./|\.\o D evelopment | Copyright (C) 2013-2015 by - o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS) - ooo | ----------------------------------------------------------------------------------- - -This file is part of LeMonADE. - -LeMonADE is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -LeMonADE is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with LeMonADE. If not, see . - ---------------------------------------------------------------------------------*/ - -#ifndef LEMONADE_LEMONADE_H -#define LEMONADE_LEMONADE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * @file - * - * @namespace LeMonADE - * - * @brief The namespace LeMonADe of the Monte-Carlo-Algorithm-project - * - * @details The name is an abbreviation of - * * Lattice-based extensible Monte-Carlo Algorithm and Development Environment" - * - * @todo do we use the namespace? - **/ -using namespace Lemonade; - -#endif - diff --git a/include/LeMonADE/analyzer/AnalyzerRadiusOfGyration.h b/include/LeMonADE/analyzer/AnalyzerRadiusOfGyration.h index c655c97..4ab36ff 100644 --- a/include/LeMonADE/analyzer/AnalyzerRadiusOfGyration.h +++ b/include/LeMonADE/analyzer/AnalyzerRadiusOfGyration.h @@ -30,12 +30,12 @@ along with LeMonADE. If not, see . #include -#include +#include #include #include #include #include -#include +#include /************************************************************************ diff --git a/include/LeMonADE/core/Ingredients.h b/include/LeMonADE/core/Ingredients.h index 286949f..aa01e8a 100644 --- a/include/LeMonADE/core/Ingredients.h +++ b/include/LeMonADE/core/Ingredients.h @@ -203,6 +203,37 @@ template class Ingredients: public Config::context_type return molecules; } + /** + * @brief Synchronizes the Features and establishing consistency in the system. + * + * @details This function only calls the function + * context_type::synchronize(Ingredients&) with itsself as argument. Thus + * it causes all features to subsequently call their synchonize routines. + * Calling this function on an instance ( "ingredients.synchronize();" ) + * is equivalent to calling "ingredients.synchonize(ingredients));" + */ + void synchronize() + { + context_type::synchronize(*this); + } + + /** + * @brief Synchronizes the Features and establishing consistency in the system. + * + * @details This function only calls the function + * context_type::synchronize(Ingredients& ing). Thus it causes all features + * to subsequently call their synchonize routines with the same argument. + * This function allows to synchronize one instance of Ingredients with + * another instance. + * + * @param ingredients A reference to the Ingredients instance to synchronize with + */ + template + void synchronize(IngredientsType& ing) + { + context_type::synchronize(ing); + } + /** * @brief Export the relevant functionality of all meta-information and molecules * for reading bfm-files. diff --git a/include/LeMonADE/core/Molecules.h b/include/LeMonADE/core/Molecules.h index 7247db1..45b9c15 100644 --- a/include/LeMonADE/core/Molecules.h +++ b/include/LeMonADE/core/Molecules.h @@ -94,12 +94,7 @@ template < class Vertex, uint max_connectivity = 7, class Edge = int > class Mol //! Conversion constructor template < class V, uint m, class E> Molecules (const Molecules& src); - - Molecules (const Molecules& src); - - //template < class V, uint m, class E > - //Molecules& operator= (const Molecules& src); - + Molecules& operator= (const Molecules& src); Molecules& operator+= (const Molecules& src); @@ -305,8 +300,8 @@ template < class Vertex, uint max_connectivity = 7, class Edge = int > class Mol /*****************************************************************************/ /** - * Copy one object of Molecules into another, i.e. copies vertex, - * connectivity and age information. + * Copys and Converts one type of Molecules object into another, i.e. copies vertex, + * connectivity and age information, and does type-conversion * * @param src A reference to another graph to copy from. * @tparam m Maximum allowed connectivity of the source graph @@ -314,70 +309,37 @@ template < class Vertex, uint max_connectivity = 7, class Edge = int > class Mol * @tparam E Edge type of the source graph */ template < class Vertex, uint max_connectivity, class Edge> -Molecules::Molecules (const Molecules& src) +template < class V, uint m, class E > +Molecules::Molecules (const Molecules& src) { - + clear(); vertices.resize(src.size()); for ( uint i = 0 ; i < vertices.size(); ++i) { - //copy all vertices. - this->vertices[i]=static_cast::internal_vertex_type&>(src[i]); - - ///@todo rethink: this copy should not be necessary because we are also copying the topology, or? - - //copy the edges, too - uint32_t nNeighbours=src.getNumLinks(i);//vertices[i].getNumLinks(); - for(uint j=0; jvertices[i]=src[i]; + //copy the connectivity and edges, too + uint32_t nNeighbours=src.getNumLinks(i); + try{ + for(uint j=0; jmyAge = src.getAge(); -} - - - -/** - * Copys and Converts one type of Molecules object into another, i.e. copies vertex, - * connectivity and age information, and does type-conversion - * - * @todo testing!!! - * - * @param src A reference to another graph to copy from. - * @tparam m Maximum allowed connectivity of the source graph - * @tparam V Vertex type of the source graph - * @tparam E Edge type of the source graph - */ -template < class Vertex, uint max_connectivity, class Edge> -template < class V, uint m, class E > -Molecules::Molecules (const Molecules& src) -{ - - clear(); - vertices.resize(src.size()); - - for ( uint i = 0 ; i < vertices.size(); ++i) { - //copy all vertices. - this->vertices[i]=static_cast::internal_vertex_type&>(src[i]); - - ///@todo rethink: this copy should not be necessary because we are also copying the topology, or? - - - //copy the edges, too - uint32_t nNeighbours=src.getNumLinks(i);//vertices[i].getNumLinks(); - - for(uint j=0; jmyAge = src.getAge(); - + } /** @@ -398,12 +360,12 @@ Molecules& Moleculesvertices[i]=static_cast::internal_vertex_type&>(src[i]); + //this does not copy the connectivity info, but it is copied + //in the loop below + this->vertices[i]=src[i]; - ///@todo rethink: this copy should not be necessary because we are also copying the topology, or? - - //copy the edges, too - uint32_t nNeighbours=src.getNumLinks(i);//vertices[i].getNumLinks(); + //copy the connectivity and edges, too + uint32_t nNeighbours=src.getNumLinks(i); for(uint j=0; j::connect(uint32_t a, uint32_t b, c vertices.at(a).connect(b); vertices.at(b).connect(a); } - //catch error due to non-existent indices here + //method vertices.at(int) might throw out_of_range exception. catch(std::out_of_range& exception){ std::stringstream messagestream; messagestream<<"Molecules::connect(int a, int b): a="< class UpdaterSynchronize: public IngredientsUpdater < T > template bool UpdaterSynchronize::execute() { - this->getIngredients().synchronize( this->getIngredients() ); + this->getIngredients().synchronize(); return true; } diff --git a/projects/SimpleSimulator/main.cpp b/projects/SimpleSimulator/main.cpp index 73158ff..6d2a0f3 100644 --- a/projects/SimpleSimulator/main.cpp +++ b/projects/SimpleSimulator/main.cpp @@ -2,13 +2,16 @@ #include -#include #include -#include +#include +#include +#include +#include #include #include - - +#include +#include +#include int main(int argc, char* argv[]) { diff --git a/tests/core/TestCopyOperator.cpp b/tests/core/TestCopyOperator.cpp index ffcadbb..b3bc534 100644 --- a/tests/core/TestCopyOperator.cpp +++ b/tests/core/TestCopyOperator.cpp @@ -35,8 +35,12 @@ along with LeMonADE. If not, see . /*****************************************************************************/ #include "gtest/gtest.h" +#include -#include +#include +#include +#include +#include #include #include diff --git a/tests/core/TestIngredients.cpp b/tests/core/TestIngredients.cpp index 1586ca2..d320075 100644 --- a/tests/core/TestIngredients.cpp +++ b/tests/core/TestIngredients.cpp @@ -42,6 +42,7 @@ along with LeMonADE. If not, see . #include #include #include +#include #include #include @@ -98,3 +99,173 @@ TEST(IngredientsTest, printMetaData){ } + +TEST(IngredientsTest, synchronize_noargument){ + typedef LOKI_TYPELIST_2(FeatureBox, FeatureBondset<>) Features1; + typedef ConfigureSystem Config1; + typedef Ingredients < Config1> MyIngredients1; + + typedef LOKI_TYPELIST_3(FeatureBox, FeatureBondset<>,FeatureExcludedVolume<>) Features2; + typedef ConfigureSystem Config2; + typedef Ingredients < Config2> MyIngredients2; + + + MyIngredients1 ingredients1; + MyIngredients2 ingredients2; + + //exception from FeatureBox is exspected, as box size is not set + EXPECT_THROW(ingredients1.synchronize(),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(),std::runtime_error); + + ingredients1.setBoxX(10); + ingredients1.setBoxY(10); + ingredients1.setBoxZ(10); + ingredients1.setPeriodicX(true); + ingredients1.setPeriodicY(true); + + ingredients2.setBoxX(10); + ingredients2.setBoxY(10); + ingredients2.setBoxZ(10); + ingredients2.setPeriodicX(true); + ingredients2.setPeriodicY(false); + + //exception from FeatureBox is exspected, as periodicity not fully set + EXPECT_THROW(ingredients1.synchronize(),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(),std::runtime_error); + + ingredients1.setPeriodicZ(false); + ingredients2.setPeriodicZ(false); + + //now add the bondset and some particles so that effect of synchronize + //can be checked + ingredients1.modifyBondset().addBFMclassicBondset(); + ingredients2.modifyBondset().addBFMclassicBondset(); + + ingredients1.modifyMolecules().addMonomer(1,1,1); + ingredients1.modifyMolecules().addMonomer(1,4,6); + ingredients1.modifyMolecules().addMonomer(7,7,1); + //this one violates excluded volume, but excluded volume feauture is not used + ingredients1.modifyMolecules().addMonomer(7,8,2); + //in ingredients1 this one is ok, but in ingredients2 it will violate box dimensions + ingredients1.modifyMolecules().addMonomer(3,9,2); + + ingredients2.modifyMolecules().addMonomer(1,1,1); + ingredients2.modifyMolecules().addMonomer(1,4,6); + ingredients2.modifyMolecules().addMonomer(7,7,1); + //this one violates excluded volume + ingredients2.modifyMolecules().addMonomer(7,8,2); + //this one violates box dimensions due to periodicity + ingredients2.modifyMolecules().addMonomer(3,9,2); + + //now make some invalid bonds + ingredients1.modifyMolecules().connect(0,1); + ingredients2.modifyMolecules().connect(0,1); + + + //again, try to synchronize. + EXPECT_THROW(ingredients1.synchronize(),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(),std::runtime_error); + + //change position of monomer 1, so that bond is valid. + ingredients1.modifyMolecules()[1].setZ(1); + ingredients2.modifyMolecules()[1].setZ(1); + + //again, try to synchronize. ingredients1 should work now + EXPECT_NO_THROW(ingredients1.synchronize()); + EXPECT_THROW(ingredients2.synchronize(),std::runtime_error); + + //now change the conflicting particle coordinate for excluded volume + //and synchronize again..still fails due to periodicit + ingredients2.modifyMolecules()[3].setY(5); + EXPECT_THROW(ingredients2.synchronize(),std::runtime_error); + + //now change the conflicting particle coordinate for periodicity + //and synchronize again..should work now + ingredients2.modifyMolecules()[4].setY(5); + EXPECT_NO_THROW(ingredients2.synchronize()); +} + +TEST(IngredientsTest, synchronize_withargument){ + typedef LOKI_TYPELIST_2(FeatureBox, FeatureBondset<>) Features1; + typedef ConfigureSystem Config1; + typedef Ingredients < Config1> MyIngredients1; + + typedef LOKI_TYPELIST_3(FeatureBox, FeatureBondset<>,FeatureExcludedVolume<>) Features2; + typedef ConfigureSystem Config2; + typedef Ingredients < Config2> MyIngredients2; + + + MyIngredients1 ingredients1; + MyIngredients2 ingredients2; + + //exception from FeatureBox is exspected, as box size is not set + EXPECT_THROW(ingredients1.synchronize(ingredients1),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(ingredients2),std::runtime_error); + + ingredients1.setBoxX(10); + ingredients1.setBoxY(10); + ingredients1.setBoxZ(10); + ingredients1.setPeriodicX(true); + ingredients1.setPeriodicY(true); + + ingredients2.setBoxX(10); + ingredients2.setBoxY(10); + ingredients2.setBoxZ(10); + ingredients2.setPeriodicX(true); + ingredients2.setPeriodicY(false); + + //exception from FeatureBox is exspected, as periodicity not fully set + EXPECT_THROW(ingredients1.synchronize(ingredients1),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(ingredients2),std::runtime_error); + + ingredients1.setPeriodicZ(false); + ingredients2.setPeriodicZ(false); + + //now add the bondset and some particles so that effect of synchronize + //can be checked + ingredients1.modifyBondset().addBFMclassicBondset(); + ingredients2.modifyBondset().addBFMclassicBondset(); + + ingredients1.modifyMolecules().addMonomer(1,1,1); + ingredients1.modifyMolecules().addMonomer(1,4,6); + ingredients1.modifyMolecules().addMonomer(7,7,1); + //this one violates excluded volume, but excluded volume feauture is not used + ingredients1.modifyMolecules().addMonomer(7,8,2); + //in ingredients1 this one is ok, but in ingredients2 it will violate box dimensions + ingredients1.modifyMolecules().addMonomer(3,9,2); + + ingredients2.modifyMolecules().addMonomer(1,1,1); + ingredients2.modifyMolecules().addMonomer(1,4,6); + ingredients2.modifyMolecules().addMonomer(7,7,1); + //this one violates excluded volume + ingredients2.modifyMolecules().addMonomer(7,8,2); + //this one violates box dimensions due to periodicity + ingredients2.modifyMolecules().addMonomer(3,9,2); + + //now make some invalid bonds + ingredients1.modifyMolecules().connect(0,1); + ingredients2.modifyMolecules().connect(0,1); + + + //again, try to synchronize. + EXPECT_THROW(ingredients1.synchronize(ingredients1),std::runtime_error); + EXPECT_THROW(ingredients2.synchronize(ingredients2),std::runtime_error); + + //change position of monomer 1, so that bond is valid. + ingredients1.modifyMolecules()[1].setZ(1); + ingredients2.modifyMolecules()[1].setZ(1); + + //again, try to synchronize. ingredients1 should work now + EXPECT_NO_THROW(ingredients1.synchronize(ingredients1)); + EXPECT_THROW(ingredients2.synchronize(ingredients2),std::runtime_error); + + //now change the conflicting particle coordinate for excluded volume + //and synchronize again..still fails due to periodicity + ingredients2.modifyMolecules()[3].setY(5); + EXPECT_THROW(ingredients2.synchronize(ingredients2),std::runtime_error); + + //now change the conflicting particle coordinate for periodicity + //and synchronize again..should work now + ingredients2.modifyMolecules()[4].setY(5); + EXPECT_NO_THROW(ingredients2.synchronize(ingredients2)); +} diff --git a/tests/core/TestMolecules.cpp b/tests/core/TestMolecules.cpp index c4b5c61..a2e7fe7 100644 --- a/tests/core/TestMolecules.cpp +++ b/tests/core/TestMolecules.cpp @@ -245,7 +245,7 @@ TEST_F(MoleculesTest, Constructors){ //this should throw an exception, because the max connectivity of molecules1 //is too high EXPECT_ANY_THROW( (Molecules (molecules1)) ); - + //create new objects from molecules1 Molecules molecules2(molecules1); Molecules molecules3(molecules2); @@ -261,6 +261,43 @@ TEST_F(MoleculesTest, Constructors){ EXPECT_EQ(molecules2.getLinkInfo(0,4),molecules3.getLinkInfo(0,4)); } +TEST_F(MoleculesTest, AssignmentOperator){ + + //setup of a molecules object first + Molecules molecules1; + + molecules1.resize(10); + molecules1.connect(0,1); + molecules1.connect(0,2); + molecules1.connect(0,3); + molecules1.connect(0,4,2); + molecules1[1].setAllCoordinates(2,3,4); + + //copy to molecules object of same type, and with higher max + //connectivity...should both work + Molecules molecules2; + molecules2=molecules1; + Molecules molecules3; + molecules3=molecules2; + + //check if everything was copied correctly + EXPECT_EQ(7,molecules2.getMaxConnectivity()); + EXPECT_EQ(8,molecules3.getMaxConnectivity()); + EXPECT_EQ(10,molecules2.size()); + EXPECT_EQ(10,molecules3.size()); + EXPECT_EQ(molecules1[1],molecules2[1]); + EXPECT_EQ(molecules2[1],molecules3[1]); + EXPECT_EQ(molecules1.getLinkInfo(0,4),molecules2.getLinkInfo(0,4)); + EXPECT_EQ(molecules2.getLinkInfo(0,4),molecules3.getLinkInfo(0,4)); + + + //now try to assign to molecules object with too low max connectivity + //this should throw an exception + Molecules molecules4; + EXPECT_ANY_THROW( molecules4=molecules1) ; + +} + TEST_F(MoleculesTest,Clear){ MyIngredients ingredients; diff --git a/tests/feature/TestExcludedVolume.cpp b/tests/feature/TestExcludedVolume.cpp index 4ae4ad8..f6b338b 100644 --- a/tests/feature/TestExcludedVolume.cpp +++ b/tests/feature/TestExcludedVolume.cpp @@ -27,7 +27,9 @@ along with LeMonADE. If not, see . #include "gtest/gtest.h" -#include +#include +#include +#include #include using namespace std; diff --git a/tests/feature/TestFeatureAttributes.cpp b/tests/feature/TestFeatureAttributes.cpp index 2150564..1fa48a8 100644 --- a/tests/feature/TestFeatureAttributes.cpp +++ b/tests/feature/TestFeatureAttributes.cpp @@ -184,3 +184,41 @@ TEST_F(FeatureAttributesTest,ReadAttributesClass) } + +TEST_F(FeatureAttributesTest,CopyConstructor) +{ + typedef MyIngredients::molecules_type MyMolecules; + MyMolecules molecules1; + + //check if attributes are copied corriectly by copy constructor + molecules1.resize(5); + molecules1[0].setAttributeTag(1); + molecules1[1].setAttributeTag(2); + molecules1[2].setAttributeTag(3); + molecules1[3].setAttributeTag(4); + molecules1[4].setAttributeTag(5); + //create new objects from molecules1 + + typedef ConfigureSystem Config8; + typedef Ingredients MyIngredients8; + typedef MyIngredients8::molecules_type MyMolecules8; + MyMolecules molecules2(molecules1); + MyMolecules8 molecules3(molecules2); + + EXPECT_EQ(molecules1[0].getAttributeTag(),molecules2[0].getAttributeTag()); + EXPECT_EQ(molecules1[0].getAttributeTag(),molecules3[0].getAttributeTag()); + + EXPECT_EQ(molecules1[1].getAttributeTag(),molecules2[1].getAttributeTag()); + EXPECT_EQ(molecules1[1].getAttributeTag(),molecules3[1].getAttributeTag()); + + EXPECT_EQ(molecules1[2].getAttributeTag(),molecules2[2].getAttributeTag()); + EXPECT_EQ(molecules1[2].getAttributeTag(),molecules3[2].getAttributeTag()); + + EXPECT_EQ(molecules1[3].getAttributeTag(),molecules2[3].getAttributeTag()); + EXPECT_EQ(molecules1[3].getAttributeTag(),molecules3[3].getAttributeTag()); + + EXPECT_EQ(molecules1[4].getAttributeTag(),molecules2[4].getAttributeTag()); + EXPECT_EQ(molecules1[4].getAttributeTag(),molecules3[4].getAttributeTag()); + +} + diff --git a/tests/feature/TestFeatureLattice.cpp b/tests/feature/TestFeatureLattice.cpp index d274b45..6ba5196 100644 --- a/tests/feature/TestFeatureLattice.cpp +++ b/tests/feature/TestFeatureLattice.cpp @@ -27,7 +27,8 @@ along with LeMonADE. If not, see . #include "gtest/gtest.h" -#include +#include +#include #include /*****************************************************************************/ diff --git a/tests/feature/TestFeatureLatticePowerOfTwo.cpp b/tests/feature/TestFeatureLatticePowerOfTwo.cpp index 02cf748..1521239 100644 --- a/tests/feature/TestFeatureLatticePowerOfTwo.cpp +++ b/tests/feature/TestFeatureLatticePowerOfTwo.cpp @@ -27,7 +27,8 @@ along with LeMonADE. If not, see . #include "gtest/gtest.h" -#include +#include +#include #include using namespace std;