Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / basic / qa / vba_tests / Err.Raise.vb
blobd7714facb3bb9427b764967e821ec6d22eae235f
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()
13 ''' This routine is QA/…/test_vba.cxx main entry point '''
14 Const MIN_ERR = &hFFFFFFFF : Const MAX_ERR = 2^31-1
16 ''' Raise one-to-many User-Defined Errors as signed Int32 '''
17 TestUtil.TestInit()
18 ' test_Description | Err # | Err_Source | Err_Description
19 Call TestErrRaise("MAXimum error value", MAX_ERR, "doUnitTest.vb", "Custom Error Maximum value")
20 Call TestErrRaise("Positive custom error", 1789, "" , "User-Defined Error Number")
21 Call TestErrRaise("Negative custom error", -1793, "doUnitTest.vb", "Negative User-Defined Error Number")
22 Call TestErrRaise("MINimum error value", MIN_ERR, "" , "Custom Error Minimum value")
24 doUnitTest = TestUtil.GetResult()
25 End Function
27 Sub TestErrRaise(TestName As String, CurErrNo As Long, CurErrSource As String, CurErrDescription As String)
28 Dim origPassCount As Integer, origFailCount As Integer
30 try: On Error Goto catch
31 Dim errorHandled As Integer
32 Err.Raise(CurErrNo, CurErrSource, CurErrDescription, "", "")
34 TestUtil.Assert(errorHandled = 1, TestName, "error handler did not execute!")
35 TestUtil.Assert(Erl = 0, TestName, "Erl = " & Erl)
36 TestUtil.Assert(Err = 0, TestName, "Err = " & Err)
37 TestUtil.Assert(Error = "", TestName, "Error = " & Error)
38 TestUtil.Assert(Err.Description = "", "Err.Description reset", "Err.Description = "& Err.Description)
39 TestUtil.Assert(Err.Number = 0, "Err.Number reset", "Err.Number = " & Err.Number)
40 TestUtil.Assert(Err.Source = "", "Err.Source reset", "Err.Source = " & Err.Source)
41 Exit Sub
43 catch:
44 TestUtil.Assert(Err.Number = CurErrNo, "Err.Number failure", "Err.Number = " & Err.Number)
45 TestUtil.Assert(Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source)
46 TestUtil.Assert(Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description)
48 TestUtil.Assert(Erl = 32, "line# failure", "Erl = " & Erl ) ' WATCH OUT for HARDCODED LINE # HERE
49 TestUtil.Assert(Err = CurErrNo, "Err# failure", "Err = " & Err)
50 TestUtil.Assert(Error = CurErrDescription, "Error description failure", "Error$ = " & Error$)
52 errorHandled = 1
53 Resume Next ' Err object properties reset from here …
54 End Sub