-
Notifications
You must be signed in to change notification settings - Fork 1
/
testutil.src
executable file
·199 lines (167 loc) · 6.45 KB
/
testutil.src
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
'##########################################################################
'
' test util.src
'
'##########################################################################
'$include:'util.inc'
'$include:'input.inc'
'$include:'test.inc'
'$include:'itemcach.inc'
'$include:'util.def'
'--------------------------------------------------------------------------
sub testMax
private ret
ret = Util.Max(2,3)
ok(ret=3,"util.max")
end sub
'--------------------------------------------------------------------------
sub testMin
private ret
ret = Util.Min(8,-5)
ok(ret=-5,"util.min")
end sub
'--------------------------------------------------------------------------
sub testTrim
private ret$[20]
ret$ = Util.Trim$(" TESTSTR ")
ok(ret$="TESTSTR","util.trim$")
end sub
'--------------------------------------------------------------------------
sub testErrlog
Util.errlog("COM",305,2)
ok(1,"util.errlog")
end sub
'--------------------------------------------------------------------------
sub testTruncateStr
private ret$[20]
private src$[30]
src$="漢字とaLphabet"
ret$=Util.TruncateStr$(src$,1,6)
ok(ret$="漢字と","util.truncatestr1")
ret$=Util.TruncateStr$(src$,1,5)
ok(ret$="漢字","util.truncatestr2")
ret$=Util.TruncateStr$(src$,1,8)
ok(ret$="漢字とa","util.truncatestr3")
ret$=Util.TruncateStr$(src$,1,16)
ok(ret$="漢字とaLphabet","util.truncatestr4")
ret$=Util.TruncateStr$(src$,3,6)
ok(ret$="字とa","util.truncatestr5")
end sub
'--------------------------------------------------------------------------
sub testStrCharIndex
private idx%(100)
private src$[20]
private ret%
src$="漢字とaLphabet"
ret%=Util.StrCharIndex%(src$,idx%)
ok(ret%=11, "util.strcharindex0")
ok(idx%(0)=1, "util.strcharindex1")
ok(idx%(2)=5, "util.strcharindex2")
ok(idx%(3)=7, "util.strcharindex3")
ok(idx%(4)=8, "util.strcharindex4")
end sub
'--------------------------------------------------------------------------
sub testIs1stShiftJis
private ret%
private src$[5]
src$="漢a字"
ret%=Util.Is1stShiftJis%(mid$(src$,1,1))
ok(ret%=1, "util.is1stshiftjis1")
ret%=Util.Is1stShiftJis%(mid$(src$,2,1))
ok(ret%=0, "util.is1stshiftjis2")
ret%=Util.Is1stShiftJis%(mid$(src$,3,1))
ok(ret%=0, "util.is1stshiftjis3")
end sub
'--------------------------------------------------------------------------
sub testGetPageInfo
private total%
private src$[100]
private offset%
private size%
src$="31765"+TAB$+"123"+TAB$+"10"
total%=Util.GetPageInfo%(src$, offset%, size%)
ok(total%=31765,"util.getpageinfo:total")
ok(offset%=123,"util.getpageinfo:offset")
ok(size%=10,"util.getpageinfo:size")
end sub
'--------------------------------------------------------------------------
sub testParseLineData
private STREOL$[1]: STREOL$=chr$(10)
private ret%
private src$[100]
private lines$(20)[20]
src$="10867"+STREOL$+"(2009)イルミ500球_クリア"
ret%=Util.ParseListData%(src$, lines$)
ok(lines$(0)="10867", "util.parselinedata1")
ok(lines$(1)="(2009)イルミ500球_クリア", "util.parselinedata2")
end sub
'--------------------------------------------------------------------------
sub testParseListTabData
private STREOL$[1]: STREOL$=chr$(10)
private ret%
private src$[500]
private meta$[100]
private ids$(10)[100]
private names$(10)[100]
private codes$(10)[100]
private quantities%(10)
private hasEnough%(10)
private productIds&(10)
private productCodes$(10)[50]
private barCodes$(10)[50]
private stockTotals%(10)
private stockUnlimiteds%(10)
'-- test parse list tab data
src$="7827"+TAB$+"0"+TAB$+"10"
src$=src$+STREOL$+"10867"+TAB$+"(2009)イルミ500球_クリア"+TAB$+"123456789012"
src$=src$+STREOL$+"10847"+TAB$+"(2009)イルミ500球_青"+TAB$+"123456789013"
src$=src$+STREOL$+"11747"+TAB$+"(V)マイクロファイバーアソート"+TAB$+"123456789014"
src$=src$+STREOL$+"10954"+TAB$+"(V)マイクロファイバー毛布ネイビー"+TAB$+"123456789015"
src$=src$+STREOL$+"10871"+TAB$+"(V)マイクロファイバー毛布ピンク"+TAB$+"123456789016"
ret%=Util.ParseListTabData%(src$, meta$, ids$, 0, names$, codes$)
ok(ids$(0)="10867","util.parselisttabdata1")
ok(ids$(3)="10954","util.parselisttabdata2")
print ids$(3)
Input.InputAnyKey
ok(names$(2)="(V)マイクロファイバーアソート","util.parselisttabdata3")
ok(ret%=5,"util.parselisttabdata4")
'-- test parse list data 2
src$="2"+TAB$+"0"+TAB$+"0"
src$=src$+STREOL$+"4902778731635"+TAB$+"商品 1"+TAB$+"7"+TAB$+"0"
src$=src$+STREOL$+"4912345678904"+TAB$+"商品 2"+TAB$+"3"+TAB$+"3"
ret%=Util.ParseListTabData2%(src$, meta$, ids$, names$, quantities%, hasEnough%)
ok(ids$(1)="4912345678904","utilparselisttabdata5")
ok(hasEnough%(1)=3,"utilparselisttabdata6")
ok(ret%=2,"utilparselisttabdata7")
'-- test parse item cache
src$="10"+TAB$+"20"+TAB$+"20"
src$=src$+STREOL$+"1777"+TAB$+"電池式シューズドライヤー"+TAB$+"0017874142804"+TAB$+"000000028740"+TAB$+"26"+TAB$+"0"
src$=src$+STREOL$+"1618"+TAB$+"新筒型車載ウーハー50W"+TAB$+"0022684520636"+TAB$+"000000007934"+TAB$+"9"+TAB$+"0"
src$=src$+STREOL$+"23"+TAB$+"タイドクリーンブリーズ1470ml"+TAB$+"0037000138082"+TAB$+"000000028236"+TAB$+"0"+TAB$+"1"
ret%=ItemCache.ParseItemCache%(src$, meta$, productIds&(), names$(), productCodes$(), barCodes$(), stockTotals%(), stockUnlimiteds%())
ok(productIds&(1)=1618,"ItemCache.parseitemcache1")
ok(productCodes$(1)="000000007934","ItemCache.parseitemcache2")
ok(stockUnlimiteds%(2)=1,"ItemCache.parseitemcache3")
ok(ret%=3,"ItemCache.parseitemcache4")
'--
src$="10"+TAB$+"20"+TAB$+"20"
src$=src$+STREOL$+"1499"+TAB$+"カー携帯充電器ドコモ"+TAB$+"4512019971227"+TAB$+"000000029243"+TAB$+"47"+TAB$+"0"
ret%=ItemCache.ParseItemCache%(src$, meta$, productIds&(), names$(), productCodes$(), barCodes$(), stockTotals%(), stockUnlimiteds%())
ok(ret%=1,"ItemCache.parseitemcache5")
ok(productIds&(0)=1499,"ItemCache.parseitemcache6")
' Input.InputAnyKey
end sub
'--------------------------------------------------------------------------
Main
Test.Start
testMax
testMin
testTrim
testErrlog
testTruncateStr
testStrCharIndex
testIs1stShiftJis
testGetPageInfo
testParseLineData
testParseListTabData
Test.Finish