tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / basic / qa / vba_tests / stringplusdouble.vb
blob7c5045eadd4232cdc73d797a5b7accfd9ef9485a
2 ' This file is part of the LibreOffice project.
4 ' This Source Code Form is subject to the terms of the Mozilla Public
5 ' License, v. 2.0. If a copy of the MPL was not distributed with this
6 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 Option VBASupport 1
10 Option Explicit
12 Function doUnitTest() As String
13 TestUtil.TestInit
14 DSD ' double = string + double
15 SSD ' string = string + double
16 DSS ' double = string + string
17 doUnitTest = TestUtil.GetResult()
18 End Function
20 Sub DSD()
21 Dim s As String
22 Dim d As Double
23 Dim r As Double
25 On Error GoTo ErrorHandler
27 r = s + d
28 TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d")
30 r = s & d
31 TestUtil.AssertEqual(r, 0, "s = null, d = null, r = s & d")
33 d = 20
34 r = s + d
35 TestUtil.AssertEqual(r, -1, "s = null, d = 20, r = s + d")
37 d = 20
38 r = s & d
39 TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d")
41 ''''''''''''''
42 s = "10"
43 Dim d2 As Double
44 r = s + d2
45 TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d")
47 r = s & d2
48 TestUtil.AssertEqual(r, 100, "s = '10', d = null, r = s & d")
50 d2 = 20
51 r = s + d2
52 TestUtil.AssertEqual(r, 30, "s = '10', d = 20, r = s + d")
54 d2 = 20
55 r = s & d2
56 TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d")
58 ''''''''''''''
59 s = "abc"
60 Dim d3 As Double
61 r = s + d3
62 TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d")
64 r = s & d3
65 TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d")
67 d3 = 20
68 r = s + d3
69 TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d")
71 d3 = 20
72 r = s & d3
73 TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d")
75 Exit Sub
77 ErrorHandler:
78 r = -1
79 Resume Next
80 End Sub
82 Sub SSD()
83 Dim s As String
84 Dim d As Double
85 Dim r As String
87 On Error GoTo ErrorHandler
89 r = s + d
90 TestUtil.AssertEqual(r, "-1", "s = null, d = null, r = s + d")
92 r = s & d
93 TestUtil.AssertEqual(r, "0", "s = null, d = null, r = s & d")
95 d = 20
96 r = s + d
97 TestUtil.AssertEqual(r, "-1", "s = null, d = 20, r = s + d")
99 d = 20
100 r = s & d
101 TestUtil.AssertEqual(r, "20", "s = null, d = 20, r = s & d")
103 ''''''''''''''
104 s = "10"
105 Dim d2 As Double
106 r = s + d2
107 TestUtil.AssertEqual(r, "10", "s = '10', d = null, r = s + d")
109 r = s & d2
110 TestUtil.AssertEqual(r, "100", "s = '10', d = null, r = s & d")
112 d2 = 20
113 r = s + d2
114 TestUtil.AssertEqual(r, "30", "s = '10', d = 20, r = s + d")
116 d2 = 20
117 r = s & d2
118 TestUtil.AssertEqual(r, "1020", "s = '10', d = 20, r = s & d")
120 ''''''''''''''
121 s = "abc"
122 Dim d3 As Double
123 r = s + d3
124 TestUtil.AssertEqual(r, "-1", "s = 'abc', d = null, r = s + d")
126 r = s & d3
127 TestUtil.AssertEqual(r, "abc0", "s = 'abc', d = null, r = s & d")
129 d3 = 20
130 r = s + d3
131 TestUtil.AssertEqual(r, "-1", "s = 'abc', d = 20, r = s + d")
133 d3 = 20
134 r = s & d3
135 TestUtil.AssertEqual(r, "abc20", "s = 'abc', d = 20, r = s & d")
136 Exit Sub
138 ErrorHandler:
139 r = "-1"
140 Resume Next
141 End Sub
143 Sub DSS()
144 Dim s As String
145 Dim d As String
146 Dim r As Double
148 On Error GoTo ErrorHandler
150 r = s + d
151 TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d")
153 r = s & d
154 TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s & d")
156 d = "20"
157 r = s + d
158 TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s + d")
160 d = "20"
161 r = s & d
162 TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d")
164 ''''''''''''''
165 s = "10"
166 Dim d2 As String
167 r = s + d2
168 TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d")
170 r = s & d2
171 TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s & d")
173 d2 = "20"
174 r = s + d2
175 TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s + d")
177 d2 = "20"
178 r = s & d2
179 TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d")
181 ''''''''''''''
182 s = "abc"
183 Dim d3 As String
184 r = s + d3
185 TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d")
187 r = s & d3
188 TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d")
190 d3 = "20"
191 r = s + d3
192 TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d")
194 d3 = "20"
195 r = s & d3
196 TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d")
197 Exit Sub
199 ErrorHandler:
200 r = -1
201 Resume Next
202 End Sub
204 Sub test2()
205 Dim s As String
206 Dim d As Double
207 s = ""
208 d = s ' fail in MSO
209 MsgBox d
210 End Sub
212 Sub testBoolean()
213 Dim a As String
214 Dim b As Boolean
215 Dim c As Boolean
216 Dim d As String
218 b = True
220 a = "1"
221 c = a + b ' c = false
222 MsgBox c
224 d = a + b 'd = 0
225 MsgBox d
226 End Sub
228 Sub testCurrency()
229 Dim a As String
230 Dim b As Currency
231 Dim c As Currency
232 Dim d As String
234 a = "10"
235 b = 30.3
237 c = a + b ' c = 40.3
238 MsgBox c
240 d = a + b ' c =40.3
241 MsgBox d
243 End Sub