1 ' This file is part of the LibreOffice project.
3 ' This Source Code Form is subject to the terms of the Mozilla Public
4 ' License, v. 2.0. If a copy of the MPL was not distributed with this
5 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 Function doUnitTest() As String
15 doUnitTest
= TestUtil
.GetResult()
18 Sub verify_optionBase()
20 On Error GoTo errorHandler
22 ' tdf#54912 - with option base arrays should start at index 1.
23 ' With option compatible the upper bound is not changed (#109275).
24 Dim strArray(2) As String
25 TestUtil
.AssertEqual(LBound(strArray
), 1, "Lower bound of a string array (before assignment): " & LBound(strArray
))
26 TestUtil
.AssertEqual(UBound(strArray
), 2, "Upper bound of a string array (before assignment): " & UBound(strArray
))
27 strArray
= Array("a", "b")
28 TestUtil
.AssertEqual(LBound(strArray
), 1, "Lower bound of a string array (after assignment): " & LBound(strArray
))
29 TestUtil
.AssertEqual(UBound(strArray
), 2, "Upper bound of a string array (after assignment): " & UBound(strArray
))
31 Dim intArray(2) As Integer
32 TestUtil
.AssertEqual(LBound(intArray
), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray
))
33 TestUtil
.AssertEqual(UBound(intArray
), 2, "Upper bound of an integer array (before assignment): " & UBound(intArray
))
34 intArray
= Array(1, 2)
35 TestUtil
.AssertEqual(LBound(intArray
), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray
))
36 TestUtil
.AssertEqual(UBound(intArray
), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray
))
38 Dim byteArray(2) As Byte
39 TestUtil
.AssertEqual(LBound(byteArray
), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray
))
40 TestUtil
.AssertEqual(UBound(byteArray
), 2, "Upper bound of a byte array (before assignment): " & UBound(byteArray
))
41 byteArray
= StrConv("ab", 128)
42 TestUtil
.AssertEqual(LBound(byteArray
), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray
))
43 TestUtil
.AssertEqual(UBound(byteArray
), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray
))
46 TestUtil
.AssertEqual(LBound(byteArray
), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray
))
47 TestUtil
.AssertEqual(UBound(byteArray
), 3, "Upper bound of a byte array (ReDim): " & UBound(byteArray
))
51 TestUtil
.ReportErrorHandler("verify_optionBase", Err
, Error$, Erl
)