/** * Builds CombinatorialDSS and ArithmeticalDSS in the fourth quadrants and * compares them, if both are equals, the test is passed. */ bool CompareToArithmetical() { typedef string::const_iterator codeIterator; typedef CombinatorialDSS<codeIterator, int> TestedType; typedef ArithmeticalDSS<Contour::ConstIterator,int,4> ReferenceType; trace.beginBlock ( "Comparing to ArithmeticalDSS" ); std::string filename = testPath + "samples/manche.fc"; std::fstream fst; fst.open (filename.c_str(), std::ios::in); Contour theContour(fst); Contour::ConstIterator it = theContour.begin(); TestedType C; C.init( it ); ArithmeticalDSS<FreemanChain<int>::ConstIterator, int, 4> A(it); A.extendForward(); bool res = true; while ( C.end() != theContour.chain.end() ) { bool a = A.extendForward(); bool c = C.extendForward(); if ( a ^ c ) { res = false; cout << "Extension test error\n"; break; } else if ( ! a ) { A.retractForward(); C.retractForward(); } // Compare positions if ( ( C.getFirstPoint() != A.getFirstPoint() ) || ( C.getLastPoint() != A.getLastPoint() ) ) { res = false; cout << "Equality test error\n"; break; } // Compare arithmetic parameters if ( ( C.getA() != A.getA() ) || ( C.getB() != A.getB() ) || ( C.getMu() != A.getMu() ) || ( C.getOmega() != A.getOmega() ) || ( C.getUf() != A.getUf() ) || ( C.getUl() != A.getUl() ) || ( C.getLf() != A.getLf() ) || ( C.getLl() != A.getLl() ) ) { cout << "Arithmetic parameters error\n"; cout << C << endl; cout << A << endl; cout << "getA() " << C.getA() << " --- " << A.getA() << "\n"; cout << "getB() " << C.getB() << " --- " << A.getB() << "\n"; cout << "getMu() " << C.getMu() << " --- " << A.getMu() << "\n"; cout << "getOmega()" << C.getOmega() << " --- " << A.getOmega() << "\n"; cout << "getUf() " << C.getUf() << " --- " << A.getUf() << "\n"; cout << "getUl() " << C.getUl() << " --- " << A.getUl() << "\n"; cout << "getLf() " << C.getLf() << " --- " << A.getLf() << "\n"; cout << "getLl() " << C.getLl() << " --- " << A.getLl() << endl; res = false; break; } } trace.endBlock(); return res; }
/** * Builds OneBalancedWordComputer and ArithmeticalDSSComputer in the fourth quadrants and * compares them, if both are equals, the test is passed. */ bool CompareToArithmetical() { typedef string::const_iterator codeIterator; typedef OneBalancedWordComputer<codeIterator, int> TestedType; typedef ArithmeticalDSSComputer<Contour::ConstIterator,int,4> ReferenceType; trace.beginBlock ( "Comparing to ArithmeticalDSSComputer" ); std::string filename = testPath + "samples/manche.fc"; std::fstream fst; fst.open (filename.c_str(), std::ios::in); Contour theContour(fst); Contour::ConstIterator it = theContour.begin(); TestedType C; C.init( it ); ReferenceType A(it); A.extendFront(); bool res = true; while ( C.end() != theContour.chain.end() ) { bool a = A.extendFront(); bool c = C.extendFront(); if ( a ^ c ) { res = false; cout << "Extension test error\n"; break; } else if ( ! a ) { A.retractBack(); C.retractBack(); } // Compare positions if ( ( C.back() != A.back() ) || ( C.front() != A.front() ) ) { res = false; cout << "Equality test error\n"; break; } // Compare arithmetic parameters if ( ( C.getA() != A.a() ) || ( C.getB() != A.b() ) || ( C.getMu() != A.mu() ) || ( C.getOmega() != A.omega() ) || ( C.Uf() != A.Uf() ) || ( C.Ul() != A.Ul() ) || ( C.Lf() != A.Lf() ) || ( C.Ll() != A.Ll() ) ) { cout << "Arithmetic parameters error\n"; cout << C << endl; cout << A << endl; cout << "a() " << C.getA() << " --- " << A.a() << "\n"; cout << "b() " << C.getB() << " --- " << A.b() << "\n"; cout << "mu() " << C.getMu() << " --- " << A.mu() << "\n"; cout << "omega()" << C.getOmega() << " --- " << A.omega() << "\n"; cout << "Uf() " << C.Uf() << " --- " << A.Uf() << "\n"; cout << "Ul() " << C.Ul() << " --- " << A.Ul() << "\n"; cout << "Lf() " << C.Lf() << " --- " << A.Lf() << "\n"; cout << "Ll() " << C.Ll() << " --- " << A.Ll() << endl; res = false; break; } } trace.endBlock(); return res; }