예제 #1
0
int testAll() {
  Debug::init();
  testStringConvertion();
  testTimeQueue();
  testRectangleIterator();
  testValueCheck();
  testSplit();
  testShortestPath();
  testAStar();
  testShortestPath2();
  testShortestPathReverse();
  testRange();
  testRange2();
  testContains();
  testPredicates();
  testOptional();
  testMustInitialize();
  testVec2();
  testConcat();
  testTable();
  testVec2();
  testRectangle();
  testProjection();
  testRandomExit();
  testCombine();
  testSectors1();
  testSectors2();
  testSectors3();
  testReverse();
  testReverse2();
  testReverse3();
  Debug() << "-----===== OK =====-----";
  return 0;
}
예제 #2
0
int main( int argc, char * argv[] )
{
	testList();

	testTable();

	return 0;
}
예제 #3
0
int main(int argc, char** argv){
	testPair();
	testVector();
	testList();
	testHash();
	testTable();
	return 0;
}
예제 #4
0
  //----------------------------------------------------------------------
  void CondProbTableTest::RunTests()
  {
    // Our 4 rows
    vector<vector<Real> > rows;
    rows.resize(numRows());
    rows[0] = makeRow((Real)0.0, (Real)0.4, (Real)0.0);
    rows[1] = makeRow((Real)1.0, (Real)0.0, (Real)0.0);
    rows[2] = makeRow((Real)0.0, (Real)0.0, (Real)0.6);
    rows[3] = makeRow((Real)0.0, (Real)0.6, (Real)0.4);

    // Test constructing without # of columns
    {
      CondProbTable table;
      
      // Add the 4 rows
      for (Size i=0; i<numRows(); i++)
        table.updateRow((UInt)i, rows[i]);
      
      // Test it
      testTable ("Dynamic columns:", table, rows);
    }


    // Test constructing and growing the columns dynamically
    {
      CondProbTable table;
      
      // Add the 2nd row first which has just 1 column
      vector<Real> row1(1);
      row1[0] = rows[1][0];
      table.updateRow(1, row1);
    
      // Add the first row first with just 2 columns
      vector<Real> row0(2);
      row0[0] = rows[0][0];
      row0[1] = rows[0][1];
      table.updateRow(0, row0);
    
      for (Size i=2; i<numRows(); i++)
        table.updateRow((UInt)i, rows[i]);
      
      // Test it
      testTable ("Growing columns:", table, rows);
    }


    // Make a table with 3 columns
    {
      CondProbTable table((UInt)numCols());
    
      // Add the 4 rows
      for (Size i=0; i<numRows(); i++)
        table.updateRow((UInt)i, rows[i]);
      
      // Test it
      testTable ("Fixed columns:", table, rows);
    }
  
  
    // Make a table, save to stream, then reload and test
    {
      CondProbTable table((UInt)numCols());
    
      // Add the 4 rows
      for (Size i=0; i<numRows(); i++)
        table.updateRow((UInt)i, rows[i]);
      
      // Save it
      stringstream state;
      table.saveState (state);
    
      CondProbTable newTable;
      newTable.readState (state);
      testTable ("Restored from state:", newTable, rows);
    }
  
        
    // Test saving an empty table
    {
      CondProbTable table;
      
      // Save it
      stringstream state;
      table.saveState (state);
    
      // Read it in
      CondProbTable newTable;
      newTable.readState (state);

      // Add the 4 rows
      for (Size i=0; i<numRows(); i++)
        newTable.updateRow((UInt)i, rows[i]);
      
      // Test it
      testTable ("Restored from empty state:", newTable, rows);
    }


  }
예제 #5
0
void main(int argc, char *argv[]){

    char *filename = argv[1];
    FILE *fp;

    if(strcmp(filename, "-s") == 0){
        testStack();
        exit(0);
    }
    if(strcmp(filename, "-t") == 0){
        testTable();
        exit(0);
    }
    if(strcmp(filename, "-i") == 0){
        testInstruction();
        exit(0);
    }


    if(argc == 1){
        printf("Proper use: wi <filename.wic>\n");
        exit(0);
    }
    else if((fp = fopen(filename, "r")) == NULL)
    {
        printf("Error opening file.  File doesn't exist.\n");
        exit(0);
    }
    
    initialize();

    char opcode[OPCODE_SIZE];
    char operand[OPERAND_SIZE];
    int address = 0;
    while(fscanf(fp, "%s", opcode) != EOF){
        if(hasOperand(opcode)){
            if(fscanf(fp, "%s", operand) == EOF){
                insertInstruction(address, opcode, operand);
                address++;
                break;
            }
        }
        if(!validOp(opcode)){
            if(fscanf(fp, "%s", operand) != EOF && strcmp(operand, "label") == 0){
                char temp[OPERAND_SIZE];
                strcpy(temp, operand);
                strcpy(operand, opcode);
                strcpy(opcode, temp);
            }
            else{
                printf("Invalid opcode: %s\n", opcode);
                exit(0);
            }
        }
        else if(hasOperand(opcode) == 0){
            strcpy(operand, "");
        }
        insertInstruction(address, opcode, operand);
        address++;
        //discard the rest of the line
        while(fgetc(fp) != '\n'){};
    }
    fclose(fp);

    runProgram();
}