Skip to content

Commit f60c31a

Browse files
author
Ali Aburas
committed
Added Dominion Folder and README.md with my name and onid
1 parent bbe18e5 commit f60c31a

38 files changed

+6007
-0
lines changed

dominion/Makefile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
CFLAGS = -Wall -fpic -coverage -lm
2+
3+
rngs.o: rngs.h rngs.c
4+
gcc -c rngs.c -g $(CFLAGS)
5+
6+
dominion.o: dominion.h dominion.c rngs.o
7+
gcc -c dominion.c -g $(CFLAGS)
8+
9+
playdom: dominion.o playdom.c
10+
gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)
11+
#To run playdom you need to entere: ./playdom <any integer number> like ./playdom 10*/
12+
testDrawCard: testDrawCard.c dominion.o rngs.o
13+
gcc -o testDrawCard -g testDrawCard.c dominion.o rngs.o $(CFLAGS)
14+
15+
badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
16+
gcc -o badTestDrawCard -g badTestDrawCard.c dominion.o rngs.o $(CFLAGS)
17+
18+
testBuyCard: testDrawCard.c dominion.o rngs.o
19+
gcc -o testDrawCard -g testDrawCard.c dominion.o rngs.o $(CFLAGS)
20+
21+
testAll: dominion.o testSuite.c
22+
gcc -o testSuite testSuite.c -g dominion.o rngs.o $(CFLAGS)
23+
24+
interface.o: interface.h interface.c
25+
gcc -c interface.c -g $(CFLAGS)
26+
27+
runtests: testDrawCard
28+
./testDrawCard &> unittestresult.out
29+
gcov dominion.c >> unittestresult.out
30+
cat dominion.c.gcov >> unittestresult.out
31+
32+
33+
player: player.c interface.o
34+
gcc -o player player.c -g dominion.o rngs.o interface.o $(CFLAGS)
35+
36+
all: playdom player testDrawCard testBuyCard badTestDrawCard
37+
38+
clean:
39+
rm -f *.o playdom.exe playdom player player.exe *.gcov *.gcda *.gcno *.so *.out testDrawCard testDrawCard.exe

dominion/badTestDrawCard.c

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "dominion.h"
2+
#include "dominion_helpers.h"
3+
#include <string.h>
4+
#include <stdio.h>
5+
#include <assert.h>
6+
#include "rngs.h"
7+
8+
#define DEBUG 0
9+
#define NOISY_TEST 1
10+
11+
int checkDrawCard(int p, struct gameState *post) {
12+
int r;
13+
14+
r = drawCard (p, post);
15+
}
16+
17+
int main () {
18+
19+
int i, n, r, p, deckCount, discardCount, handCount;
20+
21+
int k[10] = {adventurer, council_room, feast, gardens, mine,
22+
remodel, smithy, village, baron, great_hall};
23+
24+
struct gameState G;
25+
26+
printf ("Testing drawCard.\n");
27+
28+
printf ("RANDOM TESTS.\n");
29+
30+
SelectStream(2);
31+
PutSeed(3);
32+
33+
for (n = 0; n < 2000; n++) {
34+
for (i = 0; i < sizeof(struct gameState); i++) {
35+
((char*)&G)[i] = floor(Random() * 256);
36+
}
37+
p = floor(Random() * 1000);
38+
checkDrawCard(p, &G);
39+
}
40+
41+
printf ("ALL TESTS OK\n");
42+
43+
exit(0);
44+
}

dominion/betterTestDrawCard.c

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "dominion.h"
2+
#include "dominion_helpers.h"
3+
#include <string.h>
4+
#include <stdio.h>
5+
#include <assert.h>
6+
#include "rngs.h"
7+
8+
#define DEBUG 0
9+
#define NOISY_TEST 1
10+
11+
int checkDrawCard(int p, struct gameState *post) {
12+
int r;
13+
14+
r = drawCard (p, post);
15+
16+
assert (r == 0);
17+
}
18+
19+
int main () {
20+
21+
int i, n, r, p, deckCount, discardCount, handCount;
22+
23+
int k[10] = {adventurer, council_room, feast, gardens, mine,
24+
remodel, smithy, village, baron, great_hall};
25+
26+
struct gameState G;
27+
28+
printf ("Testing drawCard.\n");
29+
30+
printf ("RANDOM TESTS.\n");
31+
32+
SelectStream(2);
33+
PutSeed(3);
34+
35+
for (n = 0; n < 2000; n++) {
36+
for (i = 0; i < sizeof(struct gameState); i++) {
37+
((char*)&G)[i] = floor(Random() * 256);
38+
}
39+
p = floor(Random() * 2);
40+
G.deckCount[p] = floor(Random() * MAX_DECK);
41+
G.discardCount[p] = floor(Random() * MAX_DECK);
42+
G.handCount[p] = floor(Random() * MAX_HAND);
43+
checkDrawCard(p, &G);
44+
}
45+
46+
printf ("ALL TESTS OK\n");
47+
48+
exit(0);
49+
50+
printf ("SIMPLE FIXED TESTS.\n");
51+
for (p = 0; p < 2; p++) {
52+
for (deckCount = 0; deckCount < 5; deckCount++) {
53+
for (discardCount = 0; discardCount < 5; discardCount++) {
54+
for (handCount = 0; handCount < 5; handCount++) {
55+
memset(&G, 23, sizeof(struct gameState));
56+
r = initializeGame(2, k, 1, &G);
57+
G.deckCount[p] = deckCount;
58+
memset(G.deck[p], 0, sizeof(int) * deckCount);
59+
G.discardCount[p] = discardCount;
60+
memset(G.discard[p], 0, sizeof(int) * discardCount);
61+
G.handCount[p] = handCount;
62+
memset(G.hand[p], 0, sizeof(int) * handCount);
63+
checkDrawCard(p, &G);
64+
}
65+
}
66+
}
67+
}
68+
69+
return 0;
70+
}

0 commit comments

Comments
 (0)