int main() { int numPlayers = 2; int kingdomCards[10] = {smithy, adventurer, gardens, embargo, great_hall, mine, ambassador, outpost, baron, tribute}; int randomSeed = 15; struct gameState state; int result = 0; int oldHandCount, newHandCount; int oldActionCount, newActionCount; printf("CARDTEST3: GREAT HALL\n"); initializeGame(numPlayers, kingdomCards, randomSeed, &state); oldHandCount = numHandCards(&state); oldActionCount = state.numActions; //int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus); //TEST GREAT HALL result = cardEffect(great_hall, 0, 0, 0, &state, 1, NULL); assertc(result, "Completely failed Great Hall"); newHandCount = numHandCards(&state); assertSame(oldHandCount, newHandCount, "Hand sizes aren't the same"); newActionCount = state.numActions; assertDiff(oldActionCount, newActionCount, "Actions didn't change"); if (newActionCount == oldActionCount + 1) { result = 0; } assertc(result, "Actions didn't increment by 1"); checkFail(); return 0; }
int main() { int numPlayers = 2; int kingdomCards[10] = {smithy, adventurer, gardens, embargo, cutpurse, mine, ambassador, outpost, baron, tribute}; int randomSeed = 15; struct gameState state; int result = 0; printf("UNITTEST2: WHOSE TURN\n"); initializeGame(numPlayers, kingdomCards, randomSeed, &state); result = whoseTurn(&state); assertc(result == 1, "Should be Player 1's turn"); checkFail(); return 0; }
// check input and input with appended metadata void checkMeta (std::string const& input, bool shouldPass) { checkPass (input, shouldPass); checkPass (input + "+a", shouldPass); checkPass (input + "+1", shouldPass); checkPass (input + "+a.b", shouldPass); checkPass (input + "+ab.cd", shouldPass); checkFail (input + "!"); checkFail (input + "+"); checkFail (input + "++"); checkFail (input + "+!"); checkFail (input + "+."); checkFail (input + "+a.!"); }
int main() { int i, devCount; CUdevice dev; CUdevprop prop; CUresult e; cuInit(0); cuDeviceGetCount(&devCount); for(i = 0; i < devCount; i++) { e = cuDeviceGet(&dev, i); if(e != CUDA_SUCCESS) { printf("cuDeviceGet(%d) failed\n", i); continue; } e = cuDeviceGetProperties(&prop, dev); if(e != CUDA_SUCCESS) { printf("Could not get device properties"); continue; } printf("Card #%02d:\n", i); printf("\tName: "); { char buf[1024]; e = cuDeviceGetName(buf, 1024, dev); checkFail(e) || printf("%s", buf); printf("\n"); } printf("\tCompute capability: "); { int major, minor; e = cuDeviceComputeCapability(&major, &minor, dev); checkFail(e) || printf("%d.%d", major, minor); printf("\n"); } printf("\tTotal memory: "); { size_t mem; e = cuDeviceTotalMem(&mem, dev); checkFail(e) || printf("%lu bytes", mem); printf("\n"); } printf("\tClock rate: "); { printf("%d kHz", prop.clockRate); printf("\n"); } printf("\tGrid dimensions: "); { printf("%d x %d x %d", prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]); printf("\n"); } printf("\tThread dimensions: "); { printf("%d x %d x %d", prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]); printf("\n"); } printf("\tThreads per block: "); { printf("%d", prop.maxThreadsPerBlock); printf("\n"); } printf("\tShared memory per block: "); { printf("%d bytes", prop.sharedMemPerBlock); printf("\n"); } printf("\tConstant memory: "); { printf("%d bytes", prop.totalConstantMemory); printf("\n"); } printf("\tWarp size: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_WARP_SIZE, dev); checkFail(e) || printf("%d", attr); printf("\n"); } printf("\tNumber of multiprocessors: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, dev); checkFail(e) || printf("%d", attr); printf("\n"); } printf("\tIs integrated: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_INTEGRATED, dev); checkFail(e) || printf("%s", attr!=0?"yes":"no"); printf("\n"); } printf("\tCan map host memory: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY, dev); checkFail(e) || printf("%s", attr!=0?"yes":"no"); printf("\n"); } printf("\tCan execute multiple kernels: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS, dev); checkFail(e) || printf("%s", attr!=0?"yes":"no"); printf("\n"); } printf("\tThreads per multiprocessor: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR, dev); checkFail(e) || printf("%d", attr); printf("\n"); } printf("\tAsynchronous engines: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT, dev); checkFail(e) || printf("%d", attr); printf("\n"); } printf("\tShares address space with host: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, dev); checkFail(e) || printf("%s", attr!=0?"yes":"no"); printf("\n"); } printf("\tL2 cache: "); { int attr; e = cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE, dev); checkFail(e) || printf("%d bytes", attr); printf("\n"); } } }