Ejemplo n.º 1
0
int main(int argc,char **argv)
{
  int e=0;

  //tilt left test for one row
  e|=test_tilt_left();

  //rotate tests for 2x2 board
  board_vector_test(1,2,4,8,"Rotate 2x2 board right (+90)",4,1,8,2,board_rotate_90);
  board_vector_test(0,1,2,4,"Rotate 2x2 board right (+90)",2,0,4,1,board_rotate_90);
  board_vector_test(0,0,0,1,"Rotate 2x2 board right (+90)",0,0,1,0,board_rotate_90);
  board_vector_test(1,0,0,1,"Rotate 2x2 board right (+90)",0,1,1,0,board_rotate_90);
 
  board_vector_test(1,2,4,8,"Rotate 2x2 board right (+180)",8,4,2,1,board_rotate_180);
  board_vector_test(0,1,2,4,"Rotate 2x2 board right (+180)",4,2,1,0,board_rotate_180);
  board_vector_test(0,0,0,1,"Rotate 2x2 board right (+180)",1,0,0,0,board_rotate_180);
  board_vector_test(1,0,0,1,"Rotate 2x2 board right (+180)",1,0,0,1,board_rotate_180);

  board_vector_test(1,2,4,8,"Rotate 2x2 board right (+270)",2,8,1,4,board_rotate_270);
  board_vector_test(0,1,2,4,"Rotate 2x2 board right (+270)",1,4,0,2,board_rotate_270);
  board_vector_test(0,0,0,1,"Rotate 2x2 board right (+270)",0,1,0,0,board_rotate_270);
  board_vector_test(1,0,0,1,"Rotate 2x2 board right (+270)",0,1,1,0,board_rotate_270);

  //rotate tests for 3x3 board
  board3_vector_test(1,2,3,4,5,6,7,8,9,"Rotate 3x3 board right (+90)",7,4,1,8,5,2,9,6,3,board_rotate_90);
  
  board3_vector_test(1,2,3,4,5,6,7,8,9,"Rotate 3x3 board right (+180)",9,8,7,6,5,4,3,2,1,board_rotate_180);

  board3_vector_test(1,2,3,4,5,6,7,8,9,"Rotate 3x3 board right (+270)",3,6,9,2,5,8,1,4,7,board_rotate_270);

  //rotate tests for 4x4 board
  board4_vector_test(1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8, "Rotate 4x4 board right (+90)"
  ,5,1,5,1,6,2,6,2,7,3,7,3,8,4,8,4, board_rotate_90);

  board4_vector_test(1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8, "Rotate 4x4 board right (+180)"
  ,8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1, board_rotate_180);

  board4_vector_test(1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8, "Rotate 4x4 board right (+270)"
  ,4,8,4,8,3,7,3,7,2,6,2,6,1,5,1,5, board_rotate_270);
  return e;
}
Ejemplo n.º 2
0
int test_board_rotations()
{
  int e=0;
  e|=board_vector_test(1,0,0,0,"(2*2)Rotate Single Value",0,1,0,0,board_rotate_right);
  e|=board_vector_test(1,2,3,4,"(2*2)Rotate 4 unique values",3,1,4,2,board_rotate_right);
  e|=board3_vector_test(1,0,0,
						0,0,0,
						0,0,0,"(3*3)Rotate Single Value",0,0,1,
														 0,0,0,
														 0,0,0,board_rotate_right);
  e|=board3_vector_test(1,2,3,
						4,5,6,
						7,8,9,"(3*3)Rotate 9 distinct values",7,4,1,
															  8,5,2,
															  9,6,3,board_rotate_right);
  e|=board4_vector_test(1,0,0,0,
						0,0,0,0,
						0,0,0,0,
						0,0,0,0,"(4*4)Rotate Single Value",0,0,0,1,
														   0,0,0,0,
														   0,0,0,0,
														   0,0,0,0,board_rotate_right);
  e|=board4_vector_test(1,2,3,4,
						5,6,7,8,
						9,10,11,12,
						13,14,15,16,"(4*4)Rotate 16 distinct values",13,9,5,1,
														   		 	 14,10,6,2,
														  			 15,11,7,3,
														   			 16,12,8,4,board_rotate_right);
  e|=board4_vector_test(13,9,5,1,
						14,10,6,2,
           			 	15,11,7,3,
						16,12,8,4,"(4*4)Rotate 16 distinct values left",1,2,3,4,
																  		5,6,7,8,
																  	    9,10,11,12,
																   		13,14,15,16,board_rotate_left);
  e|=board4_vector_test(0,0,0,0,
						0,0,0,0,
						0,0,0,0,
						1,1,1,1,"(4*4)Tilt up Single Value",1,1,1,1,
														   	0,0,0,0,
														   	0,0,0,0,
														   	0,0,0,0,tilt_board_up);
 e|=board4_vector_test(0,0,0,0,
						0,0,1,2,
						1,1,0,0,
						1,1,1,1,"(4*4)Tilt up Double Value",2,2,2,2,
														   	0,0,0,1,
														   	0,0,0,0,
														   	0,0,0,0,tilt_board_up);
  e|=board4_vector_test(1,1,1,1,
						0,0,0,0,
						0,0,0,0,
						0,0,0,0,"(4*4)Tilt down Single Value",0,0,0,0,
														   	0,0,0,0,
														   	0,0,0,0,
														   	1,1,1,1,tilt_board_down);
 e|=board4_vector_test( 1,1,1,1,
						0,0,1,2,
						1,1,0,0,
						1,1,1,1,"(4*4)Tilt down Double Value",0,0,0,0,
														   	0,0,0,1,
														   	1,1,1,2,
														   	2,2,2,1,tilt_board_down);
 e|=board4_vector_test( 1,0,0,0,
						1,0,0,0,
						1,0,0,0,
						1,0,0,0,"(4*4)Tilt right Single Value",0,0,0,1,
														 	   0,0,0,1,
														   	   0,0,0,1,
														   	   0,0,0,1,tilt_board_right);
 e|=board4_vector_test( 1,1,0,0,
						1,0,0,2,
						1,1,0,0,
						1,0,0,1,"(4*4)Tilt right Double Value",0,0,0,2,
														   	0,0,1,2,
														   	0,0,0,2,
														   	0,0,0,2,tilt_board_right);
 e|=board4_vector_test( 1,0,0,0,
						1,0,0,0,
						1,0,0,0,
						1,0,0,0,"(4*4)Tilt left Single Value",1,0,0,0,
														 	   1,0,0,0,
														   	   1,0,0,0,
														   	   1,0,0,0,tilt_board_left);
 e|=board4_vector_test( 1,0,0,1,
						0,1,1,0,
						0,1,0,1,
						0,0,1,2,"(4*4)Tilt left Double Value",2,0,0,0,
														   	2,0,0,0,
														   	2,0,0,0,
														   	1,2,0,0,tilt_board_left);

return e;
}