-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_test.go
61 lines (54 loc) · 1.58 KB
/
gen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package excel2conf
import (
"encoding/json"
"github.com/nullzZ/excel2config/field"
"github.com/nullzZ/excel2config/gen/config"
"github.com/nullzZ/excel2config/loader"
"github.com/nullzZ/excel2config/pkg/zaplog"
"go.uber.org/zap"
"log"
"testing"
)
func TestGenGo(t *testing.T) {
sourcePath := "/Users/malei/works/excel2config/data"
toPath := "/Users/malei/works/excel2config/gen"
gen := NewGenerateExcel(sourcePath, toPath, WithSkipRow(5), WithSkipCol(1))
Gen(gen)
}
func TestIsRepeated(t *testing.T) {
ok := field.IsRepeated("<1,2,3>")
t.Logf("@@@%v", ok)
}
func TestRepeated2(t *testing.T) {
var a [][]int = make([][]int, 5)
for i := 0; i < 5; i++ {
var aa []int
aa = append(aa, 1)
aa = append(aa, 2)
a[i] = aa
}
bb, err := json.Marshal(a)
if err != nil {
log.Println(err)
return
}
log.Printf("@@@@@@@@%s", string(bb))
}
func TestParseRepeated2Json(t *testing.T) {
str := field.ParseRepeated2Json(field.RepeatedInt2Typ, "[1,2]")
t.Log(str)
str2 := field.ParseRepeated2Json(field.RepeatedInt2Typ, "[[1,2]]")
t.Log(str2)
str3 := field.ParseRepeated2Json(field.RepeatedInt2Typ, "[[1,2],[1]]")
t.Log(str3)
}
func TestLoader(t *testing.T) {
zaplog.Init(zap.DebugLevel)
config.InitWithLoader(loader.AddLoader)
m := make(map[string]func(i interface{}, param string) bool)
//m["ArrayExist"] = checker.ArrayExist
config.InitCheckerFunc(m) //注册自定义注解函数
loader.AddChecker(config.Checker) //加载检测方法
loader.SetLogger(zaplog.Logger) //设置log,可以不设置
loader.MustInitLocal("/Users/malei/works/excel2config/gen/rawdata", true)
}