extends GutTest

func test_card_create():
    var card = Card.create(0, 3, 14)
    assert_eq(card.card_id, 0)
    assert_eq(card.original_id, 0)
    assert_eq(card.suit(), 3)
    assert_eq(card.rank(), 14)

func test_card_equality():
    var a := Card.create(0, 2, 10)
    var b := Card.create(1, 2, 10)
    assert_true(a.matches(b))
    assert_false(a.equals(b))

func test_card_id_range():
    assert_eq(Card.MIN_ID, 0)
    assert_eq(Card.MAX_ID, 107)

func test_is_joker():
    var small := Card.create(52, 4, 15)
    var big := Card.create(53, 5, 16)
    assert_true(small.is_joker())
    assert_true(big.is_joker())

func test_compare_to():
    var low := Card.create(0, 0, 5)
    var high := Card.create(1, 1, 14)
    assert_lt(low.compare_to(high), 0)

func test_card_id_from_deck():
    assert_eq(Card.card_id_from_deck(0, 0), 0)
    assert_eq(Card.card_id_from_deck(0, 1), 54)
    assert_eq(Card.card_id_from_deck(53, 0), 53)
    assert_eq(Card.card_id_from_deck(53, 1), 107)

func test_packed():
    var c := Card.create(10, 1, 13)
    var packed := c.to_packed()
    var unpacked := Card.from_packed(packed)
    assert_eq(unpacked.suit(), 1)
    assert_eq(unpacked.rank(), 13)
