Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/neibauri/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Isaac Neibaur, Neibauri
39 changes: 39 additions & 0 deletions projects/neibauri/dominion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CFLAGS= -Wall -fpic -coverage -lm -std=c99

rngs.o: rngs.h rngs.c
gcc -c rngs.c -g $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
gcc -c dominion.c -g $(CFLAGS)

playdom: dominion.o playdom.c
gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)
#To run playdom you need to entere: ./playdom <any integer number> like ./playdom 10*/
testDrawCard: testDrawCard.c dominion.o rngs.o
gcc -o testDrawCard -g testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
gcc -o badTestDrawCard -g badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
gcc -o testDrawCard -g testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
gcc -o testSuite testSuite.c -g dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
gcc -c interface.c -g $(CFLAGS)

runtests: testDrawCard
./testDrawCard &> unittestresult.out
gcov dominion.c >> unittestresult.out
cat dominion.c.gcov >> unittestresult.out


player: player.c interface.o
gcc -o player player.c -g dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player

clean:
rm -f *.o playdom.exe playdom player player.exe *.gcov *.gcda *.gcno *.so *.out testDrawCard testDrawCard.exe
2 changes: 2 additions & 0 deletions projects/neibauri/dominion/READM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run make all #To compile the dominion code
run ./playdom 30 # to run playdom code
Binary file added projects/neibauri/dominion/badTestDrawCard
Binary file not shown.
44 changes: 44 additions & 0 deletions projects/neibauri/dominion/badTestDrawCard.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int checkDrawCard(int p, struct gameState *post) {
int r;

r = drawCard (p, post);
}

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);
}
70 changes: 70 additions & 0 deletions projects/neibauri/dominion/betterTestDrawCard.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int checkDrawCard(int p, struct gameState *post) {
int r;

r = drawCard (p, post);

assert (r == 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");

exit(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;
}
Loading