Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / weekday.vb
bloba37f07d1fac467e287d0dffee95130a539280797
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_testWeekDay()
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_testWeekDay() 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
27 testName = "Test WeekDay function"
28 On Error GoTo errorHandler
30 date2 = 7
31 date1 = Weekday(#6/7/2009#, vbMonday)
32 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
34 date2 = 2
35 date1 = Weekday(#7/7/2009#, vbMonday)
36 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
38 date2 = 5
39 date1 = Weekday(#8/7/2009#, vbMonday)
40 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
42 date2 = 1
43 date1 = Weekday(#12/7/2009#, vbMonday)
44 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
46 date2 = 1
47 date1 = Weekday(#6/7/2009#, vbSunday)
48 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
50 date2 = 5
51 date1 = Weekday(#6/7/2009#, 4)
52 TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
55 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
56 verify_testWeekDay = result
58 Exit Function
59 errorHandler:
60 TestLog_ASSERT (False), testName & ": hit error handler"
61 End Function
63 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
65 If assertion = True Then
66 passCount = passCount + 1
67 Else
68 Dim testMsg As String
69 If Not IsMissing(testId) Then
70 testMsg = testMsg + " : " + testId
71 End If
72 If Not IsMissing(testComment) And Not (testComment = "") Then
73 testMsg = testMsg + " (" + testComment + ")"
74 End If
76 result = result & Chr$(10) & " Failed: " & testMsg
77 failCount = failCount + 1
78 End If
80 End Sub