-
Notifications
You must be signed in to change notification settings - Fork 10
/
runTest.js
157 lines (149 loc) · 4.99 KB
/
runTest.js
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
require('ts-node/register');
const main = require('./src/');
let test = main.parseToPinusProtobuf('./testInterface');
console.log('server result', JSON.stringify(test, null, 4));
main.parseAndWrite('./testInterface', './tmp.json');
let compare = JSON.stringify({
"client": {
"rank.playerHandler.beginGame": {
"required uInt32 token": 1,
"optional string msg": 2,
"message IGG_1": {
"repeated string ggenv": 1,
"optional uInt32 zz": 2
},
"optional IGG_1 duplicateIgg": 3,
"message GGG": {
"required uInt32 ccgg": 1
},
"optional GGG sharewithServerused": 4
},
"rank.playerHandler.onlyNotify": {
"required uInt32 token": 1,
"optional string msg": 2
}
},
"server": {
"rank.playerHandler.beginGame": {
"optional uInt32 code": 1,
"optional string msg": 2,
"required uInt32 currank": 3
},
"enumTest": {
"optional string aa": 1,
"required uInt32 bb": 2,
"required uInt32 cc": 3,
"optional string enumstr": 4
},
"onAdd": {
"required string nickname": 1,
"required uInt32 nickname11": 2,
"required uInt32 nowplayers": 3,
"required float nowplayers2": 4,
"required double nowplayers3": 5
},
"onRank": {
"repeated uInt32 normalArr": 1,
"required uInt32 enum": 2,
"repeated string normalStrArr": 3,
"message GGG": {
"required uInt32 ccgg": 1
},
"optional GGG innerGGG": 4,
"message MyRank": {
"required uInt32 nickname": 1,
"message GGG": {
"required uInt32 ccgg": 1
},
"required GGG ggg": 2,
"required GGG xxx": 3
},
"repeated MyRank ranks": 5,
"optional MyRank rk": 6,
"optional uInt32 val": 7,
"required string ffname": 8,
"message IGG": {
"repeated string ggenv": 1
},
"repeated IGG aa": 9,
"repeated string ggenv": 10
}
}
})
if (process.env['NODE_ENV'] === 'ci' && JSON.stringify(test) !== compare) {
console.error(JSON.stringify(test), "compare:", compare)
throw new Error("error")
}
test = main.parseToPinusProtobuf('./testInterface', '_Req', '_Res', true);
console.log('@@@server result', JSON.stringify(test, null, 4));
if (process.env['NODE_ENV'] === 'ci') {
let val = JSON.stringify({
"client": {
"rank.playerHandler.beginGame": {
"required uInt32 token": 1,
"optional string msg": 2,
"optional IGG_1 duplicateIgg": 3,
"optional GGG sharewithServerused": 4
},
"rank.playerHandler.onlyNotify": {
"required uInt32 token": 1,
"optional string msg": 2
},
"message GGG": {
"required uInt32 ccgg": 1
},
"message IGG_1": {
"repeated string ggenv": 1,
"optional uInt32 zz": 2
}
},
"server": {
"rank.playerHandler.beginGame": {
"optional uInt32 code": 1,
"optional string msg": 2,
"required uInt32 currank": 3
},
"enumTest": {
"optional string aa": 1,
"required uInt32 bb": 2,
"required uInt32 cc": 3,
"optional string enumstr": 4
},
"onAdd": {
"required string nickname": 1,
"required uInt32 nickname11": 2,
"required uInt32 nowplayers": 3,
"required float nowplayers2": 4,
"required double nowplayers3": 5
},
"onRank": {
"repeated uInt32 normalArr": 1,
"required uInt32 enum": 2,
"repeated string normalStrArr": 3,
"optional GGG innerGGG": 4,
"repeated MyRank ranks": 5,
"optional MyRank rk": 6,
"optional uInt32 val": 7,
"required string ffname": 8,
"repeated IGG aa": 9,
"repeated string ggenv": 10
},
"message GGG": {
"required uInt32 ccgg": 1
},
"message IGG": {
"repeated string ggenv": 1
},
"message MyRank": {
"required uInt32 nickname": 1,
"required GGG ggg": 2,
"required GGG xxx": 3
}
}
})
if (JSON.stringify(test) !== val) {
console.error(JSON.stringify(test), "compare:", compare)
throw new Error("error")
}
console.log("test passed")
}