Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / basic / qa / vba_tests / win32compatb.vb
blobf729725ea55e27c662b1e8ff481f8cd5b64bd7c3
2 ' This file is part of the LibreOffice project.
4 ' This Source Code Form is subject to the terms of the Mozilla Public
5 ' License, v. 2.0. If a copy of the MPL was not distributed with this
6 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 ' Test built-in compatibility versions of methods whose absence
9 ' is really felt in VBA, and large numbers of macros import from
10 ' the system.
12 ' This module tests different signatures for the same methods.
15 Option VBASupport 1
16 Option Explicit
18 Private Type LARGE_INTEGER
19 lowpart As Long
20 highpart As Long
21 End Type
23 Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
24 Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
26 Function doUnitTest() As String
27 TestUtil.TestInit
28 verify_win32compatb
29 doUnitTest = TestUtil.GetResult()
30 End Function
32 Function convertLarge(scratch As LARGE_INTEGER) As Double
33 Dim ret As Double
34 ret = scratch.highpart
35 ret = ret * 65536 * 65536
36 ret = ret + scratch.lowpart
37 convertLarge = ret
38 End Function
40 Sub verify_win32compatb()
41 Dim scratch as LARGE_INTEGER
42 Dim freq As Double
43 Dim count_a As Double
44 Dim count_b As Double
45 Dim success As Long
47 On Error GoTo errorHandler
49 success = QueryPerformanceFrequency(scratch)
50 TestUtil.Assert(success <> 0, "QueryPerformanceFrequency")
51 freq = convertLarge(scratch)
52 TestUtil.Assert(freq > 0, "QueryPerformanceFrequency", "perf. frequency is incorrect " & freq)
54 success = QueryPerformanceCounter(scratch)
55 TestUtil.Assert(success <> 0, "QueryPerformanceCounter")
56 count_a = convertLarge(scratch)
58 ' success = QueryPerformanceCounter(scratch)
59 ' TestUtil.Assert(success <> 0, "fetching performance count")
60 ' count_b = convertLarge(scratch)
61 ' TestUtil.Assert(count_a < count_b, "count mismatch " & count_a & " is > " & count_b)
63 Exit Sub
64 errorHandler:
65 TestUtil.ReportErrorHandler("verify_win32compatb", Err, Error$, Erl)
66 End Sub