static uiControl *spanningGrid(void) { uiGrid *g; g = newGrid(); uiGridAppend(g, testControl("0", blue), 0, 4, 4, 1, 1, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("1", green), 4, 0, 1, 4, 0, uiAlignFill, 1, uiAlignFill); uiGridAppend(g, testControl("2", red), 3, 3, 1, 1, 1, uiAlignFill, 1, uiAlignFill); uiGridAppend(g, testControl("3", yellow), 0, 3, 2, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("4", orange), 3, 0, 1, 2, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("5", purple), 1, 1, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("6", white), 0, 1, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("7", cyan), 1, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); return uiControl(g); }
static uiControl *emptyLine(void) { uiGrid *g; g = newGrid(); uiGridAppend(g, testControl("(0, 0)", red), 0, 0, 1, 1, 1, uiAlignFill, 1, uiAlignFill); uiGridAppend(g, testControl("(0, 1)", blue), 0, 1, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("(10, 0)", green), 10, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("(10, 1)", magenta), 10, 1, 1, 1, 0, uiAlignFill, 0, uiAlignFill); return uiControl(g); }
static uiControl *simpleGrid(void) { uiGrid *g; uiControl *t4; g = newGrid(); uiGridAppend(g, testControl("1", red), 0, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("2", green), 1, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("3", blue), 2, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); t4 = testControl("4", green); uiGridAppend(g, t4, 0, 1, 1, 1, 0, uiAlignFill, 1, uiAlignFill); uiGridInsertAt(g, testControl("5", blue), t4, uiAtTrailing, 2, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("6", yellow), -1, 0, 1, 2, 1, uiAlignFill, 0, uiAlignFill); return uiControl(g); }
static uiControl *emptyGrid(void) { uiGrid *g; uiControl *t; g = newGrid(); t = testControl("(0, 0)", red); uiGridAppend(g, t, 0, 0, 1, 1, 1, uiAlignFill, 1, uiAlignFill); uiControlHide(t); return uiControl(g); }
static uiControl *boxComparison(void) { uiBox *vbox; uiGrid *g; uiBox *hbox; vbox = newVerticalBox(); uiBoxAppend(vbox, uiControl(uiNewLabel("Above")), 0); uiBoxAppend(vbox, uiControl(uiNewHorizontalSeparator()), 0); hbox = newHorizontalBox(); uiBoxAppend(vbox, uiControl(hbox), 0); uiBoxAppend(hbox, testControl("1", white), 0); uiBoxAppend(hbox, uiControl(uiNewLabel("A label")), 1); uiBoxAppend(hbox, testControl("2", green), 0); uiBoxAppend(hbox, uiControl(uiNewLabel("Another label")), 1); uiBoxAppend(hbox, testControl("3", red), 0); uiBoxAppend(vbox, uiControl(uiNewHorizontalSeparator()), 0); g = newGrid(); uiBoxAppend(vbox, uiControl(g), 0); uiGridAppend(g, testControl("1", white), 0, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, uiControl(uiNewLabel("A label")), 1, 0, 1, 1, 1, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("2", green), 2, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, uiControl(uiNewLabel("Another label")), 3, 0, 1, 1, 1, uiAlignFill, 0, uiAlignFill); uiGridAppend(g, testControl("3", red), 4, 0, 1, 1, 0, uiAlignFill, 0, uiAlignFill); uiBoxAppend(vbox, uiControl(uiNewHorizontalSeparator()), 0); uiBoxAppend(vbox, uiControl(uiNewLabel("Below")), 0); return uiControl(vbox); }
int main (int argc, char** argv) { struct gameState g; struct gameState t; char testname[] = "Random Test Council Room"; int numtests = 12; int randseed = 123; int silent = 0; int i; int players; int c; while ((c = getopt(argc, argv, "t:r:q")) != -1) { switch (c) { case 't': numtests = atoi(optarg); break; case 'r': randseed = atoi(optarg); break; case 'q': silent = 1; break; default: break; } } srand(randseed); printf("Start %s\n", testname); for (i = 0; i < numtests; i++) { int handpos = rand() % 5; printf("\tRandom test number %i\n", i); memset(&g, 0, sizeof(struct gameState)); g.numPlayers = rand() % 4 + 1; g.whoseTurn = rand() % g.numPlayers; g.phase = 0; g.numActions = 1; g.numBuys = 1; for (players = 0; players <= g.numPlayers; players++) { int numcards = rand() % 90 + 10; // cards player has is in range 10 - 100 int discard = rand() % numcards; int cards; g.deckCount[players] = numcards; for (cards = 0; cards < numcards; cards++) { g.deck[players][cards] = rand() % 3 + 4; // only have copper through adventurer in deck } for (cards = 0; cards < discard; cards++) // discard some cards { drawCard(players, &g); g.discard[players][g.discardCount[players]++] = g.hand[players][0]; discardCard(0, players, &g, 1); } for (cards = 0; cards < 5; cards++) // draw 5 cards { drawCard(players, &g); } } g.coins = updateCoins(g.whoseTurn, &g, 0); t = g; testControl(&g, handpos); testDomCode(&t, handpos); if (memcmp(&t, &g, sizeof(struct gameState)) == 0) { printf("\t\tPASS\n"); } else { printf("\t\tFAIL\n"); if (silent == 0) { info(&g, &t); } } } printf("End %s\n", testname); return 0; }