Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / cvdate.vb
blob58ef6ca7d6739111c95f6d1fc8e71b778ff3eb71
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_testCVDate()
9 If failCount <> 0 And passCount > 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
18 Function verify_testCVDate() 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 As Date 'variables for test
27 testName = "Test CVDate function"
28 On Error GoTo errorHandler
30 date2 = 25246
31 date1 = CVDate("12.2.1969") '2/12/1969
32 TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
34 date2 = 28313
35 date1 = CVDate("07/07/1977")
36 TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
38 date2 = 28313
39 date1 = CVDate(#7/7/1977#)
40 TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
42 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
43 verify_testCVDate = result
45 Exit Function
46 errorHandler:
47 TestLog_ASSERT (False), testName & ": hit error handler"
48 End Function
50 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
52 If assertion = True Then
53 passCount = passCount + 1
54 Else
55 Dim testMsg As String
56 If Not IsMissing(testId) Then
57 testMsg = testMsg + " : " + testId
58 End If
59 If Not IsMissing(testComment) And Not (testComment = "") Then
60 testMsg = testMsg + " (" + testComment + ")"
61 End If
63 result = result & Chr$(10) & " Failed: " & testMsg
64 failCount = failCount + 1
65 End If
67 End Sub