-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstruct2lua_test.go
80 lines (67 loc) · 1.03 KB
/
struct2lua_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package struct2lua
import "testing"
type T struct {
A string
B int
C []int
//D []string
E bool
}
type R struct {
F string
}
type LUA struct {
CW map[string]interface{}
ID int
IP string
t T
}
type Ld struct {
NET_TIMEOUT_MSEC int
NET_MAX_CONNETION int
StartService []int
}
func TestToLuaConfig(t *testing.T) {
g := LUA{
t: T{
A: "aaaaa",
B: 123,
C: []int{1, 2, 3},
//D: []string{"dfdfdfddf", "5", "6"},
E: true,
},
CW: make(map[string]interface{}),
}
g.CW["aaa"] = R{
F: "a is a",
}
g.CW["bbb"] = T{
A: "is a",
B: 2222,
E: true,
}
g.CW["ccc"] = "realccc"
submap := []int{1, 2}
submap[0] = 1
g.CW["sub"] = submap
//array := []R{
// {
// F: "aaaaa",
// },
// {
// F: "ccccc",
// },
//}
array := make([]R, 1)
array[0] = R{F: "ccwwr"}
g.CW["wwww"] = array
lst := Ld{
StartService: []int{0, 1, 3},
NET_TIMEOUT_MSEC: 100,
NET_MAX_CONNETION: 300,
}
sucess := ToLuaConfig("", "testlua", g, lst, 1)
if sucess == false {
t.Error("test TestToLuaConfig fail~")
}
}