예제 #1
2
int main(int argc, char *argv[]) {

    printf("\n\n\n  ONE  \n\n");
    unittest1();
    printf("\n\n\n  TWO  \n\n");
    unittest2();
    printf("\n\n\n  THREE  \n\n");
    unittest3();
    printf("\n\n\n  FOUR  \n\n");
    unittest4();
    printf("\n\n\n  FIVE  \n\n");
    cardtest1();
    printf("\n\n\n  SIX  \n\n");
    cardtest2();
    printf("\n\n\n  SEVEN  \n\n");
    cardtest3();
    printf("\n\n\n  EIGHT  \n\n");
    cardtest4();

	return 0;
}
int main()
{
    // run tests
    unittest1();
    unittest2();
    unittest3();
    unittest4();
    cardtest1();
    cardtest2();
    cardtest3();
    cardtest4();

    return 0;
}
예제 #3
0
파일: unittest1.c 프로젝트: cr8zd/cs362w16
int main() {

	int num_players = 2;
	int random_seed = 1000;
	struct gameState state;
  struct gameState pre;
	int max_hand = 5;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
         sea_hag, tribute, smithy};
  int pre_hand[MAX_HAND_TEST];

  int g = initializeGame(num_players, k, random_seed, &state);
  memcpy(&pre, &state, sizeof(struct gameState));
  
  printf("---------------- Testing %s Function ----------------\n", TEST_FUNC);

  // For each trash flag
  int trash;
  for (trash = 0; trash <= 1; trash++)
  {
    if (trash)
    {
      printf("Discard to trash, ");
    } else
    {
      printf("Discard to discard pile, ");
    }
  	// For each player
    int player;
  	for (player = 0; player <=1; player++)
  	{
      printf("for player %d, ", player);
  		// For each possible hand size
      int hand_size;
  		for (hand_size = 1; hand_size <= MAX_HAND_TEST; hand_size++)
  		{
        printf("for hand size %d, ", hand_size);
  			state.handCount[player] = hand_size;
        pre.handCount[player] = hand_size;
  			// For each possible hand position
        int hand_pos;
        for (hand_pos = 0; hand_pos < hand_size; hand_pos++)
  			{
          printf("from hand position %d\n", hand_pos);
          discardCard(hand_pos, player, &state, trash);

          if (trash == 0)
          {
            // Check the playedCardCount
            assert(state.playedCardCount == pre.playedCardCount + 1);
          } else
          {
            // Check the playedCardCount
            assert(state.playedCardCount == pre.playedCardCount);
          }

				  // If it is the last hand position
          if (hand_pos == hand_size - 1) 
          {
  				  printf("Discarding card from last hand position\n");
            
            // Did the order of the cards not change?
  			    assert(strncmp(state.hand[player], pre.hand[player], hand_size - 1) == 0);
          
          // Else if it is the last card
          } else if (hand_size == 1)
          {
            printf("Discarding final card in hand\n");
  				 
            // Is there no hand?
            assert(state.handCount[player] == 0);

          } else 
          {
            printf("Filling discarded card's hole in hand\n");

  			    // Else did we correctly replace the discarded card?
            assert(state.hand[player][hand_pos] == pre.hand[player][hand_size - 1]);
          }
  			  
          // Did handCount decrease by 1 relative to hand size?
          assert(state.handCount[player] == pre.handCount[player] - 1);

          // Copy our current gamestate to negate discard
          memcpy(&state, &pre, sizeof(struct gameState));
          printf("Passed\n");
  			}
  		}	
  	}
  }

  printf("\nUNIT TEST 1 PASSED.\n\n");

  int res2 = test2();
  int res3 = test3();
  int res4 = test4();

  int cres1 = cardtest1();
  int cres2 = cardtest2();
  int cres3 = cardtest3();
  int cres4 = cardtest4();


	return 0;
}