test and documentation added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1698 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
92251dc96f
commit
cad0320e57
25 changed files with 317 additions and 37 deletions
|
|
@ -45,6 +45,8 @@ SET (TEST_LIST
|
|||
t-moFitnessStat
|
||||
t-moDistanceStat
|
||||
t-moNeighborhoodStat
|
||||
t-moCounterMonitorSaver
|
||||
t-moSolutionStat
|
||||
)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ int main(){
|
|||
test1.printOn(std::cout);
|
||||
test2.printOn(std::cout);
|
||||
|
||||
assert(test1.className()=="moBitNeighbor");
|
||||
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
105
branches/newMo/test/t-moCounterMonitorSaver.cpp
Normal file
105
branches/newMo/test/t-moCounterMonitorSaver.cpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
<t-moCounterMonitorSaver.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <continuator/moCounterMonitorSaver.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
class monitor1 : public eoMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
monitor1(unsigned int& _a): a(_a){}
|
||||
|
||||
eoMonitor& operator()(){
|
||||
a++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void lastCall(){
|
||||
a++;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int& a;
|
||||
};
|
||||
|
||||
class monitor2 : public eoMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
monitor2(unsigned int& _a): a(_a){}
|
||||
|
||||
eoMonitor& operator()(){
|
||||
a++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void lastCall(){
|
||||
a++;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int& a;
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
|
||||
|
||||
unsigned int a=1;
|
||||
unsigned int b=10;
|
||||
|
||||
monitor1 mon1(a);
|
||||
monitor2 mon2(b);
|
||||
|
||||
moCounterMonitorSaver test(3, mon1);
|
||||
test.add(mon2);
|
||||
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==3 && b==12);
|
||||
test.lastCall();
|
||||
assert(a==4 && b==13);
|
||||
|
||||
assert(test.className()=="moCounterMonitorSaver");
|
||||
std::cout << "[t-moCounterMonitorSaver] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +63,7 @@ int main(){
|
|||
test(sol3);
|
||||
assert(test.value()==1);
|
||||
|
||||
assert(test.className()=="moDistanceStat");
|
||||
std::cout << "[t-moDistanceStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ int main(){
|
|||
test(sol);
|
||||
assert(test.value()==12);
|
||||
|
||||
|
||||
assert(test.className()=="moFitnessStat");
|
||||
std::cout << "[t-moFitnessStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ int main(){
|
|||
test2.printOn(std::cout);
|
||||
test3.printOn(std::cout);
|
||||
|
||||
assert(test1.className()=="moNeighbor");
|
||||
std::cout << "[t-moNeighbor] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ int main(){
|
|||
neighbor2.fitness(3);
|
||||
assert(test.equals(neighbor1,neighbor2));
|
||||
|
||||
assert(test.className()=="moNeighborComparator");
|
||||
std::cout << "[t-moNeighborComparator] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ int main(){
|
|||
assert(test.getNbInf()==3);
|
||||
assert(test.getNbEqual()==0);
|
||||
|
||||
assert(test.className()=="moNeighborhoodStat");
|
||||
std::cout << "[t-moNeighborhoodStat] => OK" << std::endl;
|
||||
|
||||
//test of moMaxNeighborStat.h
|
||||
|
|
@ -94,6 +95,7 @@ int main(){
|
|||
moMaxNeighborStat<bitNeighborhood> test2(test);
|
||||
test2(sol);
|
||||
assert(test2.value()==6);
|
||||
assert(test2.className()=="moMaxNeighborStat");
|
||||
std::cout << "[t-moMaxNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moMinNeighborStat.h
|
||||
|
|
@ -101,6 +103,7 @@ int main(){
|
|||
moMinNeighborStat<bitNeighborhood> test3(test);
|
||||
test3(sol);
|
||||
assert(test3.value()==8);
|
||||
assert(test3.className()=="moMinNeighborStat");
|
||||
std::cout << "[t-moMinNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNbInfNeighborStat.h
|
||||
|
|
@ -108,6 +111,7 @@ int main(){
|
|||
moNbInfNeighborStat<bitNeighborhood> test4(test);
|
||||
test4(sol);
|
||||
assert(test4.value()==3);
|
||||
assert(test4.className()=="moNbInfNeighborStat");
|
||||
std::cout << "[t-moNbInfNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNbSupNeighborStat.h
|
||||
|
|
@ -115,6 +119,7 @@ int main(){
|
|||
moNbSupNeighborStat<bitNeighborhood> test5(test);
|
||||
test5(sol);
|
||||
assert(test5.value()==7);
|
||||
assert(test5.className()=="moNbSupNeighborStat");
|
||||
std::cout << "[t-moNbSupNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNeutralDegreeNeighborStat.h
|
||||
|
|
@ -122,6 +127,7 @@ int main(){
|
|||
moNeutralDegreeNeighborStat<bitNeighborhood> test6(test);
|
||||
test6(sol);
|
||||
assert(test6.value()==0);
|
||||
assert(test6.className()=="moNeutralDegreeNeighborStat");
|
||||
std::cout << "[t-moNeutralDegreeNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moSecondMomentNeighborStat.h
|
||||
|
|
@ -130,6 +136,7 @@ int main(){
|
|||
test7(sol);
|
||||
assert(test7.value().first==6.6);
|
||||
assert(test7.value().second > 0.966 && test7.value().second < 0.967);
|
||||
assert(test7.className()=="moSecondMomentNeighborStat");
|
||||
std::cout << "[t-moSecondMomentNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moSizeNeighborStat.h
|
||||
|
|
@ -137,6 +144,7 @@ int main(){
|
|||
moSizeNeighborStat<bitNeighborhood> test8(test);
|
||||
test8(sol);
|
||||
assert(test8.value()==10);
|
||||
assert(test8.className()=="moSizeNeighborStat");
|
||||
std::cout << "[t-moSizeNeighborStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ int main(){
|
|||
test.next(sol, neighbor);
|
||||
assert(!test.cont(sol));
|
||||
|
||||
assert(test.className()=="moOrderNeighborhood");
|
||||
|
||||
std::cout << "[t-moOrderNeighborhood] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ int main(){
|
|||
|
||||
}
|
||||
|
||||
assert(test.className()=="moRndWithReplNeighborhood");
|
||||
|
||||
std::cout << "[t-moRndWithReplNeighborhood] => OK" << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ int main(){
|
|||
assert(a==1 || b==1 || c==1);
|
||||
assert(a==2 || b==2 || c==2);
|
||||
|
||||
assert(test.className()=="moRndWithoutReplNeighborhood");
|
||||
|
||||
std::cout << "[t-moRndWithoutReplNeighborhood] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ int main(){
|
|||
test.accept(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
assert(test.className()=="moSimpleHCexplorer");
|
||||
|
||||
std::cout << "[t-moSimpleHCexplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ int main(){
|
|||
neighbor.fitness(3);
|
||||
assert(test.equals(sol, neighbor));
|
||||
|
||||
assert(test.className()=="moSolNeighborComparator");
|
||||
|
||||
std::cout << "[t-moSolNeighborComparator] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
63
branches/newMo/test/t-moSolutionStat.cpp
Normal file
63
branches/newMo/test/t-moSolutionStat.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<t-moSolutionStat.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moSolutionStat] => START" << std::endl;
|
||||
|
||||
eoBit<unsigned int> s(3);
|
||||
s[0]=true;
|
||||
s[1]=true;
|
||||
s[2]=false;
|
||||
|
||||
s.fitness(17);
|
||||
|
||||
moSolutionStat< eoBit<unsigned int > > test;
|
||||
|
||||
test(s);
|
||||
|
||||
assert(test.value()[0]);
|
||||
assert(test.value()[1]);
|
||||
assert(!test.value()[2]);
|
||||
assert(test.value().fitness()==17);
|
||||
|
||||
assert(test.className()=="moSolutionStat");
|
||||
|
||||
std::cout << "[t-moSolutionStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue