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"
50 if isEnglishLang then TestCStr 3.5, "3.5"
51 if isEnglishLang then TestCStr true, "True"
53 Call ok(getVT(Chr(120)) = "VT_BSTR", "getVT(Chr(120)) = " & getVT(Chr(120)))
54 Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255)))
55 Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))
57 Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
58 Set x = new EmptyClass
59 Call ok(isObject(x), "isObject(x) is not true?")
60 Call ok(isObject(Nothing), "isObject(Nothing) is not true?")
61 Call ok(not isObject(true), "isObject(true) is true?")
62 Call ok(not isObject(4), "isObject(4) is true?")
63 Call ok(not isObject("x"), "isObject(""x"") is true?")
64 Call ok(not isObject(Null), "isObject(Null) is true?")
66 Call ok(not isEmpty(new EmptyClass), "isEmpty(new EmptyClass) is true?")
67 Set x = new EmptyClass
68 Call ok(not isEmpty(x), "isEmpty(x) is true?")
70 Call ok(isEmpty(x), "isEmpty(x) is not true?")
71 Call ok(isEmpty(empty), "isEmpty(empty) is not true?")
72 Call ok(not isEmpty(Nothing), "isEmpty(Nothing) is not true?")
73 Call ok(not isEmpty(true), "isEmpty(true) is true?")
74 Call ok(not isEmpty(4), "isEmpty(4) is true?")
75 Call ok(not isEmpty("x"), "isEmpty(""x"") is true?")
76 Call ok(not isEmpty(Null), "isEmpty(Null) is true?")
78 Call ok(not isNull(new EmptyClass), "isNull(new EmptyClass) is true?")
79 Set x = new EmptyClass
80 Call ok(not isNull(x), "isNull(x) is true?")
82 Call ok(isNull(x), "isNull(x) is not true?")
83 Call ok(not isNull(empty), "isNull(empty) is true?")
84 Call ok(not isNull(Nothing), "isNull(Nothing) is true?")
85 Call ok(not isNull(true), "isNull(true) is true?")
86 Call ok(not isNull(4), "isNull(4) is true?")
87 Call ok(not isNull("x"), "isNull(""x"") is true?")
88 Call ok(isNull(Null), "isNull(Null) is not true?")
90 Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
93 Call ok(hex(x) = ex, "hex(" & x & ") = " & hex(x) & " expected " & ex)
99 TestHex &hdeadbeef&, "DEADBEEF"
102 TestHex -934859845, "C8472BBB"
105 Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
106 Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
108 x = InStr(1, "abcd", "bc")
109 Call ok(x = 2, "InStr returned " & x)
111 x = InStr("abcd", "bc")
112 Call ok(x = 2, "InStr returned " & x)
114 x = InStr("abc", "bc")
115 Call ok(x = 2, "InStr returned " & x)
117 x = InStr("abcbc", "bc")
118 Call ok(x = 2, "InStr returned " & x)
120 x = InStr("bcabc", "bc")
121 Call ok(x = 1, "InStr returned " & x)
123 x = InStr(3, "abcd", "bc")
124 Call ok(x = 0, "InStr returned " & x)
126 x = InStr("abcd", "bcx")
127 Call ok(x = 0, "InStr returned " & x)
129 x = InStr(5, "abcd", "bc")
130 Call ok(x = 0, "InStr returned " & x)
134 Call ok(x = 2, "InStr returned " & x)
136 x = InStr("abcd", null)
137 Call ok(isNull(x), "InStr returned " & x)
138 x = InStr(null, "abcd")
139 Call ok(isNull(x), "InStr returned " & x)
140 x = InStr(2, null, "abcd")
141 Call ok(isNull(x), "InStr returned " & x)
143 x = InStr(1.3, "abcd", "bc")
144 Call ok(x = 2, "InStr returned " & x)
146 x = InStr(2.3, "abcd", "bc")
147 Call ok(x = 2, "InStr returned " & x)
149 x = InStr(2.6, "abcd", "bc")
150 Call ok(x = 0, "InStr returned " & x)
152 Sub TestMid(str, start, len, ex)
153 x = Mid(str, start, len)
154 Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
157 Sub TestMid2(str, start, ex)
159 Call ok(x = ex, "Mid(" & str & ", " & start & ") = " & x & " expected " & ex)
162 TestMid "test", 2, 2, "es"
163 TestMid "test", 2, 4, "est"
164 TestMid "test", 1, 2, "te"
165 TestMid "test", 1, 0, ""
166 TestMid "test", 1, 0, ""
167 TestMid "test", 5, 2, ""
168 TestMid2 "test", 1, "test"
169 TestMid2 "test", 2, "est"
170 TestMid2 "test", 4, "t"
171 TestMid2 "test", 5, ""
173 Sub TestUCase(str, ex)
175 Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
178 TestUCase "test", "TEST"
179 TestUCase "123aBC?", "123ABC?"
182 if isEnglishLang then TestUCase true, "TRUE"
183 TestUCase 0.123, doubleAsString(0.123)
185 Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
187 Sub TestLCase(str, ex)
189 Call ok(x = ex, "LCase(" & str & ") = " & x & " expected " & ex)
192 TestLCase "test", "test"
193 TestLCase "123aBC?", "123abc?"
196 if isEnglishLang then TestLCase true, "true"
197 TestLCase 0.123, doubleAsString(0.123)
199 Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
201 Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
202 Call ok(Len("") = 0, "Len() = " & Len(""))
203 Call ok(Len(1) = 1, "Len(1) = " & Len(1))
204 Call ok(isNull(Len(null)), "Len(null) = " & Len(null))
205 Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
207 Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
208 Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
209 Call ok(Space(false) = "", "Space(false) = " & Space(false) & """")
210 Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
211 Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """")
212 Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """")
213 Call ok(Space(5.5) = " ", "Space(5.5) = " & Space(5.5) & """")
215 Sub TestStrReverse(str, ex)
216 Call ok(StrReverse(str) = ex, "StrReverse(" & str & ") = " & StrReverse(str))
219 TestStrReverse "test", "tset"
220 TestStrReverse "", ""
221 TestStrReverse 123, "321"
222 if isEnglishLang then TestStrReverse true, "eurT"
224 Sub TestLeft(str, len, ex)
225 Call ok(Left(str, len) = ex, "Left(" & str & ", " & len & ") = " & Left(str, len))
228 TestLeft "test", 2, "te"
229 TestLeft "test", 5, "test"
230 TestLeft "test", 0, ""
231 TestLeft 123, 2, "12"
232 if isEnglishLang then TestLeft true, 2, "Tr"
234 Sub TestRight(str, len, ex)
235 Call ok(Right(str, len) = ex, "Right(" & str & ", " & len & ") = " & Right(str, len))
238 TestRight "test", 2, "st"
239 TestRight "test", 5, "test"
240 TestRight "test", 0, ""
241 TestRight 123, 2, "23"
242 if isEnglishLang then TestRight true, 2, "ue"
244 Sub TestTrim(str, exstr)
245 Call ok(Trim(str) = exstr, "Trim(" & str & ") = " & Trim(str))
248 TestTrim " test ", "test"
249 TestTrim "test ", "test"
250 TestTrim " test", "test"
251 TestTrim "test", "test"
254 if isEnglishLang then TestTrim true, "True"
256 Sub TestLTrim(str, exstr)
257 Call ok(LTrim(str) = exstr, "LTrim(" & str & ") = " & LTrim(str))
260 TestLTrim " test ", "test "
261 TestLTrim "test ", "test "
262 TestLTrim " test", "test"
263 TestLTrim "test", "test"
266 if isEnglishLang then TestLTrim true, "True"
268 Sub TestRound(val, exval, vt)
269 Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
270 Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
273 Sub TestRTrim(str, exstr)
274 Call ok(RTrim(str) = exstr, "RTrim(" & str & ") = " & RTrim(str))
277 TestRTrim " test ", " test"
278 TestRTrim "test ", "test"
279 TestRTrim " test", " test"
280 TestRTrim "test", "test"
283 if isEnglishLang then TestRTrim true, "True"
285 TestRound 3, 3, "VT_I2"
286 TestRound 3.3, 3, "VT_R8"
287 TestRound 3.8, 4, "VT_R8"
288 TestRound 3.5, 4, "VT_R8"
289 TestRound -3.3, -3, "VT_R8"
290 TestRound -3.5, -4, "VT_R8"
291 TestRound "2", 2, "VT_R8"
292 TestRound true, true, "VT_BOOL"
293 TestRound false, false, "VT_BOOL"
295 if isEnglishLang then
296 Call ok(WeekDayName(1) = "Sunday", "WeekDayName(1) = " & WeekDayName(1))
297 Call ok(WeekDayName(3) = "Tuesday", "WeekDayName(3) = " & WeekDayName(3))
298 Call ok(WeekDayName(7) = "Saturday", "WeekDayName(7) = " & WeekDayName(7))
299 Call ok(WeekDayName(1.1) = "Sunday", "WeekDayName(1.1) = " & WeekDayName(1.1))
300 Call ok(WeekDayName(1, false) = "Sunday", "WeekDayName(1, false) = " & WeekDayName(1, false))
301 Call ok(WeekDayName(1, true) = "Sun", "WeekDayName(1, true) = " & WeekDayName(1, true))
302 Call ok(WeekDayName(1, 10) = "Sun", "WeekDayName(1, 10) = " & WeekDayName(1, 10))
303 Call ok(WeekDayName(1, true, 0) = "Sun", "WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
304 Call ok(WeekDayName(1, true, 2) = "Mon", "WeekDayName(1, true, 2) = " & WeekDayName(1, true, 2))
305 Call ok(WeekDayName(1, true, 7) = "Sat", "WeekDayName(1, true, 7) = " & WeekDayName(1, true, 7))
306 Call ok(WeekDayName(1, true, 7.1) = "Sat", "WeekDayName(1, true, 7.1) = " & WeekDayName(1, true, 7.1))
308 Call ok(MonthName(1) = "January", "MonthName(1) = " & MonthName(1))
309 Call ok(MonthName(12) = "December", "MonthName(12) = " & MonthName(12))
310 Call ok(MonthName(1, 0) = "January", "MonthName(1, 0) = " & MonthName(1, 0))
311 Call ok(MonthName(12, false) = "December", "MonthName(12, false) = " & MonthName(12, false))
312 Call ok(MonthName(1, 10) = "Jan", "MonthName(1, 10) = " & MonthName(1, 10))
313 Call ok(MonthName(12, true) = "Dec", "MonthName(12, true) = " & MonthName(12, true))
316 Call ok(getVT(Now()) = "VT_DATE", "getVT(Now()) = " & getVT(Now()))
318 Call ok(vbOKOnly = 0, "vbOKOnly = " & vbOKOnly)
319 Call ok(getVT(vbOKOnly) = "VT_I2", "getVT(vbOKOnly) = " & getVT(vbOKOnly))
320 Call ok(vbOKCancel = 1, "vbOKCancel = " & vbOKCancel)
321 Call ok(getVT(vbOKCancel) = "VT_I2", "getVT(vbOKCancel) = " & getVT(vbOKCancel))
322 Call ok(vbAbortRetryIgnore = 2, "vbAbortRetryIgnore = " & vbAbortRetryIgnore)
323 Call ok(getVT(vbAbortRetryIgnore) = "VT_I2", "getVT(vbAbortRetryIgnore) = " & getVT(vbAbortRetryIgnore))
324 Call ok(vbYesNoCancel = 3, "vbYesNoCancel = " & vbYesNoCancel)
325 Call ok(getVT(vbYesNoCancel) = "VT_I2", "getVT(vbYesNoCancel) = " & getVT(vbYesNoCancel))
326 Call ok(vbYesNo = 4, "vbYesNo = " & vbYesNo)
327 Call ok(getVT(vbYesNo) = "VT_I2", "getVT(vbYesNo) = " & getVT(vbYesNo))
328 Call ok(vbRetryCancel = 5, "vbRetryCancel = " & vbRetryCancel)
329 Call ok(getVT(vbRetryCancel) = "VT_I2", "getVT(vbRetryCancel) = " & getVT(vbRetryCancel))
331 Call ok(vbOK = 1, "vbOK = " & vbOK)
332 Call ok(getVT(vbOK) = "VT_I2", "getVT(vbOK) = " & getVT(vbOK))
333 Call ok(vbCancel = 2, "vbCancel = " & vbCancel)
334 Call ok(getVT(vbCancel) = "VT_I2", "getVT(vbCancel) = " & getVT(vbCancel))
335 Call ok(vbAbort = 3, "vbAbort = " & vbAbort)
336 Call ok(getVT(vbAbort) = "VT_I2", "getVT(vbAbort) = " & getVT(vbAbort))
337 Call ok(vbRetry = 4, "vbRetry = " & vbRetry)
338 Call ok(getVT(vbRetry) = "VT_I2", "getVT(vbRetry) = " & getVT(vbRetry))
339 Call ok(vbIgnore = 5, "vbIgnore = " & vbIgnore)
340 Call ok(getVT(vbIgnore) = "VT_I2", "getVT(vbIgnore) = " & getVT(vbIgnore))
341 Call ok(vbYes = 6, "vbYes = " & vbYes)
342 Call ok(getVT(vbYes) = "VT_I2", "getVT(vbYes) = " & getVT(vbYes))
343 Call ok(vbNo = 7, "vbNo = " & vbNo)
344 Call ok(getVT(vbNo) = "VT_I2", "getVT(vbNo) = " & getVT(vbNo))