Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / sgn.vb
blobe72215679e6d4ebd326fef59bdd9f9bbcc21c7df
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_SGN()
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_SGN() 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 SGN function"
28 On Error GoTo errorHandler
30 date2 = 0
31 date1 = sgn(0)
32 TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
34 date2 = -1
35 date1 = sgn(-1)
36 TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
38 date2 = 1
39 date1 = sgn(1)
40 TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
42 date2 = 1
43 date1 = sgn(50)
44 TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
46 date2 = -1
47 date1 = sgn(-50)
48 TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
50 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
51 verify_SGN = result
53 Exit Function
54 errorHandler:
55 TestLog_ASSERT (False), testName & ": hit error handler"
56 End Function
58 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
60 If assertion = True Then
61 passCount = passCount + 1
62 Else
63 Dim testMsg As String
64 If Not IsMissing(testId) Then
65 testMsg = testMsg + " : " + testId
66 End If
67 If Not IsMissing(testComment) And Not (testComment = "") Then
68 testMsg = testMsg + " (" + testComment + ")"
69 End If
71 result = result & Chr$(10) & " Failed: " & testMsg
72 failCount = failCount + 1
73 End If
75 End Sub