Example #1
0
int main ()
{
  int i, n;
  int currentPass = 0;
  int totalPass = 0;
  int totalTests = 0;

  struct gameState G;

  int smithyPos;

  SelectStream(1);
  PutSeed(-1);
  Random();

  //Begin testing--------------------------------------------------------------
  printf("------------------------------------------------------------\n");
  printf("------------BEGIN RANDOM TESTING FOR SMITHY CARD------------\n");
  printf("------------------------------------------------------------\n");

  for (n = 0; n < 2000; n++) {
    //clear out the game state with all random values
    for (i = 0; i < sizeof(struct gameState); i++) {
      ((char*)&G)[i] = floor(Random() * 256);
    }

    //set random hand
    G.handCount[0] = floor(Random() * MAX_HAND);
    for (i = 0; i < G.handCount[0]; i++) {
      G.hand[0][i] = floor(Random() * 27);
    }

    //place smithy in random spot
    smithyPos = floor(Random() * G.handCount[0]);
    G.hand[0][smithyPos] = smithy;

    //set random deck count
    G.deckCount[0] = floor(Random() * MAX_DECK);

    //set random discard count
    G.discardCount[0] = floor(Random() * MAX_DECK);

    printf("Test results for test: %d\n", n);
    currentPass = testSmithyCard(&G, smithyPos);
    printf("Tests passed: %d out of 3\n", currentPass);
    printf("\n");

    totalPass += currentPass;
    totalTests += 3;
  }

  printf("------------------------------------------------------------\n");
  printf("-----------------RESULTS of random testing -----------------\n");
  printf("Total Tests: %d\n", totalTests);
  printf("Tests Passed: %d\tTests Failed: %d\n", totalPass, totalTests - totalPass);
  printf("------------------------------------------------------------\n");

  return 0;
}
Example #2
0
int main(){
	testSmithyCard();
	return 0;
}
int main() {
    return testSmithyCard();    
}