Ejemplo n.º 1
0
int main () {

    int i, n, r, p, deckCount, discardCount, handCount;

    int k[10] = {adventurer, council_room, feast, gardens, mine,
                 remodel, smithy, village, baron, great_hall
                };

    struct gameState G;

    printf ("Testing drawCard.\n");

    printf ("RANDOM TESTS.\n");

    SelectStream(2);
    PutSeed(3);

    for (n = 0; n < 2000; n++) {
        for (i = 0; i < sizeof(struct gameState); i++) {
            ((char*)&G)[i] = floor(Random() * 256);
        }
        p = floor(Random() * 2);
        G.deckCount[p] = floor(Random() * MAX_DECK);
        G.discardCount[p] = floor(Random() * MAX_DECK);
        G.handCount[p] = floor(Random() * MAX_HAND);
        checkDrawCard(p, &G);
    }

    printf ("ALL TESTS OK\n");

    return 0;

    printf ("SIMPLE FIXED TESTS.\n");
    for (p = 0; p < 2; p++) {
        for (deckCount = 0; deckCount < 5; deckCount++) {
            for (discardCount = 0; discardCount < 5; discardCount++) {
                for (handCount = 0; handCount < 5; handCount++) {
                    memset(&G, 23, sizeof(struct gameState));
                    r = initializeGame(2, k, 1, &G);
                    G.deckCount[p] = deckCount;
                    memset(G.deck[p], 0, sizeof(int) * deckCount);
                    G.discardCount[p] = discardCount;
                    memset(G.discard[p], 0, sizeof(int) * discardCount);
                    G.handCount[p] = handCount;
                    memset(G.hand[p], 0, sizeof(int) * handCount);
                    checkDrawCard(p, &G);
                }
            }
        }
    }

    return 0;
}
int main () {

    int i, n, r, p, deckCount, discardCount, handCount;

    int k[10] = {adventurer, council_room, feast, gardens, mine,
                 remodel, smithy, village, baron, great_hall};

    struct gameState G;

    printf ("Testing drawCard.\n");

    printf ("RANDOM TESTS.\n");

    SelectStream(2);
    PutSeed(3);

    for (n = 0; n < 2000; n++) {
        for (i = 0; i < sizeof(struct gameState); i++) {
            ((char*)&G)[i] = floor(Random() * 256);
        }
        p = floor(Random() * 1000);
        checkDrawCard(p, &G);
    }

    printf ("ALL TESTS OK\n");

    exit(0);
}
Ejemplo n.º 3
0
int main (){
   
     int seed = 1000;
     int numPlayer = 2;
     int flag; //0=no cards in deck, 
     int r;
     int result = 0;
     bool pass = true;
     int p=0;

     int k[10] = { adventurer, council_room, feast, gardens, mine
          , remodel, smithy, village, baron, great_hall };
     struct gameState G;
     
     memset(&G, 23, sizeof(struct gameState));   // clear the game state
     r = initializeGame(numPlayer, k, seed, &G); // initialize a new game

     printf("TESTING DRAW CARD\n");

     for(p=0; p<numPlayer; p++){
       printf("Testing for player %d\n", p+1);

      /*EDGE CASES*/
       //CHECK for 0 cards in deck
       printf("Testing for no cards in deck\n");
       flag = 0;
       G.deckCount[p] = 0;
       setDiscardDeck(p, &G);
       result = checkDrawCard(p, &G, flag);
       if (result == -1){
            pass = false;
       }

       //check for neg cards in deck
       printf("Testing for neg cards in deck\n");
       flag = 0;
       G.deckCount[p] = -5;
       setDiscardDeck(p, &G);
       result = checkDrawCard(p, &G, flag);
       if (result == -1){
            pass = false;
       }
       
       //testing for max cards in deck
       printf("Testing for max cards in deck\n");
       flag = 1;
       G.deckCount[p] = MAX_DECK;
       setDeck(p, &G);
       result = checkDrawCard(p, &G, flag);
       if (result == -1){
            pass = false;
       }

     
       /**NORMAL CASES**/
       printf("Testing for 10 cards in deck\n");
       flag = 1;
       G.deckCount[p] = 10;
       setDiscardDeck(p, &G);
       result = checkDrawCard(p, &G, flag);
       if (result == -1){
            pass = false;
       }

       //check for 0 cards in hand
       printf("Testing for 0 cards in hand\n");
       flag = 1;
       G.deckCount[p] = 10;
       G.handCount[p] =0;
       setDiscardDeck(p, &G);
       result = checkDrawCard(p, &G, flag);
       if (result == -1){
            pass = false;
       }




       if (pass == true){
         printf("ALL TESTS PASSED!\n");
       }else{
         printf("FAILURES\n");
       }

     }


  return 0;
}