Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / dateserial.vb
blob4b28f09d584008e6166fffda1b273f7b44465c6b
1 Option VBASupport 1
2 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_testDateSerial()
10 If failCount <> 0 Or passCount = 0 Then
11 doUnitTest = result
12 Else
13 doUnitTest = "OK"
14 End If
15 End Function
17 Function verify_testDateSerial() as String
18 Dim testName As String
19 Dim date1, date2 As Date
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 testName = "Test DateSerial function"
26 date2 = 36326
28 On Error GoTo errorHandler
30 date1 = DateSerial(1999, 6, 15) '6/15/1999
31 TestLog_ASSERT date1 = date2, "the return date is: " & date1
32 date1 = DateSerial(2000, 1 - 7, 15) '6/15/1999
33 TestLog_ASSERT date1 = date2, "the return date is: " & date1
34 date1 = DateSerial(1999, 1, 166) '6/15/1999
35 TestLog_ASSERT date1 = date2, "the return date is: " & date1
36 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
38 verify_testDateSerial = result
40 Exit Function
41 errorHandler:
42 TestLog_ASSERT (False), testName & ": hit error handler"
43 End Function
45 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
47 If assertion = True Then
48 passCount = passCount + 1
49 Else
50 Dim testMsg As String
51 If Not IsMissing(testId) Then
52 testMsg = testMsg + " : " + testId
53 End If
54 If Not IsMissing(testComment) And Not (testComment = "") Then
55 testMsg = testMsg + " (" + testComment + ")"
56 End If
58 result = result & Chr$(10) & " Failed: " & testMsg
59 failCount = failCount + 1
60 End If
62 End Sub