tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / basic / qa / basic_coverage / test_option_base.bas
blob69282f80bec6fceb89250dfbe36e2d5993ede2ac
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/.
8 Option Base 1
9 Option Explicit
11 Function doUnitTest() As String
12 TestUtil.TestInit
13 verify_optionBase
14 doUnitTest = TestUtil.GetResult()
15 End Function
17 Sub verify_optionBase() As String
18 On Error GoTo errorHandler
20 ' tdf#54912 - with option base arrays should start at index 1.
21 ' Without option compatible the upper bound is changed as well (#109275).
22 Dim strArray(2) As String
23 TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray))
24 TestUtil.AssertEqual(UBound(strArray), 3, "Upper bound of a string array (before assignment): " & UBound(strArray))
25 strArray = Array("a", "b")
26 TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray))
27 TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray))
29 Dim intArray(2) As Integer
30 TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray))
31 TestUtil.AssertEqual(UBound(intArray), 3, "Upper bound of an integer array (before assignment): " & UBound(intArray))
32 intArray = Array(1, 2)
33 TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray))
34 TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray))
36 Dim byteArray(2) As Byte
37 TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray))
38 TestUtil.AssertEqual(UBound(byteArray), 3, "Upper bound of a byte array (before assignment): " & UBound(byteArray))
39 byteArray = StrConv("ab", 128)
40 TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray))
41 TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray))
43 ReDim byteArray(3)
44 TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray))
45 TestUtil.AssertEqual(UBound(byteArray), 4, "Upper bound of a byte array (ReDim): " & UBound(byteArray))
47 Exit Sub
48 errorHandler:
49 TestUtil.ReportErrorHandler("verify_optionBase", Err, Error$, Erl)
50 End Sub