This commit is contained in:
Bel LaPointe
2021-03-28 13:13:17 -05:00
parent 117250f5c1
commit 9efb30ae3e
9 changed files with 269 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
package operation
import (
"encoding/json"
"local/sandbox/cards/src/entity"
"testing"
)
func TestSuit(t *testing.T) {
var s Suit
if err := json.Unmarshal([]byte(`"heart"`), &s); err != nil {
t.Fatal(err)
} else if s != Heart {
t.Fatal(Heart, s)
} else if b, err := json.Marshal(s); err != nil {
t.Fatal(err)
} else if string(b) != `"heart"` {
t.Fatal(`"heart"`, string(b))
} else if card := (entity.Card{Suit: int(Heart)}); !s.Is(card) {
t.Fatal(true, s.Is(card))
} else if card := (entity.Card{Suit: int(Diamond)}); s.Is(card) {
t.Fatal(false, s.Is(card))
}
}