2 ' Copyright 2011 Jacek Caban for CodeWeavers
4 ' This library is free software; you can redistribute it and/or
5 ' modify it under the terms of the GNU Lesser General Public
6 ' License as published by the Free Software Foundation; either
7 ' version 2.1 of the License, or (at your option) any later version.
9 ' This library is distributed in the hope that it will be useful,
10 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ' Lesser General Public License for more details.
14 ' You should have received a copy of the GNU Lesser General Public
15 ' License along with this library; if not, write to the Free Software
16 ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 Call ok(vbSunday = 1, "vbSunday = " & vbSunday)
27 Call ok(getVT(vbSunday) = "VT_I2", "getVT(vbSunday) = " & getVT(vbSunday))
28 Call ok(vbMonday = 2, "vbMonday = " & vbMonday)
29 Call ok(getVT(vbMonday) = "VT_I2", "getVT(vbMonday) = " & getVT(vbMonday))
30 Call ok(vbTuesday = 3, "vbTuesday = " & vbTuesday)
31 Call ok(getVT(vbTuesday) = "VT_I2", "getVT(vbTuesday) = " & getVT(vbTuesday))
32 Call ok(vbWednesday = 4, "vbWednesday = " & vbWednesday)
33 Call ok(getVT(vbWednesday) = "VT_I2", "getVT(vbWednesday) = " & getVT(vbWednesday))
34 Call ok(vbThursday = 5, "vbThursday = " & vbThursday)
35 Call ok(getVT(vbThursday) = "VT_I2", "getVT(vbThursday) = " & getVT(vbThursday))
36 Call ok(vbFriday = 6, "vbFriday = " & vbFriday)
37 Call ok(getVT(vbFriday) = "VT_I2", "getVT(vbFriday) = " & getVT(vbFriday))
38 Call ok(vbSaturday = 7, "vbSaturday = " & vbSaturday)
39 Call ok(getVT(vbSaturday) = "VT_I2", "getVT(vbSaturday) = " & getVT(vbSaturday))
41 Sub TestCStr(arg, exval)
44 Call ok(getVT(x) = "VT_BSTR*", "getVT(x) = " & getVT(x))
45 Call ok(x = exval, "CStr(" & arg & ") = " & x)
48 TestCStr "test", "test"
51 if isEnglishLang then TestCStr true, "True"
53 Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
54 Set x = new EmptyClass
55 Call ok(isObject(x), "isObject(x) is not true?")
56 Call ok(isObject(Nothing), "isObject(Nothing) is not true?")
57 Call ok(not isObject(true), "isObject(true) is true?")
58 Call ok(not isObject(4), "isObject(4) is true?")
59 Call ok(not isObject("x"), "isObject(""x"") is true?")
60 Call ok(not isObject(Null), "isObject(Null) is true?")
62 Call ok(not isEmpty(new EmptyClass), "isEmpty(new EmptyClass) is true?")
63 Set x = new EmptyClass
64 Call ok(not isEmpty(x), "isEmpty(x) is true?")
66 Call ok(isEmpty(x), "isEmpty(x) is not true?")
67 Call ok(isEmpty(empty), "isEmpty(empty) is not true?")
68 Call ok(not isEmpty(Nothing), "isEmpty(Nothing) is not true?")
69 Call ok(not isEmpty(true), "isEmpty(true) is true?")
70 Call ok(not isEmpty(4), "isEmpty(4) is true?")
71 Call ok(not isEmpty("x"), "isEmpty(""x"") is true?")
72 Call ok(not isEmpty(Null), "isEmpty(Null) is true?")
74 Call ok(not isNull(new EmptyClass), "isNull(new EmptyClass) is true?")
75 Set x = new EmptyClass
76 Call ok(not isNull(x), "isNull(x) is true?")
78 Call ok(isNull(x), "isNull(x) is not true?")
79 Call ok(not isNull(empty), "isNull(empty) is true?")
80 Call ok(not isNull(Nothing), "isNull(Nothing) is true?")
81 Call ok(not isNull(true), "isNull(true) is true?")
82 Call ok(not isNull(4), "isNull(4) is true?")
83 Call ok(not isNull("x"), "isNull(""x"") is true?")
84 Call ok(isNull(Null), "isNull(Null) is not true?")
86 Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
89 Call ok(hex(x) = ex, "hex(" & x & ") = " & hex(x) & " expected " & ex)
95 TestHex &hdeadbeef&, "DEADBEEF"
98 TestHex -934859845, "C8472BBB"
101 Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
102 Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
104 x = InStr(1, "abcd", "bc")
105 Call ok(x = 2, "InStr returned " & x)
107 x = InStr("abcd", "bc")
108 Call ok(x = 2, "InStr returned " & x)
110 x = InStr("abc", "bc")
111 Call ok(x = 2, "InStr returned " & x)
113 x = InStr("abcbc", "bc")
114 Call ok(x = 2, "InStr returned " & x)
116 x = InStr("bcabc", "bc")
117 Call ok(x = 1, "InStr returned " & x)
119 x = InStr(3, "abcd", "bc")
120 Call ok(x = 0, "InStr returned " & x)
122 x = InStr("abcd", "bcx")
123 Call ok(x = 0, "InStr returned " & x)
125 x = InStr(5, "abcd", "bc")
126 Call ok(x = 0, "InStr returned " & x)
130 Call ok(x = 2, "InStr returned " & x)
132 x = InStr("abcd", null)
133 Call ok(isNull(x), "InStr returned " & x)
134 x = InStr(null, "abcd")
135 Call ok(isNull(x), "InStr returned " & x)
136 x = InStr(2, null, "abcd")
137 Call ok(isNull(x), "InStr returned " & x)
139 x = InStr(1.3, "abcd", "bc")
140 Call ok(x = 2, "InStr returned " & x)
142 x = InStr(2.3, "abcd", "bc")
143 Call ok(x = 2, "InStr returned " & x)
145 x = InStr(2.6, "abcd", "bc")
146 Call ok(x = 0, "InStr returned " & x)
148 Sub TestMid(str, start, len, ex)
149 x = Mid(str, start, len)
150 Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
153 Sub TestMid2(str, start, ex)
155 Call ok(x = ex, "Mid(" & str & ", " & start & ") = " & x & " expected " & ex)
158 TestMid "test", 2, 2, "es"
159 TestMid "test", 2, 4, "est"
160 TestMid "test", 1, 2, "te"
161 TestMid "test", 1, 0, ""
162 TestMid "test", 1, 0, ""
163 TestMid "test", 5, 2, ""
164 TestMid2 "test", 1, "test"
165 TestMid2 "test", 2, "est"
166 TestMid2 "test", 4, "t"
167 TestMid2 "test", 5, ""
169 Sub TestUCase(str, ex)
171 Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
174 TestUCase "test", "TEST"
175 TestUCase "123aBC?", "123ABC?"
178 if isEnglishLang then TestUCase true, "TRUE"
179 TestUCase 0.123, doubleAsString(0.123)
181 Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
183 Sub TestLCase(str, ex)
185 Call ok(x = ex, "LCase(" & str & ") = " & x & " expected " & ex)
188 TestLCase "test", "test"
189 TestLCase "123aBC?", "123abc?"
192 if isEnglishLang then TestLCase true, "true"
193 TestLCase 0.123, doubleAsString(0.123)
195 Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
197 Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
198 Call ok(Len("") = 0, "Len() = " & Len(""))
199 Call ok(Len(1) = 1, "Len(1) = " & Len(1))
200 Call ok(isNull(Len(null)), "Len(null) = " & Len(null))
201 Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
203 Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
204 Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
205 Call ok(Space(false) = "", "Space(false) = " & Space(false) & """")
206 Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
207 Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """")
208 Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """")
209 Call ok(Space(5.5) = " ", "Space(5.5) = " & Space(5.5) & """")
211 Sub TestStrReverse(str, ex)
212 Call ok(StrReverse(str) = ex, "StrReverse(" & str & ") = " & StrReverse(str))
215 TestStrReverse "test", "tset"
216 TestStrReverse "", ""
217 TestStrReverse 123, "321"
218 if isEnglishLang then TestStrReverse true, "eurT"
220 Sub TestLeft(str, len, ex)
221 Call ok(Left(str, len) = ex, "Left(" & str & ", " & len & ") = " & Left(str, len))
224 TestLeft "test", 2, "te"
225 TestLeft "test", 5, "test"
226 TestLeft "test", 0, ""
227 TestLeft 123, 2, "12"
228 if isEnglishLang then TestLeft true, 2, "Tr"
230 Sub TestRight(str, len, ex)
231 Call ok(Right(str, len) = ex, "Right(" & str & ", " & len & ") = " & Right(str, len))
234 TestRight "test", 2, "st"
235 TestRight "test", 5, "test"
236 TestRight "test", 0, ""
237 TestRight 123, 2, "23"
238 if isEnglishLang then TestRight true, 2, "ue"
240 Sub TestTrim(str, exstr)
241 Call ok(Trim(str) = exstr, "Trim(" & str & ") = " & Trim(str))
244 TestTrim " test ", "test"
245 TestTrim "test ", "test"
246 TestTrim " test", "test"
247 TestTrim "test", "test"
250 if isEnglishLang then TestTrim true, "True"
252 Sub TestLTrim(str, exstr)
253 Call ok(LTrim(str) = exstr, "LTrim(" & str & ") = " & LTrim(str))
256 TestLTrim " test ", "test "
257 TestLTrim "test ", "test "
258 TestLTrim " test", "test"
259 TestLTrim "test", "test"
262 if isEnglishLang then TestLTrim true, "True"
264 Sub TestRound(val, exval, vt)
265 Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
266 Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
269 Sub TestRTrim(str, exstr)
270 Call ok(RTrim(str) = exstr, "RTrim(" & str & ") = " & RTrim(str))
273 TestRTrim " test ", " test"
274 TestRTrim "test ", "test"
275 TestRTrim " test", " test"
276 TestRTrim "test", "test"
279 if isEnglishLang then TestRTrim true, "True"
281 TestRound 3, 3, "VT_I2"
282 TestRound 3.3, 3, "VT_R8"
283 TestRound 3.8, 4, "VT_R8"
284 TestRound 3.5, 4, "VT_R8"
285 TestRound -3.3, -3, "VT_R8"
286 TestRound -3.5, -4, "VT_R8"
287 TestRound "2", 2, "VT_R8"
288 TestRound true, true, "VT_BOOL"
289 TestRound false, false, "VT_BOOL"
291 if isEnglishLang then
292 Call ok(WeekDayName(1) = "Sunday", "WeekDayName(1) = " & WeekDayName(1))
293 Call ok(WeekDayName(3) = "Tuesday", "WeekDayName(3) = " & WeekDayName(3))
294 Call ok(WeekDayName(7) = "Saturday", "WeekDayName(7) = " & WeekDayName(7))
295 Call ok(WeekDayName(1.1) = "Sunday", "WeekDayName(1.1) = " & WeekDayName(1.1))
296 Call ok(WeekDayName(1, false) = "Sunday", "WeekDayName(1, false) = " & WeekDayName(1, false))
297 Call ok(WeekDayName(1, true) = "Sun", "WeekDayName(1, true) = " & WeekDayName(1, true))
298 Call ok(WeekDayName(1, 10) = "Sun", "WeekDayName(1, 10) = " & WeekDayName(1, 10))
299 Call ok(WeekDayName(1, true, 0) = "Sun", "WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
300 Call ok(WeekDayName(1, true, 2) = "Mon", "WeekDayName(1, true, 2) = " & WeekDayName(1, true, 2))
301 Call ok(WeekDayName(1, true, 7) = "Sat", "WeekDayName(1, true, 7) = " & WeekDayName(1, true, 7))
302 Call ok(WeekDayName(1, true, 7.1) = "Sat", "WeekDayName(1, true, 7.1) = " & WeekDayName(1, true, 7.1))
304 Call ok(MonthName(1) = "January", "MonthName(1) = " & MonthName(1))
305 Call ok(MonthName(12) = "December", "MonthName(12) = " & MonthName(12))
306 Call ok(MonthName(1, 0) = "January", "MonthName(1, 0) = " & MonthName(1, 0))
307 Call ok(MonthName(12, false) = "December", "MonthName(12, false) = " & MonthName(12, false))
308 Call ok(MonthName(1, 10) = "Jan", "MonthName(1, 10) = " & MonthName(1, 10))
309 Call ok(MonthName(12, true) = "Dec", "MonthName(12, true) = " & MonthName(12, true))
312 Call ok(getVT(Now()) = "VT_DATE", "getVT(Now()) = " & getVT(Now()))
314 Call ok(vbOKOnly = 0, "vbOKOnly = " & vbOKOnly)
315 Call ok(getVT(vbOKOnly) = "VT_I2", "getVT(vbOKOnly) = " & getVT(vbOKOnly))
316 Call ok(vbOKCancel = 1, "vbOKCancel = " & vbOKCancel)
317 Call ok(getVT(vbOKCancel) = "VT_I2", "getVT(vbOKCancel) = " & getVT(vbOKCancel))
318 Call ok(vbAbortRetryIgnore = 2, "vbAbortRetryIgnore = " & vbAbortRetryIgnore)
319 Call ok(getVT(vbAbortRetryIgnore) = "VT_I2", "getVT(vbAbortRetryIgnore) = " & getVT(vbAbortRetryIgnore))
320 Call ok(vbYesNoCancel = 3, "vbYesNoCancel = " & vbYesNoCancel)
321 Call ok(getVT(vbYesNoCancel) = "VT_I2", "getVT(vbYesNoCancel) = " & getVT(vbYesNoCancel))
322 Call ok(vbYesNo = 4, "vbYesNo = " & vbYesNo)
323 Call ok(getVT(vbYesNo) = "VT_I2", "getVT(vbYesNo) = " & getVT(vbYesNo))
324 Call ok(vbRetryCancel = 5, "vbRetryCancel = " & vbRetryCancel)
325 Call ok(getVT(vbRetryCancel) = "VT_I2", "getVT(vbRetryCancel) = " & getVT(vbRetryCancel))
327 Call ok(vbOK = 1, "vbOK = " & vbOK)
328 Call ok(getVT(vbOK) = "VT_I2", "getVT(vbOK) = " & getVT(vbOK))
329 Call ok(vbCancel = 2, "vbCancel = " & vbCancel)
330 Call ok(getVT(vbCancel) = "VT_I2", "getVT(vbCancel) = " & getVT(vbCancel))
331 Call ok(vbAbort = 3, "vbAbort = " & vbAbort)
332 Call ok(getVT(vbAbort) = "VT_I2", "getVT(vbAbort) = " & getVT(vbAbort))
333 Call ok(vbRetry = 4, "vbRetry = " & vbRetry)
334 Call ok(getVT(vbRetry) = "VT_I2", "getVT(vbRetry) = " & getVT(vbRetry))
335 Call ok(vbIgnore = 5, "vbIgnore = " & vbIgnore)
336 Call ok(getVT(vbIgnore) = "VT_I2", "getVT(vbIgnore) = " & getVT(vbIgnore))
337 Call ok(vbYes = 6, "vbYes = " & vbYes)
338 Call ok(getVT(vbYes) = "VT_I2", "getVT(vbYes) = " & getVT(vbYes))
339 Call ok(vbNo = 7, "vbNo = " & vbNo)
340 Call ok(getVT(vbNo) = "VT_I2", "getVT(vbNo) = " & getVT(vbNo))