From b754c0a71ede55cb56e7fb89c8ea39dc53639851 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sat, 10 Apr 2010 13:39:22 -0300 Subject: [PATCH] Added the a debug function to print the values of the structures. --- debug/card_test.c | 42 ++++++++++++++++++++++++++++++++++ debug/card_test.h | 8 +++++++ debug/deck_test.c | 22 ++++++++++++++++++ debug/deck_test.h | 8 +++++++ {test => debug}/display_test.c | 0 {test => debug}/frame_test.c | 0 debug/stack_test.c | 16 +++++++++++++ debug/stack_test.h | 8 +++++++ test/card_test.c | 0 test/deck_test.c | 0 test/stack_test.c | 0 11 files changed, 104 insertions(+) create mode 100644 debug/card_test.c create mode 100644 debug/card_test.h create mode 100644 debug/deck_test.c create mode 100644 debug/deck_test.h rename {test => debug}/display_test.c (100%) rename {test => debug}/frame_test.c (100%) create mode 100644 debug/stack_test.c create mode 100644 debug/stack_test.h delete mode 100644 test/card_test.c delete mode 100644 test/deck_test.c delete mode 100644 test/stack_test.c diff --git a/debug/card_test.c b/debug/card_test.c new file mode 100644 index 0000000..e1f56a8 --- /dev/null +++ b/debug/card_test.c @@ -0,0 +1,42 @@ +#include +#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; +} diff --git a/debug/card_test.h b/debug/card_test.h new file mode 100644 index 0000000..38a800b --- /dev/null +++ b/debug/card_test.h @@ -0,0 +1,8 @@ +#ifndef CARD_TEST_H +#define CARD_TEST_H + +#include "../lib/card.h" + +void print_card(struct card *); + +#endif diff --git a/debug/deck_test.c b/debug/deck_test.c new file mode 100644 index 0000000..c144735 --- /dev/null +++ b/debug/deck_test.c @@ -0,0 +1,22 @@ +#include +#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; +} diff --git a/debug/deck_test.h b/debug/deck_test.h new file mode 100644 index 0000000..ab33c4c --- /dev/null +++ b/debug/deck_test.h @@ -0,0 +1,8 @@ +#ifndef DECK_TEST_H +#define DECK_TEST_H + +#include "../lib/deck.h" + +void print_deck(struct deck *); + +#endif diff --git a/test/display_test.c b/debug/display_test.c similarity index 100% rename from test/display_test.c rename to debug/display_test.c diff --git a/test/frame_test.c b/debug/frame_test.c similarity index 100% rename from test/frame_test.c rename to debug/frame_test.c diff --git a/debug/stack_test.c b/debug/stack_test.c new file mode 100644 index 0000000..593bc42 --- /dev/null +++ b/debug/stack_test.c @@ -0,0 +1,16 @@ +#include +#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; +} diff --git a/debug/stack_test.h b/debug/stack_test.h new file mode 100644 index 0000000..e1902da --- /dev/null +++ b/debug/stack_test.h @@ -0,0 +1,8 @@ +#ifndef STACK_TEST_H +#define STACK_TEST_H + +#include "../lib/stack.h" + +void print_stack(struct stack *); + +#endif diff --git a/test/card_test.c b/test/card_test.c deleted file mode 100644 index e69de29..0000000 diff --git a/test/deck_test.c b/test/deck_test.c deleted file mode 100644 index e69de29..0000000 diff --git a/test/stack_test.c b/test/stack_test.c deleted file mode 100644 index e69de29..0000000