Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / isobject.vb
blob82a1a0aa39a6bb76da1322c5b53358559ce7b19d
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_testIsObject()
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_testIsObject() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim TestStr As String
27 Dim MyObject As Object
28 Dim date1, date2, YourObject
29 testName = "Test IsObject function"
30 On Error GoTo errorHandler
32 Set YourObject = MyObject ' Assign an object reference.
33 date2 = True
34 date1 = IsObject(YourObject)
35 TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
37 date2 = False
38 date1 = IsObject(TestStr)
39 TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
41 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
42 verify_testIsObject = result
44 Exit Function
45 errorHandler:
46 TestLog_ASSERT (False), testName & ": hit error handler"
47 End Function
49 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
51 If assertion = True Then
52 passCount = passCount + 1
53 Else
54 Dim testMsg As String
55 If Not IsMissing(testId) Then
56 testMsg = testMsg + " : " + testId
57 End If
58 If Not IsMissing(testComment) And Not (testComment = "") Then
59 testMsg = testMsg + " (" + testComment + ")"
60 End If
62 result = result & Chr$(10) & " Failed: " & testMsg
63 failCount = failCount + 1
64 End If
66 End Sub