예제 #1
0
void processInfoCommand() {  
  logging(DEBUG, "Current device setup:");

  Serial.print("Free memory: ");
  Serial.println(freeMemory());
  
  printActions();
  
}
예제 #2
0
bool randomTest(struct gameState *originalGame, int kingdomCards[KINGDOM_CARDS_SIZE]) {
    int player = 0;
    struct gameState testGame;
    bool allPassed = true;
    int handPos = 0;
    int bonus = 0;
    
    memcpy(&testGame, originalGame, sizeof(struct gameState));
    
    randomDeck(player, DECK_SIZE, kingdomCards, &testGame);

    // empty discard pile
    int playedCardCountBefore = testGame.playedCardCount;
    int deckCountBefore = testGame.deckCount[player];
    
    int handCountBefore = 1;
    testGame.handCount[player] = handCountBefore;
    testGame.hand[player][handPos] = village;

    int numActionsBefore = Random() * MAX_ACTIONS;
    testGame.numActions = numActionsBefore;
    
    printf("Before Play Village\n");
    printDeck(player, &testGame);
    printHand(player, &testGame);
    printPlayedCards(&testGame);
    
    printf("After Play Village\n");
    
    cardEffect(village, 0, 0, 0, &testGame, handPos, &bonus);

    
    /* Test Failed Statements */
    /* Test 1 */
    // deck decreases by 1
    printDeck(player, &testGame);
    
    int actualDeckCountAfter = testGame.deckCount[player];
    int expectedDeckCountAfter = deckCountBefore - 1;
    printf("Deck count: %d, Expected: %d\n", actualDeckCountAfter, expectedDeckCountAfter);
    
    if(actualDeckCountAfter != expectedDeckCountAfter){
        printf(">>>>>>> ERROR: TEST 1 FAILED: >>>>>>>\n");
        allPassed &= false;
    }
    
    /* Test 2 */
    // played card count increases by 1 to indicated discardCard is called.
    printPlayedCards(&testGame);
    
    int actualPlayedCardCountAfter = testGame.playedCardCount;
    int expectedPlayedCardCountAfter = playedCardCountBefore + 1;
    printf("Played card count: %d, Expected: %d\n", actualPlayedCardCountAfter, expectedPlayedCardCountAfter);
    
    if(actualPlayedCardCountAfter != expectedPlayedCardCountAfter){
        printf(">>>>>>> ERROR: TEST 2 FAILED: >>>>>>>\n");
        allPassed &= false;
    }
    
    /* Test 3 */
    // hand count should stay the same because card is drawn and village is discarded
    printHand(player, &testGame);
    
    int actualHandCountAfter = testGame.handCount[player];
    int expectedHandCountAfter = handCountBefore;
    printf("Hand count: %d, Expected: %d\n", actualHandCountAfter, expectedHandCountAfter);
    
    if(actualHandCountAfter != expectedHandCountAfter){
        printf(">>>>>>> ERROR: TEST 3 FAILED >>>>>>>\n");
        allPassed &= false;
    }
    
    /* Test 4 */
    // number of actions increased by 2
    printActions(&testGame);
    
    int actualActionsCountAfter = testGame.numActions;
    int expectedActionsCountAfter = numActionsBefore + 2;
    printf("Action count: %d, Expected: %d\n", actualActionsCountAfter, expectedActionsCountAfter);
    
    if(actualActionsCountAfter != expectedActionsCountAfter){
        printf(">>>>>>> ERROR: TEST 4 FAILED >>>>>>>\n");
        allPassed &= false;
    }
    
    return allPassed;
}