Esempio n. 1
0
// Returns 0 if success, 1 if a model error, 2 if an emit error.
int TestCFSM::processResults(QTextStream &in)
{
    while(!in.atEnd())
    {
        QString line = in.readLine();
        // Blank lines and comments.
        if((line.size() == 0) || (line[0] == QChar('#')))
            continue;
        else if(line == "results:")
            continue;
        else if((line[0] == QChar('0')) || line[0] == QChar('1') ||
                (line[0] == QChar('2')))
        {
            QString lineRelname  = getRelname(line);
            int     desiredState = getLineState(line);
            int     modelState   = getCheckedStateInt(line);
            if(desiredState != modelState)
            {
                // Test failed!
                return (1);
            }
        }
        else
        {
            QTextStream console(stdout);
            console << "ERROR: Scenario file is broken; parsing died on line:"
                    << endl
                    << line << endl;
            // Don't try to recover.
            QApplication::exit(1);
        }
    }
    return (0);
}
Esempio n. 2
0
void commonPort::checkControls( void )
{
   getLineState();
   for ( std::vector<commonLineControl *>::iterator i = lines.begin(); i != lines.end(); i++ )
   {
      // output lines can't sort their state in the same way
      if ( ( *i ) ->lineIn )
      {
         ( *i ) ->checkLine();
      }
   }
}
Esempio n. 3
0
bool TicTacToe::checkForWinner(CCObject* obj) {
    Mark* m = (Mark*) obj;
    CCLog("checking line with [%d, %d]: %d", m->getX(), m->getY(), m->getState());
    int16_t winner = -1;
    LINE_DIRECTION dir;
    for(int16_t d = 0; d < DIR_END; d++) {
        dir = LINE_DIRECTION(d);
        auto s = getLineState(m->getX(), m->getY(), dir);
        winner = checkFor3Marks(s);
        CCLog("dir: %d, winner: %d", dir, winner);
        if (winner >= 0) break;
    }
    if (winner>=0) {
        drawWinLine(m->getX(), m->getY(), dir, m);
    }
    CCLog("Found winner: %s (%d)", winner >= 0 ? "yes" : "no", winner);
    return false;
}