test: 完善测试用例

This commit is contained in:
kercylan98 2023-06-30 12:50:39 +08:00
parent d1b7699cb4
commit 741a25cf42
3 changed files with 194 additions and 1 deletions

View File

@ -12,3 +12,178 @@ func ExampleNewCard() {
// Output:
// (A Spade)
}
func ExampleCard_Equal() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card1.Equal(card2))
// Output:
// true
}
func ExampleCard_EqualColor() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.EqualColor(card2))
// Output:
// false
}
func ExampleCard_EqualPoint() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.EqualPoint(card2))
// Output:
// true
}
func ExampleCard_GetColor() {
card := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card.GetColor())
// Output:
// Spade
}
func ExampleCard_GetPoint() {
card := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card.GetPoint())
// Output:
// A
}
func ExampleCard_GetPointAndColor() {
card := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card.GetPointAndColor())
// Output:
// A Spade
}
func ExampleCard_MaxPoint() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
fmt.Println(card1.MaxPoint(card2))
// Output:
// (2 Spade)
}
func ExampleCard_MinPoint() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
fmt.Println(card1.MinPoint(card2))
// Output:
// (A Spade)
}
func ExampleCard_String() {
card := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card.String())
// Output:
// (A Spade)
}
func ExampleCard_MaxColor() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.MaxColor(card2))
// Output:
// (A Spade)
}
func ExampleCard_MinColor() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.MinColor(card2))
// Output:
// (A Heart)
}
func ExampleCard_Max() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.Max(card2))
// Output:
// (A Spade)
}
func ExampleCard_Min() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.Min(card2))
// Output:
// (A Heart)
}
func ExampleCard_IsJoker() {
card := poker.NewCard(poker.PointA, poker.ColorSpade)
fmt.Println(card.IsJoker())
// Output:
// false
}
func ExampleCard_CalcPointDifference() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
fmt.Println(card1.CalcPointDifference(card2))
// Output:
// -1
}
func ExampleCard_CalcColorDifference() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.CalcColorDifference(card2))
// Output:
// 1
}
func ExampleCard_CalcPointDifferenceAbs() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
fmt.Println(card1.CalcPointDifferenceAbs(card2))
// Output:
// 1
}
func ExampleCard_CalcColorDifferenceAbs() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.CalcColorDifferenceAbs(card2))
// Output:
// 1
}
func ExampleCard_IsNeighborPoint() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
fmt.Println(card1.IsNeighborPoint(card2))
// Output:
// true
}
func ExampleCard_IsNeighborColor() {
card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
fmt.Println(card1.IsNeighborColor(card2))
// Output:
// true
}

View File

@ -13,5 +13,5 @@ func ExampleNewCardPile() {
fmt.Println(pile.Cards())
// Output:
// [(R None) (K Spade) (K Heart) (K Club) (K Diamond) (Q Spade) (Q Heart) (Q Club) (Q Diamond) (J Spade) (J Heart) (J Club) (J Diamond) (10 Spade) (10 Heart) (10 Club) (10 Diamond) (9 Spade) (9 Heart) (9 Club) (9 Diamond) (8 Spade) (8 Heart) (8 Club) (8 Diamond) (7 Spade) (7 Heart) (7 Club) (7 Diamond) (6 Spade) (6 Heart) (6 Club) (6 Diamond) (5 Spade) (5 Heart) (5 Club) (5 Diamond) (4 Spade) (4 Heart) (4 Club) (4 Diamond) (3 Spade) (3 Heart) (3 Club) (3 Diamond) (2 Spade) (2 Heart) (2 Club) (2 Diamond) (A Spade) (A Heart) (A Club) (A Diamond)]
// [(R None) (K Diamond) (K Club) (K Heart) (K Spade) (Q Diamond) (Q Club) (Q Heart) (Q Spade) (J Diamond) (J Club) (J Heart) (J Spade) (10 Diamond) (10 Club) (10 Heart) (10 Spade) (9 Diamond) (9 Club) (9 Heart) (9 Spade) (8 Diamond) (8 Club) (8 Heart) (8 Spade) (7 Diamond) (7 Club) (7 Heart) (7 Spade) (6 Diamond) (6 Club) (6 Heart) (6 Spade) (5 Diamond) (5 Club) (5 Heart) (5 Spade) (4 Diamond) (4 Club) (4 Heart) (4 Spade) (3 Diamond) (3 Club) (3 Heart) (3 Spade) (2 Diamond) (2 Club) (2 Heart) (2 Spade) (A Diamond) (A Club) (A Heart) (A Spade)]
}

View File

@ -0,0 +1,18 @@
package maths_test
import (
"fmt"
"github.com/kercylan98/minotaur/utils/maths"
)
func ExampleToContinuous() {
var nums = []int{1, 2, 3, 5, 6, 7, 9, 10, 11}
var continuous = maths.ToContinuous(nums)
fmt.Println(nums)
fmt.Println(continuous)
// Output:
// [1 2 3 5 6 7 9 10 11]
// map[1:1 2:2 3:3 4:5 5:6 6:7 7:9 8:10 9:11]
}