Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / cverr.vb
blob11707ba2517cbcaaceea1e158aa54c5e270aa5c7
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_testCVErr()
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_testCVErr() 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 CVErr function"
28 On Error GoTo errorHandler
30 date2 = "Error 3001"
31 date1 = CStr(CVErr(3001))
32 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
34 date2 = "Error 2007"
35 date1 = CStr(CVErr(xlErrDiv0))
36 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
38 date2 = "Error 2042"
39 date1 = CStr(CVErr(xlErrNA))
40 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
42 date2 = "Error 2029"
43 date1 = CStr(CVErr(xlErrName))
44 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
46 date2 = "Error 2000"
47 date1 = CStr(CVErr(xlErrNull))
48 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
50 date2 = "Error 2036"
51 date1 = CStr(CVErr(xlErrNum))
52 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
54 date2 = "Error 2023"
55 date1 = CStr(CVErr(xlErrRef))
56 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
58 date2 = "Error 2015"
59 date1 = CStr(CVErr(xlErrValue))
60 TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
62 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
63 verify_testCVErr = result
65 Exit Function
66 errorHandler:
67 TestLog_ASSERT (False), testName & ": hit error handler"
68 End Function
70 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
72 If assertion = True Then
73 passCount = passCount + 1
74 Else
75 Dim testMsg As String
76 If Not IsMissing(testId) Then
77 testMsg = testMsg + " : " + testId
78 End If
79 If Not IsMissing(testComment) And Not (testComment = "") Then
80 testMsg = testMsg + " (" + testComment + ")"
81 End If
83 result = result & Chr$(10) & " Failed: " & testMsg
84 failCount = failCount + 1
85 End If
87 End Sub