complex.vvh

00001 #ifndef TEST_COMPLEX_VVH
00002 #define TEST_COMPLEX_VVH
00003 
00004 #include <test/test.h>
00005 #include <test/graph.h>
00006 
00007 #include <util/forall.h>
00008 #include <util/unorderedset.h>
00009 
00015 #define CHECK_CONSISTENT_COMPLEX(T) \
00016   TEST_RESULT &= test::check_consistentComplex(T, __LINE__)
00017 
00018 namespace test
00019 {
00020   template <typename Complex>
00021   bool check_consistentComplex(const Complex& T, size_t line_nb)
00022   {
00023     bool result = true;
00024     IMPORT_COMPLEX_TYPES(Complex);
00025     forall const cell& c in T.C:
00026     {
00027       forall const junction& j in T.S.neighbors(c):
00028       {
00029         const junction& jn = T.S.nextTo(c,j);
00030         if(!T.W.edge(j,jn))
00031         {
00032           if(result) FAILED_FUNCTION(line_nb);
00033           result = false;
00034           out << endl << " junction " << toStr(j) << " is after " << toStr(jn) << " in " << toStr(c) << " but the edge is not in W" << endl;
00035         }
00036         const cell& oc = T.S.prevTo(j, c);
00037         if(T.S.prevTo(oc, j) == jn and !T.C.edge(c,oc))
00038         {
00039           if(result) FAILED_FUNCTION(line_nb);
00040           result = false;
00041           out << endl << " cell " << toStr(c) << " is a neighbor of " << toStr(oc) << " in S but not in C" << endl;
00042         }
00043       }
00044       forall const cell& oc in T.C.neighbors(c):
00045       {
00046         bool foundInS = false;
00047         forall const junction& j in T.S.neighbors(c):
00048         {
00049           if(T.S.nextTo(j, c) == oc)
00050           {
00051             foundInS = true;
00052             break;
00053           }
00054         }
00055         if(!foundInS)
00056         {
00057           if(result) FAILED_FUNCTION(line_nb);
00058           result = false;
00059           out << endl << " cell " << toStr(c) << " is neighbor of " << toStr(oc) << " in C but not in S" << endl;
00060         }
00061       }
00062     }
00063     forall const junction& j in T.W:
00064       forall const junction& jn in T.W.neighbors(j):
00065       {
00066         bool foundInS = false;
00067         forall const cell& c in T.S.neighbors(j):
00068         {
00069           if(T.S.nextTo(c,j) == jn or T.S.prevTo(c,j) == jn)
00070           {
00071             foundInS = true;
00072             break;
00073           }
00074         }
00075         if(!foundInS)
00076         {
00077           if(result) FAILED_FUNCTION(line_nb);
00078           result = false;
00079           out << endl << " junction " << toStr(j) << " is neighbor of " << toStr(jn) << " in W but not in S" << endl;
00080         }
00081       }
00082     return result;
00083   }
00084 }
00085 
00086 #endif // COMPLEX_VVH
00087 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Fri May 31 15:37:52 2013 for VVE by  doxygen 1.6.3