39 lines
851 B
Go
39 lines
851 B
Go
![]() |
package poker
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestPoker_String(t *testing.T) {
|
||
|
p := &Poker{
|
||
|
Color: 1,
|
||
|
Point: 2,
|
||
|
}
|
||
|
t.Log(p.ToInt())
|
||
|
t.Log(NewPoker(113).ToInt())
|
||
|
t.Log(NewPoker(208).ToInt())
|
||
|
t.Log(NewPoker(310).ToInt())
|
||
|
}
|
||
|
|
||
|
func cmpPoker(t *testing.T, a, b *Poker, maxPoint Point) {
|
||
|
pokers := NewPaulistaCleanPokers()
|
||
|
pokers.Shuffle()
|
||
|
pokers.maxPoint = maxPoint
|
||
|
t.Log(fmt.Sprintf("牌规则:%v", pokers.DebugSortPoker()))
|
||
|
ret := pokers.Cmp(a, b)
|
||
|
if ret == CppSmall {
|
||
|
t.Log(fmt.Sprintf("%v<%v", a.ToString(), b.ToString()))
|
||
|
} else if ret == CppEqual {
|
||
|
t.Log(fmt.Sprintf("%v=%v", a.ToString(), b.ToString()))
|
||
|
} else {
|
||
|
t.Log(fmt.Sprintf("%v>%v", a.ToString(), b.ToString()))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestPoker_Sort(t *testing.T) {
|
||
|
p1 := NewPoker(int(Heart), int(Point2))
|
||
|
p2 := NewPoker(int(Club), int(PointJ))
|
||
|
cmpPoker(t, p1, p2, PointQ)
|
||
|
}
|