Debian Codegraph @

basic/qa/basic_coverage/test_unsigned_integers.bas

raw
1 '
2 ' This file is part of the LibreOffice project.
3 '
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/.
7 '
8
9 Option Explicit
10
11 Function doUnitTest() As String
12 TestUtil.TestInit
13 verify_testUnsignedIntegers
14 doUnitTest = TestUtil.GetResult()
15 End Function
16
17 Function convertToDouble(n)
18 Dim conv As Object
19 conv = CreateUnoService("com.sun.star.script.Converter")
20 convertToDouble = conv.convertToSimpleType(n, com.sun.star.uno.TypeClass.DOUBLE)
21 End Function
22
23 Sub verify_testUnsignedIntegers()
24 On Error GoTo errorHandler
25
26 Dim t As New com.sun.star.util.Time ' has both unsigned long and unsigned short
27 t.Seconds = 201
28 t.NanoSeconds = 202
29 Dim u8 As Byte, u16, u32
30 u8 = 200
31 u16 = t.Seconds ' UShort
32 u32 = t.NanoSeconds ' ULong
33
34 TestUtil.AssertEqual(TypeName(u8), "Byte", "TypeName(u8)")
35 TestUtil.AssertEqual(convertToDouble(u8), 200, "convertToDouble(u8)")
36
37 TestUtil.AssertEqual(TypeName(u16), "UShort", "TypeName(u16)")
38 TestUtil.AssertEqual(convertToDouble(u16), 201, "convertToDouble(u16)")
39
40 TestUtil.AssertEqual(TypeName(u32), "ULong", "TypeName(u32)")
41 TestUtil.AssertEqual(convertToDouble(u32), 202, "convertToDouble(u32)")
42
43 Exit Sub
44 errorHandler:
45 TestUtil.ReportErrorHandler("verify_testUnsignedIntegers", Err, Error$, Erl)
46 End Sub