Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / day.vb
blobe33a7b84659b23fe721e876328e85db1dd4a8c7e
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_testday()
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_testday() 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 'variables for test
27 testName = "Test day function"
28 On Error GoTo errorHandler
30 date2 = 12
31 date1 = Day("1969-02-12") '2/12/1969
32 TestLog_ASSERT date1 = date2, "the return day is: " & date1
34 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
35 verify_testday = 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