#ifndef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <tarot.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
int
main ()
{
if (tarot_init (LOCALEDIR) != 0)
{
fprintf (stderr, "Error: could not load libtarot.\n");
return EXIT_FAILURE;
}
{
TarotGame *game = tarot_game_alloc ();
tarot_game_free (game);
}
tarot_quit ();
return EXIT_SUCCESS;
}
TarotGameEvent *event = NULL;
(void) event;
if (tarot_game_add_event (game, event) != TAROT_GAME_OK)
{
fprintf (stderr, "%s:%d: Error: could not add the event.", __FILE__, __LINE__);
return EXIT_FAILURE;
}
tarot_game_event_free (event);
event = tarot_game_event_alloc_setup (
,
1
0
);
{
const TarotPlayer player = tarot_string_to_player_c ("
");
TarotCard cards[
];
size_t i = 0;
assert (player != ((TarotPlayer) (-1)));
cards[i] = tarot_string_to_card_c ("
");
assert (cards[i] != ((TarotCard) (-1)));
i++;
event = tarot_game_event_alloc_deal (player, sizeof (cards) / sizeof (cards[0]), cards);
}
{
TarotPlayer owners[
];
size_t i = 0;
owners[i] = tarot_string_to_player_c ("
");
assert (owners[i] != ((TarotPlayer) (-1)));
i++;
event = tarot_game_event_alloc_deal_all (sizeof (owners) / sizeof (owners[0]), owners);
}
event = tarot_game_event_alloc_bid (TAROT_PASS);
event = tarot_game_event_alloc_bid (TAROT_TAKE);
event = tarot_game_event_alloc_bid (TAROT_PUSH);
event = tarot_game_event_alloc_bid (TAROT_STRAIGHT_KEEP);
event = tarot_game_event_alloc_bid (TAROT_DOUBLE_KEEP);
event = tarot_game_event_alloc_decl (1);
event = tarot_game_event_alloc_decl (0);
{
TarotCard call = tarot_string_to_card_c ("");
assert (call != ((TarotCard) (-1)));
event = tarot_game_event_alloc_call (call);
}
{
TarotCard cards[
];
size_t i = 0;
cards[i] = tarot_string_to_card_c ("
");
assert (cards[i] != ((TarotCard) (-1)));
i++;
event = tarot_game_event_alloc_dog (sizeof (cards) / sizeof (cards[0]), cards);
}
{
TarotCard cards[
];
size_t i = 0;
cards[i] = tarot_string_to_card_c ("
");
assert (cards[i] != ((TarotCard) (-1)));
i++;
event = tarot_game_event_alloc_discard (sizeof (cards) / sizeof (cards[0]), cards);
}
{
TarotCard cards[
];
size_t i = 0;
(void) i;
cards[i] = tarot_string_to_card_c ("
");
assert (cards[i] != ((TarotCard) (-1)));
i++;
event = tarot_game_event_alloc_handful (sizeof (cards) / sizeof (cards[0]), cards);
}
{
TarotCard card = tarot_string_to_card_c ("")
assert (card != ((TarotCard) (-1)));
event = tarot_game_event_alloc_card (card);
}
/* Now running the tests */
assert (tarot_game_step (game) == TAROT_SETUP);
assert (tarot_game_step (game) == TAROT_DEAL);
assert (tarot_game_step (game) == TAROT_BIDS);
assert (tarot_game_step (game) == TAROT_DECLS);
assert (tarot_game_step (game) == TAROT_CALL);
assert (tarot_game_step (game) == TAROT_DOG);
assert (tarot_game_step (game) == TAROT_DISCARD);
assert (tarot_game_step (game) == TAROT_TRICKS);
assert (tarot_game_step (game) == TAROT_END);
assert (tarot_game_n_players (game) ==
);
assert (!tarot_game_with_call (game));
assert (tarot_game_with_call (game));
assert (tarot_game_n_tricks (game) ==
);
{
TarotPlayer next;
assert (tarot_game_get_next (game, &next) == TAROT_GAME_NA);
}
{
TarotPlayer next;
assert (tarot_game_get_next (game, &next) == TAROT_GAME_OK);
assert (next != ((TarotPlayer) (-1)));
assert (next == tarot_string_to_player_c (""));
}
{
TarotPlayer p;
assert (tarot_game_get_main_player (game, &p) == TAROT_GAME_NA);
}
{
TarotPlayer p;
assert (tarot_game_get_main_player (game, &p) == TAROT_GAME_OK);
assert (p != ((TarotPlayer) (-1)));
assert (p == tarot_string_to_player_c (""));
}
{
size_t n;
assert (tarot_game_get_deal_all (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
}
{
size_t n;
size_t i = 0;
TarotPlayer owner;
assert (tarot_game_get_deal_all (game, &n, i++, 1, &owner) == TAROT_GAME_OK);
assert (n == );
assert (owner != ((TarotPlayer) (-1)));
assert (owner == tarot_string_to_player_c (""));
}
{
size_t n;
TarotPlayer who = tarot_string_to_player_c ("");
assert (who != ((TarotPlayer) (-1)));
assert (tarot_game_get_deal_of (game, who, &n, 0, 0, NULL) == TAROT_GAME_NA);
}
{
size_t n;
size_t i = 0;
TarotCard c;
TarotPlayer who = tarot_string_to_player_c ("");
assert (who != ((TarotPlayer) (-1)));
assert (tarot_game_get_deal_of (game, who, &n, i++, 1, &c) == TAROT_GAME_OK);
assert (n == );
assert (c != ((TarotCard) (-1)));
assert (c == tarot_string_to_card_c (""));
}
{
size_t n;
TarotPlayer who = tarot_string_to_player_c ("
");
assert (who != ((TarotPlayer) (-1)));
assert (tarot_game_get_cards (game, who, &n, 0, 0, NULL) == TAROT_GAME_NA);
}
{
size_t n;
size_t i = 0;
TarotCard c;
TarotPlayer who = tarot_string_to_player_c ("");
assert (who != ((TarotPlayer) (-1)));
assert (tarot_game_get_cards (game, who, &n, i++, 1, &c) == TAROT_GAME_OK);
assert (n == );
assert (c != ((TarotCard) (-1)));
assert (c == tarot_string_to_card_c (""));
}
{
size_t n;
assert (tarot_game_get_bids (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t n;
size_t i = 0;
TarotBid b;
assert (tarot_game_get_bids (game, &n, i++, 1, &b) == TAROT_GAME_OK);
assert (n == );
assert (b == TAROT_PASS);
assert (b == TAROT_TAKE);
assert (b == TAROT_PUSH);
assert (b == TAROT_STRAIGHT_KEEP);
assert (b == TAROT_DOUBLE_KEEP);
}
{
TarotPlayer taker;
assert (tarot_game_get_taker (game, &taker) == TAROT_GAME_NA);
assert (taker != ((TarotPlayer) (-1)));
assert (taker == tarot_string_to_player_c ("
"));
}
{
TarotPlayer taker;
assert (tarot_game_get_taker (game, &taker) == TAROT_GAME_OK);
assert (taker != ((TarotPlayer) (-1)));
assert (taker == tarot_string_to_player_c ("
"));
}
{
size_t n;
assert (tarot_game_get_declarations (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t n;
size_t i = 0;
int d;
assert (tarot_game_get_declarations (game, &n, i++, 1, &d) == TAROT_GAME_OK);
assert (n == );
assert (!d);
assert (d);
}
{
TarotPlayer declarant;
assert (tarot_game_get_declarant (game, &declarant) == TAROT_GAME_NA);
assert (declarant != ((TarotPlayer) (-1)));
assert (declarant == tarot_string_to_player_c ("
"));
}
{
TarotPlayer declarant;
assert (tarot_game_get_declarant (game, &declarant) == TAROT_GAME_OK);
assert (declarant != ((TarotPlayer) (-1)));
assert (declarant == tarot_string_to_player_c ("
"));
}
{
TarotCard call;
assert (tarot_game_get_call (game, &call) == TAROT_GAME_NA);
}
{
TarotCard call;
assert (tarot_game_get_call (game, &call) == TAROT_GAME_OK);
assert (call != (TarotCard) (-1));
assert (call == tarot_string_to_card_c (""));
}
{
TarotPlayer partner;
assert (tarot_game_get_partner (game, &partner) == TAROT_GAME_NA);
}
{
TarotPlayer partner;
assert (tarot_game_get_partner (game, &partner) == TAROT_GAME_OK);
assert (partner != (TarotPlayer) (-1));
assert (partner == tarot_string_to_player_c (""));
}
{
size_t n;
assert (tarot_game_get_dog (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t n;
size_t i = 0;
TarotCard c;
assert (tarot_game_get_dog (game, &n, i++, 1, &c) == TAROT_GAME_OK);
assert (n == );
assert (c != ((TarotCard) (-1)));
assert (c == tarot_string_to_card_c (""));
}
{
size_t n;
assert (tarot_game_get_full_discard (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t n;
assert (tarot_game_get_public_discard (game, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t n;
int size;
TarotPlayer who = tarot_string_to_player_c ("
");
assert (who != ((TarotPlayer) (-1)));
assert (tarot_game_get_handful (game, who, &size, &n, 0, 0, NULL) == TAROT_GAME_NA);
assert (n == 0);
}
{
size_t trick;
assert (tarot_game_get_current_trick (game, &trick) == TAROT_GAME_NA);
assert (trick ==
);
}
{
TarotSuit lead_suit;
assert (tarot_game_get_lead_suit (game,
, &lead_suit) == TAROT_GAME_NA);
}
{
TarotNumber max_trump;
assert (tarot_game_get_max_trump (game,
, &max_trump) == TAROT_GAME_NA);
}
{
TarotPlayer trick_leader;
assert (tarot_game_get_trick_leader (game,
, &trick_leader) == TAROT_GAME_NA);
}
{
TarotPlayer trick_taker;
assert (tarot_game_get_trick_taker (game,
, &trick_taker) == TAROT_GAME_NA);
assert (trick_taker != ((TarotPlayer) (-1)));
assert (trick_taker == tarot_string_to_player_c ("
"));
}
{
size_t n_cards;
assert (tarot_game_get_trick_cards (game,
, &n_cards, 0, 0, NULL) == TAROT_GAME_NA);
}
{
unsigned int hp;
unsigned int od;
assert (tarot_game_get_points_in_trick (game,
, &hp, &od) == TAROT_GAME_NA);
}
{
size_t n_players;
assert (tarot_game_get_scores (game, &n_players, 0, 0, NULL) == TAROT_GAME_NA);
}
{
TarotPlayer next;
TarotBid min;
assert (tarot_game_get_hint_bid (game, &next, &min) == TAROT_GAME_NA);
}
{
TarotPlayer next;
int allowed;
assert (tarot_game_get_hint_decl (game, &next, &allowed) == TAROT_GAME_NA);
}
{
TarotPlayer next;
TarotNumber min;
assert (tarot_game_get_hint_call (game, &next, &min) == TAROT_GAME_NA);
}
{
TarotPlayer next;
size_t n, n_prio, n_additional;
assert (tarot_game_get_hint_discard (game, &next, &n, &n_prio, 0, 0, NULL, &n_additional, 0, 0, NULL) == TAROT_GAME_NA);
}
{
size_t n, n_set, n_other_set;
size_t i = 0;
TarotCard c;
TarotPlayer next;
assert (tarot_game_get_hint_discard (game, &next, &n, &n_set, i++, 1, &c, &n_other_set, 0, 0, NULL) == TAROT_GAME_OK);
assert (next != (TarotPlayer) (-1));
assert (next == tarot_string_to_player_c (""));
assert (n == );
assert (n_set == );
assert (c != ((TarotCard) (-1)));
assert (c == tarot_string_to_card_c (""));
i = 0;
assert (tarot_game_get_hint_discard (game, &next, &n, &n_other_set, 0, 0, NULL, &n_set, i++, 1, &c) == TAROT_GAME_OK);
assert (next != (TarotPlayer) (-1));
assert (next == tarot_string_to_player_c (""));
assert (n == );
assert (n_set == );
assert (c != ((TarotCard) (-1)));
assert (c == tarot_string_to_card_c (""));
}
{
TarotPlayer next;
size_t n_simple, n_double, n_triple, n_prio, n_additional;
assert (tarot_game_get_hint_handful (game, &next, &n_simple, &n_double, &n_triple, &n_prio, 0, 0, NULL, &n_additional, 0, 0, NULL) == TAROT_GAME_NA);
}
{
TarotPlayer next;
size_t n_playable;
assert (tarot_game_get_hint_card (game, &next, &n_playable, 0, 0, NULL) == TAROT_GAME_NA);
}
{
size_t n_dog;
assert (!tarot_game_can_autoreveal (game, &n_dog, 0, 0, NULL));
}
{
TarotGameEvent *ev = tarot_game_event_alloc_card (played_card);
assert (tarot_game_check_event (game, ev) != TAROT_GAME_OK);
}