feat(cafegame): 自 go-hua 迁入网咖游戏识别与运行记录框架
- 游戏来源常量/按目录特征识别(云更新/网维大师/易乐游)/RunAppRecord 上报框架 - 网吧业务专用包, 附测试、examples/cafegame 例程与包 README
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package cafegame
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSourceToName(t *testing.T) {
|
||||
cases := map[int]string{
|
||||
SourceYGX: "云更新",
|
||||
SourceWWDS: "网维大师",
|
||||
SourceYLY: "易乐游",
|
||||
SourceMTGX: "马蹄更新",
|
||||
SourceStory: "蘑菇",
|
||||
SourceGoodGame: "盖伦",
|
||||
SourceHaoSiJi: "好司机",
|
||||
SourceFast: "火箭",
|
||||
SourceWfGame: "WF游戏",
|
||||
999: "", // 未知来源
|
||||
}
|
||||
for id, want := range cases {
|
||||
if got := SourceToName(id); got != want {
|
||||
t.Errorf("SourceToName(%d) = %q, want %q", id, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSourceAll(t *testing.T) {
|
||||
all := GetSourceAll()
|
||||
if len(all) == 0 {
|
||||
t.Fatal("GetSourceAll 不应为空")
|
||||
}
|
||||
for _, id := range all {
|
||||
if SourceToName(id) == "" {
|
||||
t.Errorf("来源 %d 无对应名称", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGameStatusConstants(t *testing.T) {
|
||||
if GameStatusStart != 1 || GameStatusStop != 0 {
|
||||
t.Errorf("游戏状态常量错误: start=%d stop=%d", GameStatusStart, GameStatusStop)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsAllNumberHandle(t *testing.T) {
|
||||
if !IsAllNumberHandle("12345") {
|
||||
t.Error("纯数字应通过")
|
||||
}
|
||||
if IsAllNumberHandle("12a45") {
|
||||
t.Error("含字母应不通过")
|
||||
}
|
||||
if IsAllNumberHandle("") {
|
||||
t.Error("空串应不通过")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user