void test_Institution_reverse_should_reverse_the_institude_with_3_different_institution(){
	Institution institude,institude2,institude3;

	LinkedList listIn,listOut;
	int stackCount;
	
	List_removeHead_ExpectAndReturn(&listIn, &institude);
	Stack_push_Expect(&stack , &institude);
	List_removeHead_ExpectAndReturn(&listIn, &institude2);
	Stack_push_Expect(&stack , &institude2);
	List_removeHead_ExpectAndReturn(&listIn, &institude3);
	Stack_push_Expect(&stack , &institude3);
	
	List_removeHead_ExpectAndReturn(&listIn, NULL);
	
	Stack_pop_ExpectAndReturn(&stack, &institude3);
	List_addTail_Expect(&listOut, &institude3);
	Stack_pop_ExpectAndReturn(&stack, &institude2);
	List_addTail_Expect(&listOut, &institude2);
	Stack_pop_ExpectAndReturn(&stack, &institude);
	List_addTail_Expect(&listOut, &institude);	
	
	stackCount = Institution_reverse(&listIn,&listOut);
	
	TEST_ASSERT_EQUAL(3, stackCount);
	
}
void test_Institution_reverse_should_reverse_2_Institution_elements() {
	Institution institution1;
	Institution institution2;
	
	LinkedList list;
	LinkedList reversedList;

	int numberOfElement;
	
	// Mocking
	List_removeHead_ExpectAndReturn(&list, &institution1);
	Stack_push_Expect(&stack, &institution1);
	
	List_removeHead_ExpectAndReturn(&list, &institution2);
	Stack_push_Expect(&stack, &institution2);
	
	List_removeHead_ExpectAndReturn(&list, NULL);
	
	Stack_pop_ExpectAndReturn(&stack, &institution2);
	List_addTail_Expect(&reversedList, &institution2);
	
	Stack_pop_ExpectAndReturn(&stack, &institution1);
	List_addTail_Expect(&reversedList, &institution1);

	// Call function
	numberOfElement = Institution_reverse(&list, &reversedList);
	
	TEST_ASSERT_EQUAL(2, numberOfElement);
}
Beispiel #3
0
void test_reverse_add_institution_for_4_elements(){
	Institution institution[]={};
	LinkedList inputList = {};
	LinkedList outputList = {};
	
	List_removeHead_ExpectAndReturn(&inputList, &institution[0]);
	Stack_push_Expect(&stack, &institution[0]);
	List_removeHead_ExpectAndReturn(&inputList, &institution[1]);
	Stack_push_Expect(&stack, &institution[1]);
	List_removeHead_ExpectAndReturn(&inputList, &institution[2]);
	Stack_push_Expect(&stack, &institution[2]);
	List_removeHead_ExpectAndReturn(&inputList, &institution[3]);
	Stack_push_Expect(&stack, &institution[3]);
	List_removeHead_ExpectAndReturn(&inputList, NULL);
	
	Stack_pop_ExpectAndReturn(&stack, &institution[3]);
	List_addTail_Expect(&outputList, &institution[3]);
	Stack_pop_ExpectAndReturn(&stack, &institution[2]);
	List_addTail_Expect(&outputList, &institution[2]);
	Stack_pop_ExpectAndReturn(&stack, &institution[1]);
	List_addTail_Expect(&outputList, &institution[1]);
	Stack_pop_ExpectAndReturn(&stack, &institution[0]);
	List_addTail_Expect(&outputList, &institution[0]);
	
	TEST_ASSERT_EQUAL(4, Institution_reverse(&inputList, &outputList) );
}
void test_Institution_reverse_given_TARC_MMU_should_reverse_become_MMU_TARC(void){

				
  
	Stack_create_ExpectAndReturn(&stack);

	List_removeHead_ExpectAndReturn(&inputList,&TARC);
	Stack_push_Expect(&stack, &TARC);
	List_removeHead_ExpectAndReturn(&inputList,&UTAR);
	Stack_push_Expect(&stack, &UTAR);
	List_removeHead_ExpectAndReturn(&inputList, NULL);
	
	Stack_pop_ExpectAndReturn(&stack, &UTAR);
	List_addTail_Expect(&outputList, &UTAR);
	Stack_pop_ExpectAndReturn(&stack, &TARC);
	List_addTail_Expect(&outputList, &TARC);
	Stack_pop_ExpectAndReturn(&stack, NULL);
		
	Institution_reverse(&inputList, &outputList);

}