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 Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
42 Set x = new EmptyClass
43 Call ok(isObject(x), "isObject(x) is not true?")
44 Call ok(isObject(Nothing), "isObject(Nothing) is not true?")
45 Call ok(not isObject(true), "isObject(true) is true?")
46 Call ok(not isObject(4), "isObject(4) is true?")
47 Call ok(not isObject("x"), "isObject(""x"") is true?")
48 Call ok(not isObject(Null), "isObject(Null) is true?")
50 Call ok(not isEmpty(new EmptyClass), "isEmpty(new EmptyClass) is true?")
51 Set x = new EmptyClass
52 Call ok(not isEmpty(x), "isEmpty(x) is true?")
54 Call ok(isEmpty(x), "isEmpty(x) is not true?")
55 Call ok(isEmpty(empty), "isEmpty(empty) is not true?")
56 Call ok(not isEmpty(Nothing), "isEmpty(Nothing) is not true?")
57 Call ok(not isEmpty(true), "isEmpty(true) is true?")
58 Call ok(not isEmpty(4), "isEmpty(4) is true?")
59 Call ok(not isEmpty("x"), "isEmpty(""x"") is true?")
60 Call ok(not isEmpty(Null), "isEmpty(Null) is true?")
62 Call ok(not isNull(new EmptyClass), "isNull(new EmptyClass) is true?")
63 Set x = new EmptyClass
64 Call ok(not isNull(x), "isNull(x) is true?")
66 Call ok(isNull(x), "isNull(x) is not true?")
67 Call ok(not isNull(empty), "isNull(empty) is true?")
68 Call ok(not isNull(Nothing), "isNull(Nothing) is true?")
69 Call ok(not isNull(true), "isNull(true) is true?")
70 Call ok(not isNull(4), "isNull(4) is true?")
71 Call ok(not isNull("x"), "isNull(""x"") is true?")
72 Call ok(isNull(Null), "isNull(Null) is not true?")
74 Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
77 Call ok(hex(x) = ex, "hex(" & x & ") = " & hex(x) & " expected " & ex)
83 TestHex &hdeadbeef&, "DEADBEEF"
86 TestHex -934859845, "C8472BBB"
89 Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
90 Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
92 x = InStr(1, "abcd", "bc")
93 Call ok(x = 2, "InStr returned " & x)
95 x = InStr("abcd", "bc")
96 Call ok(x = 2, "InStr returned " & x)
98 x = InStr("abc", "bc")
99 Call ok(x = 2, "InStr returned " & x)
101 x = InStr("abcbc", "bc")
102 Call ok(x = 2, "InStr returned " & x)
104 x = InStr("bcabc", "bc")
105 Call ok(x = 1, "InStr returned " & x)
107 x = InStr(3, "abcd", "bc")
108 Call ok(x = 0, "InStr returned " & x)
110 x = InStr("abcd", "bcx")
111 Call ok(x = 0, "InStr returned " & x)
113 x = InStr(5, "abcd", "bc")
114 Call ok(x = 0, "InStr returned " & x)
118 Call ok(x = 2, "InStr returned " & x)
120 x = InStr("abcd", null)
121 Call ok(isNull(x), "InStr returned " & x)
122 x = InStr(null, "abcd")
123 Call ok(isNull(x), "InStr returned " & x)
124 x = InStr(2, null, "abcd")
125 Call ok(isNull(x), "InStr returned " & x)
127 x = InStr(1.3, "abcd", "bc")
128 Call ok(x = 2, "InStr returned " & x)
130 x = InStr(2.3, "abcd", "bc")
131 Call ok(x = 2, "InStr returned " & x)
133 x = InStr(2.6, "abcd", "bc")
134 Call ok(x = 0, "InStr returned " & x)
136 Sub TestMid(str, start, len, ex)
137 x = Mid(str, start, len)
138 Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
141 Sub TestMid2(str, start, ex)
143 Call ok(x = ex, "Mid(" & str & ", " & start & ") = " & x & " expected " & ex)
146 TestMid "test", 2, 2, "es"
147 TestMid "test", 2, 4, "est"
148 TestMid "test", 1, 2, "te"
149 TestMid "test", 1, 0, ""
150 TestMid "test", 1, 0, ""
151 TestMid "test", 5, 2, ""
152 TestMid2 "test", 1, "test"
153 TestMid2 "test", 2, "est"
154 TestMid2 "test", 4, "t"
155 TestMid2 "test", 5, ""
157 Sub TestUCase(str, ex)
159 Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
162 TestUCase "test", "TEST"
163 TestUCase "123aBC?", "123ABC?"
166 if isEnglishLang then TestUCase true, "TRUE"
167 TestUCase 0.123, doubleAsString(0.123)
169 Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
171 Sub TestLCase(str, ex)
173 Call ok(x = ex, "LCase(" & str & ") = " & x & " expected " & ex)
176 TestLCase "test", "test"
177 TestLCase "123aBC?", "123abc?"
180 if isEnglishLang then TestLCase true, "true"
181 TestLCase 0.123, doubleAsString(0.123)
183 Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
185 Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
186 Call ok(Len("") = 0, "Len() = " & Len(""))
187 Call ok(Len(1) = 1, "Len(1) = " & Len(1))
188 Call ok(isNull(Len(null)), "Len(null) = " & Len(null))
189 Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
191 Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
192 Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
193 Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
194 Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """")
195 Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """")
196 Call ok(Space(5.5) = " ", "Space(5.5) = " & Space(5.5) & """")
198 Sub TestRound(val, exval, vt)
199 Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
200 Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
203 TestRound 3, 3, "VT_I2"
204 TestRound 3.3, 3, "VT_R8"
205 TestRound 3.8, 4, "VT_R8"
206 TestRound 3.5, 4, "VT_R8"
207 TestRound -3.3, -3, "VT_R8"
208 TestRound -3.5, -4, "VT_R8"
209 TestRound "2", 2, "VT_R8"
210 TestRound true, true, "VT_BOOL"
211 TestRound false, false, "VT_BOOL"