void test_card_to_string(void) { cut_set_message("カードを文字列にする"); { Card sa = card_new(SPADE,ACE); cut_assert(strcmp(card_to_string(sa), "SA")==0); } }
void test_card_new(void) { cut_set_message("スーツと番号からカードを作成"); { Card sa = card_new(SPADE,ACE); cut_assert(card_suit(sa)==SPADE); cut_assert(card_no(sa)==ACE); } }
Card card_new_with_values (uint value, char seed) { Card ret = card_new (); if (value < 1 || value > 13) value = 1; if (!__check_seed (seed)) seed = SPADES; ret->value = value; ret->seed = seed; return ret; }
Card card_new_random () { Card ret = card_new (); ret->value = (rand () % 13) + 1; switch (rand () % 4) { case 0: ret->seed = SPADES; break; case 1: ret->seed = DIAMONDS; break; case 2: ret->seed = CLUBS; break; case 3: ret->seed = HEARTS; break; } return ret; }