Exemplo n.º 1
0
void genericBubbleSort(void *array, int length, 
					   int (*compare)(void *v1, void *v2),
					   void (*swap)(void *array, int index1,int index2))
{
	int i ;
	int size =length;
	
	for (i =0 ; i < length - 1 ; i ++ )
	{
		genericSingleBubbleSort(array,size,length,compare,swap);
		size -- ;
	}
	
}
void test_genericSingleBubbleSort_given_array_4_2_should_swap_to_2_4(void){
     int array[]={4,2,5,7};
	 
	 int v1 =array[0];
	 int v2 =array[1];
	  
	 genericSingleBubbleSort (  &array, 
								4, 
								4, 
								(&compare), // point the compare function
								(&swap)    //point the swap function
							 );
							 
	TEST_ASSERT_EQUAL(2, array[0]);
	TEST_ASSERT_EQUAL(4, array[1]);	
    TEST_ASSERT_EQUAL(5, array[2]);
	TEST_ASSERT_EQUAL(7, array[3]);						 
								 
}