Refactor code, added new checkXu test cases(9 latterns)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package pattern
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFanEncoder(t *testing.T) {
|
||||
testFans := []Fan{
|
||||
{Id: 1, Name: "大四喜", Pattern: PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{12}, Value: 88},
|
||||
{Id: 2, Name: "七对", Pattern: PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{12}, Value: 24},
|
||||
}
|
||||
data, err := FansEncoder(testFans)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't encode fan xing: %v", err)
|
||||
return
|
||||
}
|
||||
fmt.Println(data)
|
||||
}
|
||||
|
||||
func TestFanDecoder(t *testing.T) {
|
||||
testFans := []Fan{
|
||||
{Id: 1, Name: "大四喜", Pattern: PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{12}, Value: 88},
|
||||
{Id: 2, Name: "七对", Pattern: PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{12}, Value: 24},
|
||||
}
|
||||
jsonBytes, err := FansEncoder(testFans)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't encode fan xing, cancel decoding test: %v", err)
|
||||
return
|
||||
}
|
||||
fans, err := FansDecoder(jsonBytes)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed decoding byte stream of fan xing: %v", err)
|
||||
return
|
||||
}
|
||||
fmt.Println(fans)
|
||||
}
|
||||
Reference in New Issue
Block a user