33 lines
619 B
Go
33 lines
619 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewDeck(t *testing.T) {
|
|
d := newDeck()
|
|
if len(d) != 16 {
|
|
t.Errorf("Expected 16 but got %d", len(d))
|
|
}
|
|
|
|
if d[0] != "Ace of Spades" {
|
|
t.Errorf("Expected Ace of spades but got %s", d[0])
|
|
}
|
|
|
|
if d[len(d)-1] != "Four of Clubs" {
|
|
t.Errorf("Expected Four of Clubs but got %s", d[len(d)-1])
|
|
}
|
|
}
|
|
|
|
func TestSaveAndLoad(t *testing.T) {
|
|
os.Remove("_decktesting")
|
|
d := newDeck()
|
|
d.save("_decktesting")
|
|
loadDeck := load("_decktesting")
|
|
if len(loadDeck) != len(d) {
|
|
t.Errorf("Expected loaded and saved deck to be the same length")
|
|
}
|
|
os.Remove("_decktesting")
|
|
}
|