Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / cos.vb
blob993794b70f8c03faae4f57e4037e2efe0bcf547a
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_testCOS()
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_testCOS() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim nr1, nr2 As Double 'variables for test
27 testName = "Test COS function"
30 On Error GoTo errorHandler
32 nr2 = -0.532833020333398
33 nr1 = Cos(23)
34 TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
36 nr2 = 0.980066577841242
37 nr1 = Cos(0.2)
38 TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
40 nr2 = 0.487187675007006
41 nr1 = Cos(200)
42 TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
45 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
46 verify_testCOS = result
48 Exit Function
49 errorHandler:
50 TestLog_ASSERT (False), testName & ": hit error handler"
51 End Function
53 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
55 If assertion = True Then
56 passCount = passCount + 1
57 Else
58 Dim testMsg As String
59 If Not IsMissing(testId) Then
60 testMsg = testMsg + " : " + testId
61 End If
62 If Not IsMissing(testComment) And Not (testComment = "") Then
63 testMsg = testMsg + " (" + testComment + ")"
64 End If
66 result = result & Chr$(10) & " Failed: " & testMsg
67 failCount = failCount + 1
68 End If
70 End Sub