示例#1
0
void testRemoveNode() {
  // printf("\n%s\n","calling from in here");

		struct BSTree *tree = buildBSTTree();
	//	printf("\n%s\n","tree built");
		struct Node *cur;
	//	printf("\n%s\n","ptr made");
		struct data myData1,  myData2,  myData3,  myData4;
	//	printf("\n%s\n","structs defined");
	myData1.number = 50;
	myData1.name = "rooty";
	myData2.number = 13;
	myData2.name = "lefty";
	myData3.number = 110;
	myData3.name = "righty";
	myData4.number = 10;
	myData4.name = "lefty of lefty";

	//printf("\n%s\n","calling remove node");
    _removeNode(tree->root, &myData4);
    printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->left->left == NULL, "_removeNode", "remove left of left of root 1st try");

    _removeNode(tree->root, &myData3);
	 printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->right == NULL, "_removeNode", "remove right of root 2st try");

    _removeNode(tree->root, &myData2);
	printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->left == 0, "_removeNode", "remove right of root 3st try");

    cur = _removeNode(tree->root, &myData1);
    printTestResult(cur == NULL, "_removeNode", "remove right of root 4st try");
}
示例#2
0
文件: bst.c 项目: nguyminh/CS-261
/*
fucntion to test that the BST contains the elements that we added to it

*/
void testContainsBSTree() {
    struct BSTree *tree = buildBSTTree();
    
    struct data myData1,  myData2,  myData3,  myData4, myData5;
	
	myData1.number = 50;
	myData1.name = "rooty";
	myData2.number = 13;
	myData2.name = "lefty";
	myData3.number = 110;
	myData3.name = "righty";
	myData4.number = 10;
	myData4.name = "lefty of lefty";
    myData5.number = 111;
	myData5.name = "not in tree";
    
    printTestResult(containsBSTree(tree, &myData1), "containsBSTree", "when test containing 50 as root");
        
    printTestResult(containsBSTree(tree, &myData2), "containsBSTree", "when test containing 13 as left of root");
    
	printTestResult(containsBSTree(tree, &myData3), "containsBSTree", "when test containing 110 as right of root");
        
    printTestResult(containsBSTree(tree, &myData4), "containsBSTree", "when test containing 10 as left of left of root");

     //check containsBSTree fucntion when the tree does not contain a node    
    printTestResult(!containsBSTree(tree, &myData5), "containsBSTree", "when test containing 111, which is not in the tree");
    
}
示例#3
0
int main() {
    struct gameState G;
    int randomSeed = rand();
    int player = 0;
    int choice1, choice2, choice3;
    int handPos = 0;
    int *bonus;

    int i;

    int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
    sea_hag, tribute, smithy};

    printf("\nStarting test for Village...\n\n");

    initializeGame(2, k, randomSeed, &G);

    printTestResult(G.handCount[0] == 5, "Expected Value 5", "Starting Hand Count");
    printTestResult(G.numActions == 1, "Expected Value 1", "Starting Number of Actions");

    cardEffect(village, 0, 0, 0, &G, 0, 0);

    printTestResult(G.handCount[0] == 6, "Expected Value 6", "Ending Hand Count");
    printTestResult(G.numActions == 3, "Expected Value 3", "Ending Number of Actions");

    printf("\n\n\nEnd Test\n");
}
示例#4
0
文件: bst.c 项目: nguyminh/CS-261
void testRemoveNode() {
    struct BSTree *tree = buildBSTTree();
    struct Node *cur;
     struct data myData1,  myData2,  myData3,  myData4;
		
	myData1.number = 50;
	myData1.name = "rooty";
	myData2.number = 13;
	myData2.name = "lefty";
	myData3.number = 110;
	myData3.name = "righty";
	myData4.number = 10;
	myData4.name = "lefty of lefty";
    
    _removeNode(tree->root, &myData4);
    printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->left->left == NULL, "_removeNode", "remove left of left of root 1st try");
	        
    _removeNode(tree->root, &myData3);
	 printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->right == NULL, "_removeNode", "remove right of root 2st try");
	   
    _removeNode(tree->root, &myData2);
	printTestResult(compare(tree->root->val, &myData1) == 0 && tree->root->left == 0, "_removeNode", "remove right of root 3st try");
        
    cur = _removeNode(tree->root, &myData1);
    printTestResult(cur == NULL, "_removeNode", "remove right of root 4st try");       
}
示例#5
0
文件: main.c 项目: avisinha1/CS-261
void testRemoveNode() {
    struct BSTree *tree = buildBSTTree();
    struct data *myData;
    /*Grabs the expected value from the tree, then deletes a node and checks if the new value in that place matches the expected value.*/

    myData = tree->root->right->val;
    _removeNode(tree->root, tree->root->val);
    printTestResult( (compare(tree->root->val, myData) == 0), "_removeNode", "Testing remove Root\n");

    myData = tree->root->right->left->val;
    _removeNode(tree->root, tree->root->right->val);
    printTestResult( (compare(tree->root->right->val, myData) == 0), "_removeNode", "Testing remove Root->Right\n"); /*Keep in mind that the tree has changed.*/

    myData = tree->root->left->right->left->val;
    _removeNode(tree->root, tree->root->left->val);
    printTestResult( (compare(tree->root->left->val, myData) == 0), "_removeNode", "Testing remove Root->Left\n");
        
    myData = tree->root->right->val;
    _removeNode(tree->root, tree->root->val);
    printTestResult( (compare(tree->root->val, myData) == 0), "_removeNode", "Testing remove Root again\n");
    
    struct data not_in_tree;
    not_in_tree.number = 9000;
    printf("Testing invalid remove. The two lines below should match exactly\n");
    printTree(tree);
    _removeNode(tree->root, &not_in_tree); /*Should print error message and leave tree unchanged.*/
    printTree(tree);

    printf("Deleting the BSTree...\n");
    deleteBSTree(tree);
    printf("Returning from testRemoveNode().\n");
}
示例#6
0
文件: main.c 项目: avisinha1/CS-261
void testRemoveLeftMost() {
    struct BSTree *tree = buildBSTTree();
    struct data *myData;
    struct data *delete_val; /*In this case we need another struct to delete value 105
    Since _removeLeftMost is not supposed to delete the value (it may be pointed to by another element in the tree)
    we will need to manually delete it ourselves once the node has been deleted.*/

    myData = tree->root->left->left->val;
    _removeLeftMost(tree->root);
    printTestResult( (tree->root->left->left == NULL), "_removeLeftMost", "Removing leftmost from Root");
    free(myData);

    delete_val = tree->root->left->val;
    myData = tree->root->left->right->val;
    _removeLeftMost(tree->root);
    printTestResult( (compare(tree->root->left->val, myData) == 0), "_removeLeftMost", "Removing leftmost from Root again");
    free(delete_val);

    delete_val = tree->root->right->right->left->val;
    myData = tree->root->right->right->left->right->val;
    _removeLeftMost(tree->root->right->right);
    free(delete_val);
    printTestResult( (compare(tree->root->right->right->left->val, myData) == 0), "_removeLeftMost", "removing leftmost from Root->Right->Right");

    printf("Deleting the BSTree...\n");
    deleteBSTree(tree);
    printf("Returning from testRemoveLeftMost().\n");
}
示例#7
0
int main() {
	struct gameState state,			// running instance of game
					 stateOriginal;	// backup copy of game to detect changes
	int i = 0,						// iteration variable for loop counting
		j = 0,						// iteration variable for loop counting
		numPlayers = 2,				// number of players in game
		randomSeed = 10000,			// seed for random generation
		validationCheck = 1;		// used to determine pass or fail
	// initial array of kingdom cards
	int kingdomCards[10] = {adventurer, gardens, village, minion, mine, cutpurse,
							sea_hag, remodel, smithy};
	
	// Initializing game and backup copy of game
	initializeGame(numPlayers, kingdomCards, randomSeed, &state);

	// PERFORMING OPERATIONS TO MEET TEST CONDITION
	memcpy(&stateOriginal, &state, sizeof(struct gameState));
	state.hand[state.whoseTurn][0] = silver;
	// DISPLAY
	printf("***************************************************************************\n");
	printf("* TESTING FUNCTION: remodelEffect\n");
	printf("***************************************************************************\n");
	printf("\n  EXECUTING: remodelEffect(state.whoseTurn, 1, 2, &state, 0)\n\n");
	remodelEffect(state.whoseTurn, 1, 2, &state, 0);

	printf("  TEST: Choice1 removed from player's hand with valid selection...\n\n");
	validationCheck = 0;
	for (i = 0; i < state.handCount[state.whoseTurn]; i++) {
		if (state.hand[state.whoseTurn][i] == 1) {
			validationCheck = 1;
			break;
		}
	}
	printTestResult(validationCheck, -999, -999);

	memcpy(&state, &stateOriginal, sizeof(struct gameState));
	remodelEffect(state.whoseTurn, province, copper, &state, 0);
	printf("  TEST: Choice1/discard card cost + 2 must not be greater than choice2/buyCard...\n\n");
	validationCheck = 1;
	if (memcmp(&state, &stateOriginal, sizeof(struct gameState)) != 0)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);


	memcpy(&state, &stateOriginal, sizeof(struct gameState));
	remodelEffect(state.whoseTurn, copper, province, &state, 0);
	printf("  TEST: The new card must be added to the player's hand...\n\n");
	validationCheck = 1;
	if (state.hand[state.whoseTurn][state.handCount[state.whoseTurn] - 1] != copper)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);

	printf("  TEST: The trashed card must be removed from the player's hand and placed in discard...\n\n");
	if (state.discard[state.whoseTurn][state.discardCount[state.whoseTurn] - 1] != province)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);
	
	return 0;
}
示例#8
0
/*
 * runAutoTest
 *
 * Test all the interface supported by the project automatically
 */
void runAutoTest(void) {
	XStatus status;
	status = ddr3IicTest('B');
	printTestResult("DDR3B_IIC", status);

	status = ddr3RwTest();
	printTestResult("DDR3B_RW", status);
}
示例#9
0
文件: main.c 项目: anonrose/CS260
/*
	testLeftMost: function to test the left most element
	param: tree - the tree we are testing
	pre: tree is not null
	post: none
*/
void testLeftMost(struct BSTree *tree) {
    assert(tree != NULL);
	printTestResult(compareValues(_leftMostValue(tree->root), 20) == 0, "_leftMostValue", "left most of root");

	printTestResult(compareValues(_leftMostValue(tree->root->left), 20) == 0, "_leftMostValue", "left most of left of root");

	printTestResult(compareValues(_leftMostValue(tree->root->left->left), 20) == 0, "_leftMostValue", "left most of left of left of root");

	printTestResult(compareValues(_leftMostValue(tree->root->right), 67) == 0, "_leftMostValue", "left most of right of root");
}
示例#10
0
文件: main.c 项目: avisinha1/CS-261
/*
  Function to test that the BST contains the elements that we added to it
*/
void testContainsBSTree() {
  /* printf("test the test \n");*/
    struct BSTree *tree = buildBSTTree();
    struct data myData;

    myData.number = 90;
    myData.name = "Root";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 90 as Root");

    myData.number = 10;
    myData.name = "Root->L";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 10 as Root->Left");
    
    myData.number = 5;
    myData.name = "Root->L->L";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 5 as Root->Left->Left");
        
    myData.number = 50;
    myData.name = "Root->L->R";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 50 as Root->Left->Right");

    myData.number = 40;
    myData.name = "Root->L->R->L";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 40 as Root->Left->Right->Left");

    myData.number = 55;
    myData.name = "Root->L->R->R";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 55 as Root->Left->Right->Right");

    myData.number = 100;
    myData.name = "Root->R";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 100 as Root->Right");

    myData.number = 110;
    myData.name = "Root->R->R";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 110 as Root->Right->Right");

    myData.number = 105;
    myData.name = "Root->R->R->L";
    printTestResult(containsBSTree(tree->root, &myData), "containsBSTree", "When test containing 105 as Root->Right->Right->Left");

    /*Check if containsBSTree will properly recognize if a number is not in the tree.   */
    myData.number = 1337;
    myData.name = "Root->N->A->N";
    printTestResult(!containsBSTree(tree->root, &myData), "containsBSTree", "When testing if 1337 is not in the tree.");

    printf("Deleting the BSTree...\n");
    deleteBSTree(tree);
    printf("Returning from testContainsBSTree().\n");

}
示例#11
0
文件: bst.c 项目: nguyminh/CS-261
void testRemoveLeftMost() {
    struct BSTree *tree = buildBSTTree();
    struct Node *cur;
    
    cur = _removeLeftMost(tree->root);

	printTestResult(cur == tree->root, "_removeLeftMost", "removing leftmost of root 1st try");
    
    cur = _removeLeftMost(tree->root->right);
    printTestResult(cur == NULL, "_removeLeftMost", "removing leftmost of right of root 1st try");
   
 	cur = _removeLeftMost(tree->root);
    printTestResult(cur == tree->root, "_removeLeftMost", "removing leftmost of root 2st try");
}
示例#12
0
文件: main.c 项目: anonrose/CS260
/*
	testRemoveNode: function to test the left most element
	param: tree - the tree we are testing
	pre: tree is not null
	post: 3 nodes have been removed from the tree
*/
void testRemoveNode(struct BSTree *tree) {

    removeNodeFromTree(tree, 13);
    /* Should output: node is not contained in the tree */

    removeNodeFromTree(tree, 20);
    printTestResult(tree->root->val == 55 && tree->root->left->left == NULL, "removeNodeFromTree", "remove left-left of root");

    removeNodeFromTree(tree, 36);
    printTestResult(compareValues(tree->root->val, 55) == 0 && tree->root->left == NULL, "removeNodeFromTree", "remove left of root");

    removeNodeFromTree(tree, 67);
    printTestResult(compareValues(tree->root->val, 55) == 0 && tree->root->right->left == NULL, "removeNodeFromTree", "remove right-left of root");

    /* Comment out these test cases and try some more interesting ones */


}
示例#13
0
/*
fucntion to test the left_Most_element

*/
void testLeftMost() {
    struct BSTree *tree = buildBSTTree();

    struct data myData3;
    struct data myData4;

    myData3.number = 110;
    myData3.name = "righty";
    myData4.number = 10;
    myData4.name = "lefty of lefty";

    printTestResult(compare(_leftMost(tree->root), &myData4) == 0, "_leftMost", "left most of root");

    printTestResult(compare(_leftMost(tree->root->left), &myData4) == 0, "_leftMost", "left most of left of root");

    printTestResult(compare(_leftMost(tree->root->left->left), &myData4) == 0, "_leftMost", "left most of left of left of root");

}
示例#14
0
文件: main.c 项目: avisinha1/CS-261
/*
  Function to test the left_Most_element 

*/
void testLeftMost() {
    struct BSTree *tree = buildBSTTree();
    struct data *myData;

    myData = (struct data*)tree->root->left->left->val;
    printTestResult( (compare(_leftMost(tree->root)->val, myData) == 0), "_leftMost", "Left most of Root"); 
    printTestResult( (compare(_leftMost(tree->root->left)->val, myData) == 0), "_leftMost", "Left most of Left of Root");
    
    myData = (struct data*)tree->root->left->right->left->val;
    printTestResult( (compare(_leftMost(tree->root->left->right)->val, myData) == 0), "_leftMost", "Left most of Left of Right of Root");

    myData = (struct data*)tree->root->right->right->left->val;
    printTestResult( (compare(_leftMost(tree->root->right->right)->val, myData) == 0), "_leftMost", "Left most of Right of Right of Root");

    printf("Deleting the BSTree...\n");
    deleteBSTree(tree);
    printf("Returning from testLeftMost().\n");

}
示例#15
0
int main ()
{
	testResult_t *result = initializeTestResult();

	getFS();	

	deleteFile("File to Delete");
	deleteDir("Dir to Delete");

	int newFd = openFile("NewFile");

	char *text = "Here is some text.";
	int writeLen = writeInFile(newFd, text, strlen(text));
	assert(writeLen == strlen(text), "File write return value test.", result);
	seekInFile(newFd, 0);
	char target[100];
	memset(target, 0, sizeof(target));
	int readLen = readInFile(newFd, target, strlen(text));
	assert(readLen == strlen(text), "File write return value test.", result);
	deny(strcmp(target, text), "Read + write test.", result);

	int fd = openFile("File to Delete");

	seekInFile(newFd, FILE_BLOCK_DATA_SIZE - 2);
	writeLen = writeInFile(newFd, text, strlen(text));
	seekInFile(newFd, FILE_BLOCK_DATA_SIZE - 2);
	readLen = readInFile(newFd, target, strlen(text));
	assert(readLen == strlen(text), "Non-contiguous allocation read+write test.", result);
	deny(strcmp(target, text), "Read + write test.", result);

	mkDir("Dir to Delete");

	giveDirListing();

	deleteFile("File to Delete");
	mkDir("NewDir");
	giveDirListing();

	deleteDir("Dir to Delete");

	giveDirListing();

	seekInFile(newFd, 0);

	int i;
	for (i = 0; i < 150; i++)
	{
		writeInFile(newFd, text, strlen(text));
		seekInFile(newFd, (i * FILE_BLOCK_DATA_SIZE) - 2);
	}

	printTestResult(result);
	freeTestResult(result);
	return 0;
}
示例#16
0
int main ()
{
	testResult_t *result = initializeTestResult();
	int i;
	for (i = 0; i < 10; i++) { }
	assert( i == 10, "For loop.", result);
	deny( i == 12, "For loop, should error.", result);
	
	printTestResult(result);

	freeTestResult(result);
	return 0;
}
示例#17
0
文件: main.c 项目: anonrose/CS260
/*
	testContainsBSTree: function to test that the BST contains the elements that we added to it
	pre: tree is not null
	param: tree - the tree we are testing
	post: none
*/
void testContainsBSTree(struct BSTree *tree) {
    assert(tree != NULL);

    printTestResult(containsBSTree(tree, 55), "containsBSTree", "when test containing 55 as root");
    printTestResult(containsBSTree(tree, 36), "containsBSTree", "when test containing 36 as left of root");
    printTestResult(containsBSTree(tree, 78), "containsBSTree", "when test containing 78 as right of root");
    printTestResult(containsBSTree(tree, 20), "containsBSTree", "when test containing 20 as left-left of root");
    printTestResult(containsBSTree(tree, 67), "containsBSTree", "when test containing 20 as right-left of root");
    printTestResult(containsBSTree(tree, 85), "containsBSTree", "when test containing 20 as right-right of root");

    printTestResult(!containsBSTree(tree, 88), "containsBSTree", "when test containing 88, which is not in the tree");
}
示例#18
0
int main ()
{
	testResult_t *result = initializeTestResult();
	fprintf(stdout, "Size of dirBlock_t: %d\n", sizeof(dirBlock_t));
	fprintf(stdout, "Size of superblock_t: %d\n", sizeof(superBlock_t));
	fprintf(stdout, "Size of fileBlock_t: %d\n", sizeof(fileBlock_t));
	assert(sizeof(dirBlock_t) == 1024, "dirBlock_t size test.", result);
	assert(sizeof(fileBlock_t) == 1024, "fileBlock_t size test.", result);
	assert(sizeof(superBlock_t) == 1024, "superBlock_t size test.", result);
	assert(createDisk(), "Creating vdisk file.", result);
	printTestResult(result);
	freeTestResult(result);
	return 0;
}
示例#19
0
/*
  fucntion to test the left_Most_element

*/
void testLeftMost() {
    struct BSTree *tree = buildBSTTree();

    struct data myData3, myData4;

    myData3.number = 110;
    myData3.name = "righty";
    myData4.number = 10;
    myData4.name = "lefty of lefty";

    printTestResult(compare(_leftMost(tree->root), &myData4) == 0, "_leftMost", "left most of root");

    printTestResult(compare(_leftMost(tree->root->left), &myData4) == 0, "_leftMost", "left most of left of root");

    printTestResult(compare(_leftMost(tree->root->left->left), &myData4) == 0, "_leftMost", "left most of left of left of root");

    printTestResult(compare(_leftMost(tree->root->right), &myData3) == 0, "_leftMost", "left most of right of root");

    printf("Deleting the BSTree...\n");
    deleteBSTree(tree);
    printf("Returning from testLeftMost().\n");

}
示例#20
0
int main ()
{
	testResult_t *result = initializeTestResult();

	fileSystem_t *FS = getFS();

	FS->superBlock->blockBitmap[0] = 0b11111111;
	FS->superBlock->blockBitmap[1] = 0b11111111;
	FS->superBlock->blockBitmap[2] = 0b00001101;
	
	assert(findEmptyBlock() == 17, "empty block find test.", result);

	assert(FS->activeDir->entryCount == 0, "add entry test begin", result);

	activeFile_t * aF = openFileInternal(FS->activeDir, "TestFile");

	assert(FS->activeDir->entryCount == 1, "add entry test begin", result);

	directoryEntry_t dE = FS->activeDir->entries[0];
	fprintf(stdout, "%s, %d, %d\n", dE.name, dE.blockType, dE.startingBlockNum);
	fprintf(stdout, "%s, %d\n", aF->name, aF->curContentsPtr);

	fileBlock_t *fB;
	fB = malloc(sizeof(fileBlock_t));
	readBlockFromDisk(17, fB);
	fprintf(stdout, "%d\n", fB->blockType);

	assert(fB->blockType == 3, "read blockType", result);

	fprintf(stdout, "%s\n", fB->name);

	assert(findEmptyBlock() == 20, "bitmap affect test.", result);

	markBlockFree(17);
	assert(findEmptyBlock() == 17, "bitmap affect test.", result);
	memset(fB, 0, sizeof(fileBlock_t));
	readBlockFromDisk(17, fB);
	fprintf(stdout, "%d\n", fB->blockType);

	assert(fB->blockType == 0, "free block zero set test.", result);

	printTestResult(result);
	freeTestResult(result);
	return 0;
}
示例#21
0
void afterTest(char* testName, Boolean result)
{
	printTestResult(testName, result);
	freeList(testlist);
	passCount += result;
}
void TestComponentMetadata::PrintTestResult()
{
    printTestResult("ComponentMetadata", testPassed);
}
示例#23
0
int main() {
	struct gameState state,			// running instance of game
					 stateOriginal;	// backup copy of game to detect changes
	int i = 0,						// iteration variable for loop counting
		j = 0,						// iteration variable for loop counting
		numPlayers = 2,				// number of players in game
		randomSeed = 10000,			// seed for random generation
		validationCheck = 1,		// used to determine pass or fail
		found = 0;					// detecs if card found in deck
	// initial array of kingdom cards
	int kingdomCards[10] = {adventurer, gardens, village, minion, mine, cutpurse,
							sea_hag, remodel, smithy};
	
	// Initializing game and backup copy of game
	initializeGame(numPlayers, kingdomCards, randomSeed, &state);

	// PERFORMING OPERATIONS TO MEET TEST CONDITION
	state.hand[state.whoseTurn][0] = smithy;
	memcpy(&stateOriginal, &state, sizeof(struct gameState));

	// DISPLAY
	printf("***************************************************************************\n");
	printf("* TESTING FUNCTION: smithyEffect\n");
	printf("***************************************************************************\n");
	printf("  NOTE: Smithy card placed in position 0 before each test...\n");
	printf("\n  EXECUTING: smithyEffect(state.whoseTurn, &state, 0)\n\n");

	printf("  TEST: 3 valid cards added to current player hand...\n");
	smithyEffect(state.whoseTurn, &state, 0);
	validationCheck = 1;
	for (i = 0; i < state.handCount[state.whoseTurn]; i++) {
		if (state.hand[state.whoseTurn][i] != stateOriginal.hand[state.whoseTurn][i]) {
			if (state.hand[state.whoseTurn][i] == -1) {
				validationCheck = 0;
			}
		}
	}
	// Ensure top card is valid selection
	if (state.hand[state.whoseTurn][stateOriginal.handCount[state.whoseTurn] + 1] == -1)
		validationCheck = 0;
	// Ensure card after top card is -1
	if (state.hand[state.whoseTurn][stateOriginal.handCount[state.whoseTurn] + 2] != -1)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);

	printf("  TEST: Current player hand count changed: 3 draws - 1 discard = +2...\n");
	validationCheck = 0;
	if (state.handCount[state.whoseTurn] != stateOriginal.handCount[state.whoseTurn] + 2)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);

	printf("  TEST: The smithy card is properly removed from the player hand...\n");
	validationCheck = 1;
	if (state.hand[state.whoseTurn][0] == smithy)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);
	
	printf("  TEST: 3 cards	came from player's deck...\n");
	validationCheck = 1;
	for (i = 0; i < state.handCount[state.whoseTurn]; i++) {
		if (state.hand[state.whoseTurn][i] != stateOriginal.hand[state.whoseTurn][i]) {
			found = 0;
			for (j = 0; j < stateOriginal.deckCount[state.whoseTurn]; j++) {
				if (state.hand[state.whoseTurn][i] == stateOriginal.deck[state.whoseTurn][j]) {
					found = 1;
				}
			}
			if (found == 0)
				validationCheck = 0;
		}
	}
	printTestResult(validationCheck, -999, -999);

	printf("  TEST: Player 2's decks were not modified...\n");
	validationCheck = 1;
	if (isHandSame(&state, &stateOriginal, state.whoseTurn + 1) != 1)
		validationCheck = 0;
	if (isDeckSame(&state, &stateOriginal, state.whoseTurn + 1) != 1)
		validationCheck = 0;
	if (isDiscardSame(&state, &stateOriginal, state.whoseTurn + 1) != 1)
		validationCheck = 0;
	printTestResult(validationCheck, -999, -999);

	printf("  TEST: Game kingdom decks were not modified...\n");
	validationCheck = 1;
	for (i = 0; i < 28; i++) {
		if (state.supplyCount[i] != stateOriginal.supplyCount[i])
			validationCheck = 0;
	}
	printTestResult(validationCheck, -999, -999);
	
	return 0;
}
void TestCreateComponent::PrintTestResult()
{
    printTestResult("CreateComponent", testPassed);
}
示例#25
0
文件: main.c 项目: avisinha1/CS-261
/*
  Function to test if nodes are added correctly.
*/
void testAddNode() {
   struct BSTree *tree	= newBSTree();
   struct data *test_data;
  
   test_data = malloc(sizeof(struct data));
   test_data->number = 90;
   test_data->name = "Root";
   addBSTree(tree, test_data);
   /*Check the Root node*/
   printTestResult( (compare(tree->root->val, test_data) == 0), "testAddNode", "Inserting 90 as Root");
   printTestResult( (tree->cnt == 1), "testAddNode", "Increase tree->cnt to 1 when inserting 90 as Root");

   test_data = malloc(sizeof(struct data));
   test_data->number = 10;
   test_data->name = "Root->L";
   addBSTree(tree, test_data);
   /*Check the position of the second element that is added to the BST tree*/
   printTestResult( (compare(tree->root->left->val, test_data) == 0), "testAddNode", "Inserting 10 as Root->L");
   printTestResult( (tree->cnt == 2), "testAddNode", "Increase tree->cnt to 2 when inserting 10 as Root->L");

   test_data = malloc(sizeof(struct data));
   test_data->number = 100;
   test_data->name = "Root->R";
   addBSTree(tree, test_data);
   /*Check the position of the third element that is added to the BST tree*/
   printTestResult( (compare(tree->root->right->val, test_data) == 0), "testAddNode", "Inserting 100 as Root->R");
   printTestResult( (tree->cnt == 3), "testAddNode", "Increase tree->cnt to 3 when inserting 100 as Root->R");

   test_data = malloc(sizeof(struct data));
   test_data->number = 5;
   test_data->name = "Root->L->L";
   addBSTree(tree, test_data);
   /*Check the position of the fourth element that is added to the BST tree*/
   printTestResult( (compare(tree->root->left->left->val, test_data) == 0), "testAddNode", "Inserting 5 as Root->L->L");
   printTestResult( (tree->cnt == 4), "testAddNode", "Increase tree->cnt to 4 when inserting 5 as Root->L->L");

   test_data = malloc(sizeof(struct data));
   test_data->number = 50;
   test_data->name = "Root->L->R";
   addBSTree(tree, test_data);
   /*Check the position of the fifth element that is added to the BST tree*/
   printTestResult( (compare(tree->root->left->right->val, test_data) == 0), "testAddNode", "Inserting 50 as Root->L->R");
   printTestResult( (tree->cnt == 5), "testAddNode", "Increase tree->cnt to 5 when inserting 50 as Root->L->R");

   test_data = malloc(sizeof(struct data));
   test_data->number = 40;
   test_data->name = "Root->L->R->L";
   addBSTree(tree, test_data);
   /*Check the position of the sixt element that is added to the BST tree*/
   printTestResult( (compare(tree->root->left->right->left->val, test_data) == 0), "testAddNode", "Inserting 40 as Root->L->R->L");
   printTestResult( (tree->cnt == 6), "testAddNode", "Increase tree->cnt to 6 when inserting 40 as Root->L->R->L");

   printf("Deleting the BSTree...\n");
   deleteBSTree(tree);
   printf("Returning from testAddNode().\n");
}
void TestComponentMTime::PrintTestResult()
{
    printTestResult("ComponentMTime", testPassed);
}
示例#27
0
void TestBigDB::PrintTestResult()
{
    printTestResult("BigDB", testPassed);
}
void TestMoveComponent::PrintTestResult()
{
    printTestResult("MoveComponent", testPassed);
}
void TestComponentVersion::PrintTestResult()
{
    printTestResult("ComponentVersion", testPassed);
}
示例#30
0
/*
 * runAutoTest
 *
 * Test all the interface supported by the project automatically
 */
void runAutoTest(void) {
	XStatus status;
	status = sataRwTest();
	printTestResult("SATA", status);
}