using Test function troca(v, i, j) aux = v[i] v[i] = v[j] v[j] = aux end function insercao(v) tam = length(v) for i in 2:tam j = i while j > 1 if compareByValueAndSuit(v[j], v[j - 1]) troca(v, j, j - 1) else break end j = j - 1 end end return v end function getCardValue(card, check_suit = false) value = card[1:end - 1] suit = card[end] total_value = 0 if value == "A" total_value += 14 elseif value == "K" total_value += 13 elseif value == "Q" total_value += 12 elseif value == "J" total_value += 11 else total_value += parse(Int64, value) end if check_suit if suit == '♢' total_value += 100 elseif suit == '♠' total_value += 200 elseif suit == '♡' total_value += 300 elseif suit == '♣' total_value += 400 end end return total_value end function compareByValue(x, y) return getCardValue(x) < getCardValue(y) end function compareByValueAndSuit(x, y) return getCardValue(x, true) < getCardValue(y, true) end # Seção de testes # ♢♦ ♠ ♡♥ ♣ function extra_test() @testset "Tests for MiniEP8" begin @testset "compareByValue" begin @test !compareByValue("A♠", "K♠") @test !compareByValue("2♡", "2♢") @test !compareByValue("10♣", "9♣") @test compareByValue("7♡", "8♢") @test compareByValue("5♣", "J♠") @test compareByValue("10♢", "Q♢") end @testset "compareByValueAndSuit" begin @test !compareByValueAndSuit("2♠", "2♢") @test !compareByValueAndSuit("A♡", "A♠") @test !compareByValueAndSuit("5♠", "K♢") @test compareByValueAndSuit("A♢", "2♡") @test compareByValueAndSuit("7♣", "8♣") @test compareByValueAndSuit("J♢", "3♠") end end end