Exemplo n.º 1
0
void TestMidi::midi3()
      {
      MCursor c;
      c.createScore("test3a");
      c.addPart("voice");
      c.move(0, 0);     // move to track 0 tick 0

      c.addKeySig(1);
      c.addTimeSig(Fraction(4,4));
      c.addChord(60, TDuration(TDuration::V_QUARTER));
      c.addChord(61, TDuration(TDuration::V_QUARTER));
      c.addChord(62, TDuration(TDuration::V_QUARTER));
      c.addChord(63, TDuration(TDuration::V_QUARTER));
      Score* score = c.score();

      score->doLayout();
      score->rebuildMidiMapping();
      c.saveScore();
      saveMidi(score, "test3.mid");

      Score* score2 = new Score(mscore->baseStyle());
      score2->setName("test3b");
      QVERIFY(importMidi(score2, "test3.mid"));

      score2->doLayout();
      score2->rebuildMidiMapping();
      MCursor c2(score2);
      c2.saveScore();

      QVERIFY(compareScores(score, score2));

      delete score;
      delete score2;
      }
Exemplo n.º 2
0
int main() {
    int i;
    int seed = 1000;
    int p, r, handCount;
    int bonus;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
		int *scoreBuffer;
		int *expectedScoreBuffer;
		int numPlayersTest = 0;
		int handSize = MAX_HAND;
		int deckSize = 100;
		int discardSize = 2;
		
		//Initialize the hands to hold only coppers
		int noPoints[MAX_HAND];
		for (i = 0; i < MAX_HAND; i++){
			noPoints[i] = copper;
		}
		
    printf ("TESTING scoreFor():\n");


#if (NOISY_TEST == 1)
		printf("Player with all coppers.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give all players noPoints
		for (i = 0; i < numPlayersTest; i++){
			memcpy(G.hand[i], noPoints, sizeof(int) * MAX_HAND);
		}
		//Run the code
		compareScores(0, 0, &G);

		
#if (NOISY_TEST == 1)
		printf("Player with one estate in hand.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one estate
		memcpy(G.hand[0], noPoints, sizeof(int) * MAX_HAND);
		G.hand[0][G.handCount[0]-1] = estate;
		//Run the code
		compareScores(1, 0, &G);

		
#if (NOISY_TEST == 1)
		printf("Player with one duchy in hand.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one duchy
		memcpy(G.hand[0], noPoints, sizeof(int) * MAX_HAND);
		G.hand[0][G.handCount[0]-1] = duchy;
		//Run the code
		compareScores(3, 0, &G);

		
#if (NOISY_TEST == 1)
		printf("Player with one province in hand.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one province
		memcpy(G.hand[0], noPoints, sizeof(int) * MAX_HAND);
		G.hand[0][G.handCount[0]-1] = province;
		//Run the code
		compareScores(6, 0, &G);

		
#if (NOISY_TEST == 1)
		printf("Player with one estate and one duchy in hand.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one estate and one duchy
		memcpy(G.hand[0], noPoints, sizeof(int) * MAX_HAND);
		G.hand[0][G.handCount[0]-1] = estate;
		G.hand[0][G.handCount[0]-2] = duchy;
		//Run the code
		compareScores(4, 0, &G);
		

#if (NOISY_TEST == 1)
		printf("Player with one estate, one duchy and one province in hand.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one estate, one duchy and one province
		memcpy(G.hand[0], noPoints, sizeof(int) * MAX_HAND);
		G.hand[0][G.handCount[0]-1] = estate;
		G.hand[0][G.handCount[0]-2] = duchy;
		G.hand[0][G.handCount[0]-3] = province;
		//Run the code
		compareScores(10, 0, &G);

		
#if (NOISY_TEST == 1)
		printf("Player with one estate in discard.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		//Give the player one estate in discard
		for(i = 0; i < discardSize; i++)
			G.discard[0][i] = copper;
		G.discard[0][0] = estate;
		//Run the code
		compareScores(1, 0, &G);
		

#if (NOISY_TEST == 1)
		printf("Player with one estate in deck.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		
		G.deckCount[0] = 10;
		G.discardCount[0] = 2;
		
		//Give the player one estate in deck
		for(i = 0; i < G.handCount[0]; i++)
			G.hand[0][i] = copper;
		for(i = 0; i < G.discardCount[0]; i++)
			G.discard[0][i] = copper;
		for(i = 0; i < G.deckCount[0]; i++)
			G.deck[0][i] = copper;
		G.deck[0][0] = estate;
		
		//Run the code
		compareScores(1, 0, &G);
		

#if (NOISY_TEST == 1)
		printf("Player with one estate in hand, discard and deck.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		G.discardCount[0] = 2;
		//Give the player one estate in deck
		for(i = 0; i < G.handCount[0]; i++)
			G.hand[0][i] = copper;
		for(i = 0; i < G.discardCount[0]; i++)
			G.discard[0][i] = copper;
		for(i = 0; i < G.deckCount[0]; i++)
			G.deck[0][i] = copper;
		G.hand[0][0] = estate;
		G.discard[0][0] = estate;
		G.deck[0][0] = estate;
		
		//Run the code
		compareScores(3, 0, &G);
		

#if (NOISY_TEST == 1)
		printf("Player with multiple victory cards in hand, discard and deck.\n");
#endif
		numPlayersTest = 2;
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayersTest, k, seed, &G); // initialize a new game
		G.discardCount[0] = 2;
		//Give the player one estate in deck
		for(i = 0; i < G.handCount[0]; i++)
			G.hand[0][i] = copper;
		for(i = 0; i < G.discardCount[0]; i++)
			G.discard[0][i] = copper;
		for(i = 0; i < G.deckCount[0]; i++)
			G.deck[0][i] = copper;
		G.hand[0][0] = estate;
		G.hand[0][1] = province;
		G.discard[0][0] = estate;
		G.discard[0][1] = duchy;
		G.deck[0][0] = estate;
		G.deck[0][1] = estate;
		
		//Run the code
		compareScores(13, 0, &G);
		
		
		return 0;
		
}