Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / asc.vb
blob813abe9f859dca896ae3eb8ad351f7516c47779d
1 Rem Attribute VBA_ModuleType=VBAModule
2 Option VBASupport 1
3 Option Explicit
4 Dim passCount As Integer
5 Dim failCount As Integer
6 Dim result As String
8 Function doUnitTest() As String
9 result = verify_testASC()
10 If failCount <> 0 Or passCount = 0 Then
11 doUnitTest = result
12 Else
13 doUnitTest = "OK"
14 End If
15 End Function
19 Function verify_testASC() As String
21 passCount = 0
22 failCount = 0
24 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
26 Dim testName As String
27 Dim nr1, nr2 As Double
29 testName = "Test ASC function"
30 On Error GoTo errorHandler
32 nr2 = 65
33 nr1 = Asc("A")
34 TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
36 nr2 = 97
37 nr1 = Asc("a")
38 TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
41 nr2 = 65
42 nr1 = Asc("Apple")
43 TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
45 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
46 verify_testASC = result
48 Exit Function
49 errorHandler:
50 TestLog_ASSERT (False), testName & ": hit error handler"
51 End Function
53 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
55 If assertion = True Then
56 passCount = passCount + 1
57 Else
58 Dim testMsg As String
59 If Not IsMissing(testId) Then
60 testMsg = testMsg + " : " + testId
61 End If
62 If Not IsMissing(testComment) And Not (testComment = "") Then
63 testMsg = testMsg + " (" + testComment + ")"
64 End If
66 result = result & Chr$(10) & " Failed: " & testMsg
67 failCount = failCount + 1
68 End If
70 End Sub