Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / basic / qa / vba_tests / typename.vb
blobb21d34cc4e0e64ffcd5d6f4d40bd8b47c5747c05
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/.
9 Option VBASupport 1
10 Option Explicit
12 Function doUnitTest() As String
13 TestUtil.TestInit
14 verify_testTypeName
15 doUnitTest = TestUtil.GetResult()
16 End Function
18 Sub verify_testTypeName()
19 On Error GoTo errorHandler
20 Dim b1 As Boolean
21 Dim c1 As Byte
22 Dim d1 As Date
23 Dim d2 As Double
24 Dim i1 As Integer
25 Dim l1 As Long
26 Dim s1 As String
28 Dim TestIntSign%
29 Dim TestLongSign&
30 Dim TestSingleSign!
31 Dim TestDoubleSign#
32 Dim TestCurrSign@
33 Dim TestStrSign$
35 TestUtil.AssertEqual(TypeName(varname:=s1), "String", "TypeName(varname:=s1")
37 TestUtil.AssertEqual(TypeName(s1), "String", "TypeName(s1)")
38 TestUtil.AssertEqual(TypeName(b1), "Boolean", "TypeName(b1)")
39 TestUtil.AssertEqual(TypeName(c1), "Byte", "TypeName(c1)")
40 TestUtil.AssertEqual(TypeName(d1), "Date", "TypeName(d1)")
41 TestUtil.AssertEqual(TypeName(d2), "Double", "TypeName(d2)")
42 TestUtil.AssertEqual(TypeName(i1), "Integer", "TypeName(i1)")
43 TestUtil.AssertEqual(TypeName(l1), "Long", "TypeName(l1)")
45 ' tdf#129596 - Types of constant values
46 TestUtil.AssertEqual(TypeName(32767), "Integer", "TypeName(32767)")
47 TestUtil.AssertEqual(TypeName(-32767), "Integer", "TypeName(-32767)")
48 TestUtil.AssertEqual(TypeName(1048575), "Long", "TypeName(1048575)")
49 TestUtil.AssertEqual(TypeName(-1048575), "Long", "TypeName(-1048575)")
51 TestUtil.AssertEqual(TypeName(TestIntSign), "Integer", "TypeName(TestIntSign)")
52 TestUtil.AssertEqual(TypeName(TestLongSign), "Long", "TypeName(TestLongSign)")
53 TestUtil.AssertEqual(TypeName(TestSingleSign), "Single", "TypeName(TestSingleSign)")
54 TestUtil.AssertEqual(TypeName(TestDoubleSign), "Double", "TypeName(TestDoubleSign)")
55 TestUtil.AssertEqual(TypeName(TestCurrSign), "Currency", "TypeName(TestCurrSign)")
56 TestUtil.AssertEqual(TypeName(TestStrSign), "String", "TypeName(TestStrSign)")
58 ' tdf#143707 - check correct initialization of default value for optionals
59 ' Without the fix in place, this test would have failed with
60 ' - Expected: Integer
61 ' - Actual : String
62 TestUtil.AssertEqual(TestOptVariantInit(), "Integer", "TestOptVariantInit()")
64 Exit Sub
65 errorHandler:
66 TestUtil.ReportErrorHandler("verify_testTypeName", Err, Error$, Erl)
67 End Sub
69 Function TestOptVariantInit(Optional A As Variant = 123)
70 TestOptVariantInit = TypeName(A)
71 End Function