]> ruin.nu Git - germs.git/blobdiff - src/test/modelidentifiertest.cpp
Added a Whirl model, which favors reversals, instead of using the standard
[germs.git] / src / test / modelidentifiertest.cpp
index 1e5563f1993ffe391a38b18cbdbfb373f4ff0db5..b4848cc30326410550b9fea3fe23e4ede54bebf5 100644 (file)
@@ -4,10 +4,12 @@
 #include <geneorder.h>
 #include <genealgorithms.h>
 #include <modelidentifier.h>
+#include <model.h>
 
 #include <algorithm>
 #include <queue>
 #include <iterator>
+
 using namespace std;
 
 /* 
@@ -18,13 +20,8 @@ using namespace std;
 
 #define TESTNAME ModelIdentifierTest
 
-typedef pair<ModelIdentifier::Model,double> modelpair;
+typedef pair<double, Model> modelpair;
 
-struct ModelCmp {
-       bool operator()(modelpair m1, modelpair m2){
-               return m1.second < m2.second;
-       }
-};
 
 class TESTNAME : public CPPUNIT_NS::TestFixture
 {
@@ -65,24 +62,20 @@ protected:
                ModelIdentifier mi("default.ann");
 
                GeneOrder axis(_1axis.begin(),_1axis.end());
-               map<ModelIdentifier::Model,double> scores = mi.identify(axis);
-               priority_queue<modelpair, vector<modelpair>, ModelCmp > pq(scores.begin(),scores.end());
-               CPPUNIT_ASSERT_EQUAL(ModelIdentifier::X,pq.top().first);
+               priority_queue<modelpair> pq = mi.identify(axis);
+               CPPUNIT_ASSERT_EQUAL(string("X"),string(pq.top().second.name()));
 
                GeneOrder uniform(_uniform.begin(),_uniform.end());
-               scores = mi.identify(uniform);
-               pq = priority_queue<modelpair, vector<modelpair>, ModelCmp >(scores.begin(),scores.end());
-               CPPUNIT_ASSERT_EQUAL(ModelIdentifier::Whirl,pq.top().first);
+               pq = mi.identify(uniform);
+               CPPUNIT_ASSERT_EQUAL(string("Whirl"),string(pq.top().second.name()));
 
                GeneOrder zipper(_zipper.begin(),_zipper.end());
-               scores = mi.identify(zipper);
-               pq = priority_queue<modelpair, vector<modelpair>, ModelCmp >(scores.begin(),scores.end());
-               CPPUNIT_ASSERT_EQUAL(ModelIdentifier::Zipper,pq.top().first);
+               pq = mi.identify(zipper);
+               CPPUNIT_ASSERT_EQUAL(string("Zipper"),string(pq.top().second.name()));
 
                GeneOrder transpos(_transpos.begin(),_transpos.end());
-               scores = mi.identify(transpos);
-               pq = priority_queue<modelpair, vector<modelpair>, ModelCmp >(scores.begin(),scores.end());
-               CPPUNIT_ASSERT_EQUAL(ModelIdentifier::Cloud,pq.top().first);
+               pq = mi.identify(transpos);
+               CPPUNIT_ASSERT_EQUAL(string("Cloud"),string(pq.top().second.name()));
        }
 };