in prog
This commit is contained in:
24
src/game/rule/operation/suit_test.go
Normal file
24
src/game/rule/operation/suit_test.go
Normal 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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user