Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / error.vb
blobe36661253be2a50d0846e6e7849fc4a45b194080
1 Option VBASupport 1
2 Option Explicit
3 Dim passCount As Integer
4 Dim failCount As Integer
5 Dim result As String
7 Function doUnitTest() As String
8 result = verify_testError()
9 If failCount <> 0 or passCount = 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
18 Function verify_testError() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim date1, date2
27 testName = "Test Error function"
28 On Error GoTo errorHandler
30 date2 = Error(11) 'https://help.libreoffice.org/Basic/Error_Function_Runtime
31 date1 = "Division by zero."
32 TestLog_ASSERT date1 = date2, "the return Error is: " & date2
34 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
35 verify_testError = result
37 Exit Function
38 errorHandler:
39 TestLog_ASSERT (False), testName & ": hit error handler"
40 End Function
42 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
44 If assertion = True Then
45 passCount = passCount + 1
46 Else
47 Dim testMsg As String
48 If Not IsMissing(testId) Then
49 testMsg = testMsg + " : " + testId
50 End If
51 If Not IsMissing(testComment) And Not (testComment = "") Then
52 testMsg = testMsg + " (" + testComment + ")"
53 End If
55 result = result & Chr$(10) & " Failed: " & testMsg
56 failCount = failCount + 1
57 End If
59 End Sub