void testObj::test<1>(void) { const Similarity s =compare( TestType(3), TestType(4) ); const double exp=1-1.0/9; if( !System::Math::compareFP<double>(s.get(), exp, 3) ) tut::ensure_equals("invalid similarity - self test failed", s.get(), exp); }
ErrCode TestCall (int iAantalPars, char **ppcAdressenPars) { ErrCode fout = NO_ERR; if (iAantalPars != NUM_OF_PARS) { fout = ERR_PARS; } else { fout = TestType(ppcAdressenPars[1]); if (fout == NO_ERR) { fout = TestNr(ppcAdressenPars[2]); } if (fout == NO_ERR) { fout = TestChar(ppcAdressenPars[3]); } } return fout; }
bool mediaplugin::searchPattern() { switch(_sMode) { case And: { _found = true; for(vector<pattern>::iterator i = _patterns.begin(); i != _patterns.end(); i++) switch ((*i).searchMethod) { case State: { struct stat buf; string path = string(_st_curDirectory) + "/" + (*i).searchPattern; if (!stat(path.c_str(), &buf) == 0) { // cerr << "cur path " << path << endl; if(!(*i).caseSensitive) { char *upperBuffer = strdup((*i).searchPattern); strToUpper(upperBuffer); path = string(_st_curDirectory) + "/" + upperBuffer; // cerr << "cur path " << path << endl; free(upperBuffer); if (!stat(path.c_str(), &buf) == 0) _found = false; } else _found = false; } else _pluginDescription = (*i).patternDescription; break; } case Find: if (!TestType(_st_curDirectory, (*i).searchPattern, (*i).caseSensitive)) _found = false; else _pluginDescription = (*i).patternDescription; break; case MediaType: if((*i).mediaT != _st_curMediaType) _found = false; else _pluginDescription = (*i).patternDescription; break; } return _found; break; } case Or: { _found = false; for(vector<pattern>::iterator i = _patterns.begin(); i != _patterns.end(); i++) switch ((*i).searchMethod) { case State: { string path = string(_st_curDirectory) + "/" + (*i).searchPattern; struct stat buf; if (stat(path.c_str(), &buf) == 0) { _found = true; _pluginDescription = (*i).patternDescription; return _found; } else if(!(*i).caseSensitive) { char *upperBuffer = strdup((*i).searchPattern); strToUpper(upperBuffer); path = string(_st_curDirectory) + "/" + upperBuffer; free(upperBuffer); if (stat(path.c_str(), &buf) == 0) { _found = true; _pluginDescription = (*i).patternDescription; return _found; } } break; } case Find: if (TestType(_st_curDirectory, (*i).searchPattern, (*i).caseSensitive)) { _found = true; _pluginDescription = (*i).patternDescription; return _found; } break; case MediaType: if((*i).mediaT == _st_curMediaType) { _found = true; _pluginDescription = (*i).patternDescription; return _found; } break; } } } return false; }