5 ' This file is part of the LibreOffice project.
7 ' This Source Code Form is subject to the terms of the Mozilla Public
8 ' License, v. 2.0. If a copy of the MPL was not distributed with this
9 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 ' Test built-in compatibility versions of methods whose absence
13 ' is really felt in VBA, and large numbers of macros import from
17 Dim passCount
As Integer
18 Dim failCount
As Integer
21 Private Declare Function QueryPerformanceCounter
Lib "kernel32" (ByRef lpPerformanceCount
As Currency) As Long
22 Private Declare Function QueryPerformanceFrequency
Lib "kernel32" (ByRef lpFrequency
As Currency) As Long
24 ' FIXME: all this cut/paste should be factored out !
26 Function doUnitTest() As String
27 result
= verify_win32compat()
28 If failCount
<> 0 Then
36 Function verify_win32compat() as String
40 result
= "Test Results" & Chr
$(10) & "================" & Chr
$(10)
43 Dim count_a
As Currency
44 Dim count_b
As Currency
47 On Error GoTo errorHandler
49 success
= QueryPerformanceFrequency(freq
)
50 TestLog_ASSERT success
<> 0, "fetching perf. frequency"
51 TestLog_ASSERT freq
> 0, "perf. frequency is incorrect " & freq
53 success
= QueryPerformanceCounter(count_a
)
54 TestLog_ASSERT success
<> 0, "fetching performance count"
56 success
= QueryPerformanceCounter(count_b
)
57 TestLog_ASSERT success
<> 0, "fetching performance count"
58 TestLog_ASSERT count_a
< count_b
, "count mismatch " & count_a
& " is > " & count_b
60 verify_win32compat
= "OK"
64 TestLog_ASSERT (False), "hit error handler - " & Err
& ": " & Error$
& " (line : " & Erl
& ")"
65 verify_win32compat
= result
69 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
71 If assertion
= True Then
72 passCount
= passCount
+ 1
75 If Not IsMissing(testId
) Then
76 testMsg
= testMsg
+ " : " + testId
78 If Not IsMissing(testComment
) And Not (testComment
= "") Then
79 testMsg
= testMsg
+ " (" + testComment
+ ")"
82 result
= result
& Chr
$(10) & " Failed: " & testMsg
83 failCount
= failCount
+ 1