Added the a debug function to print the values of the structures.
This commit is contained in:
		
							parent
							
								
									7558551ac1
								
							
						
					
					
						commit
						b754c0a71e
					
				
							
								
								
									
										42
									
								
								debug/card_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								debug/card_test.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| #include <stdio.h> | ||||
| #include "card_test.h" | ||||
| 
 | ||||
| void print_card(struct card *card) { | ||||
|   switch (card->face) { | ||||
|     case NO_FACE: printf("No face "); break; | ||||
|     case COVERED: printf("Covered "); break; | ||||
|     case EXPOSED: printf("Exposed "); break; | ||||
|     default     : printf("?"); | ||||
|   } | ||||
| 
 | ||||
|   switch (card->value) { | ||||
|     case NO_VALUE: printf(", no value "); break; | ||||
|     case TWO     : printf("two"); break; | ||||
|     case THREE   : printf("three "); break; | ||||
|     case FOUR    : printf("four "); break; | ||||
|     case FIVE    : printf("five"); break; | ||||
|     case SIX     : printf("six"); break; | ||||
|     case SEVEN   : printf("seven"); break; | ||||
|     case EIGHT   : printf("eight"); break; | ||||
|     case NINE    : printf("nine"); break; | ||||
|     case TEN     : printf("ten"); break; | ||||
|     case JACK    : printf("jack"); break; | ||||
|     case QUEEN   : printf("queen "); break; | ||||
|     case KING    : printf("king "); break; | ||||
|     case ACE     : printf("ace "); break; | ||||
|     default      : printf("?"); | ||||
|   } | ||||
| 
 | ||||
|   switch (card->suit) { | ||||
|     case NO_SUIT : printf(", no suit "); break; | ||||
|     case DIAMONDS: printf("of diamonds "); break; | ||||
|     case SPADES  : printf("of spades "); break; | ||||
|     case HEARTS  : printf("of hearts "); break; | ||||
|     case CLUBS   : printf("of clubs "); break; | ||||
|   } | ||||
| 
 | ||||
|   printf("at y:%d x:%d, ", card->frame->start_y, card->frame->start_x); | ||||
|   printf("with width:%d height:%d\n", card->frame->width, card->frame->height); | ||||
| 
 | ||||
|   return; | ||||
| } | ||||
							
								
								
									
										8
									
								
								debug/card_test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								debug/card_test.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #ifndef CARD_TEST_H | ||||
| #define CARD_TEST_H | ||||
| 
 | ||||
| #include "../lib/card.h" | ||||
| 
 | ||||
| void print_card(struct card *); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										22
									
								
								debug/deck_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								debug/deck_test.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| #include <stdio.h> | ||||
| #include "deck_test.h" | ||||
| 
 | ||||
| void print_deck(struct deck *deck) { | ||||
|   print_stack(deck->stock); | ||||
|   print_stack(deck->waste_pile); | ||||
| 
 | ||||
|   print_stack(deck->foundation_0); | ||||
|   print_stack(deck->foundation_1); | ||||
|   print_stack(deck->foundation_2); | ||||
|   print_stack(deck->foundation_3); | ||||
| 
 | ||||
|   print_stack(deck->maneuvre_0); | ||||
|   print_stack(deck->maneuvre_1); | ||||
|   print_stack(deck->maneuvre_2); | ||||
|   print_stack(deck->maneuvre_3); | ||||
|   print_stack(deck->maneuvre_4); | ||||
|   print_stack(deck->maneuvre_5); | ||||
|   print_stack(deck->maneuvre_6); | ||||
| 
 | ||||
|   return; | ||||
| } | ||||
							
								
								
									
										8
									
								
								debug/deck_test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								debug/deck_test.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #ifndef DECK_TEST_H | ||||
| #define DECK_TEST_H | ||||
| 
 | ||||
| #include "../lib/deck.h" | ||||
| 
 | ||||
| void print_deck(struct deck *); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										16
									
								
								debug/stack_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								debug/stack_test.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| #include <stdio.h> | ||||
| #include "stack_test.h" | ||||
| 
 | ||||
| void print_stack(struct stack *stack) { | ||||
|   if (empty(stack)) { | ||||
|     printf("Empty stack\n"); | ||||
|   } else { | ||||
|     struct stack *iterator = stack; | ||||
|     while (iterator != NULL) { | ||||
|       print_card(iterator->card); | ||||
|       iterator = iterator->next; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return; | ||||
| } | ||||
							
								
								
									
										8
									
								
								debug/stack_test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								debug/stack_test.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #ifndef STACK_TEST_H | ||||
| #define STACK_TEST_H | ||||
| 
 | ||||
| #include "../lib/stack.h" | ||||
| 
 | ||||
| void print_stack(struct stack *); | ||||
| 
 | ||||
| #endif | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user