summaryrefslogtreecommitdiffstats
path: root/basic/qa/basic_coverage/test_typename_method.bas
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /basic/qa/basic_coverage/test_typename_method.bas
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/qa/basic_coverage/test_typename_method.bas')
-rw-r--r--basic/qa/basic_coverage/test_typename_method.bas78
1 files changed, 78 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/test_typename_method.bas b/basic/qa/basic_coverage/test_typename_method.bas
new file mode 100644
index 000000000..80a9658d2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_typename_method.bas
@@ -0,0 +1,78 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option Explicit
+
+Type UDF ' User defined type
+ l As Object
+ s as String
+End Type
+Dim myUDF as UDF
+
+Dim int16 As Integer, int32 As Long, flt32 As Single, flt64 As Double, _
+ curr As Currency, dat As Date, str As String, obj As Object, _
+ myErr As Variant, var As Variant, byt3 As Byte, bool As Boolean
+
+Dim int_%, long_&, single_!, double_#, currency_@, string_$, array_
+
+Dim intArray() As Integer, lngArray(5) As Long, sngArray!() As Single, dblArray#(8) As Double, _
+ curArray@() As Currency, datArray() As Date, strArray$() As String, objArray(5,15) As Object, _
+ varArray() As Variant, byteArray() As Byte, boolArray() As Boolean
+
+Function doUnitTest ' TypeName()
+
+ myErr = CVErr(0.56E-41)
+ assert( TypeName(int16) = "Integer" , "TypeName(int16) is not ""Integer""")
+ assert( TypeName(int32) = "Long" , "TypeName(int32) is not ""Long""")
+ assert( TypeName(flt32) = "Single" , "TypeName(flt32) is not ""Single""" )
+ assert( TypeName(flt64) = "Double" , "TypeName(flt64) is not ""Double""" )
+ assert( TypeName(curr) = "Currency", "TypeName(curr) is not ""Currency""" )
+ assert( TypeName(dat) = "Date" , "TypeName(dat) is not ""Date""" )
+ assert( TypeName(byt3) = "Byte" , "TypeName(byt3) is not ""Byte""" )
+ assert( TypeName(MyErr) = "Error" , "TypeName(MyErr) is not ""Error""" )
+ assert( TypeName(bool) = "Boolean" , "TypeName(bool) is not ""Boolean""" )
+ assert( TypeName(str) = "String" , "TypeName(str) is not ""String""" )
+ assert( TypeName(obj) = "Object" , "TypeName(obj) is not ""Object""" )
+ assert( TypeName(myUDF) = "Object" , "TypeName(myUDF) is not ""Object""" )
+ assert( TypeName(var) = "Empty" , "TypeName(var) is not ""Empty""" )
+
+ assert( TypeName(int_) = "Integer" , "TypeName(int_) is not ""Integer""" )
+ assert( TypeName(long_) = "Long" , "TypeName(long_) is not ""Long""" )
+ assert( TypeName(single_) = "Single" , "TypeName(single_) is not ""Single""" )
+ assert( TypeName(double_) = "Double" , "TypeName(double_) is not ""Double""" )
+ assert( TypeName(currency_) = "Currency", "TypeName(currency_) is not ""Currency""" )
+ assert( TypeName(string_) = "String" , "TypeName(string_) is not ""String""" )
+
+ assert( TypeName(intArray) = "Integer()" , "TypeName(intArray) is not ""Integer()""" )
+ assert( TypeName(lngArray) = "Long()" , "TypeName(lngArray) is not ""Long()""" )
+ assert( TypeName(sngArray) = "Single()" , "TypeName(sngArray) is not ""Single()""" )
+ assert( TypeName(dblArray) = "Double()" , "TypeName(dblArray) is not ""Double()""" )
+ assert( TypeName(curArray) = "Currency()", "TypeName(curArray) is not ""Currency()""" )
+ assert( TypeName(datArray) = "Date()" , "TypeName(datArray) is not ""Date()""" )
+ assert( TypeName(strArray) = "String()" , "TypeName(strArray) is not ""String()""" )
+ assert( TypeName(objArray) = "Object()" , "TypeName(objArray) is not ""Object()""" )
+ assert( TypeName(boolArray) = "Boolean()" , "TypeName(boolArray) is not ""Boolean()""" )
+ assert( TypeName(varArray) = "Variant()" , "TypeName(varArray) is not ""Variant()""" )
+ assert( TypeName(byteArray) = "Byte()" , "TypeName(byteArray) is not ""Byte()""" )
+ If FailedAssertion Then
+ doUnitTest = "test_typename_method.vb failed" + messages
+ Exit Function
+ EndIf
+ doUnitTest = "OK" ' All checks passed
+End Function
+
+Sub DEV_TEST : Print doUnitTest : End Sub
+
+Dim failedAssertion As Boolean, messages As String
+
+Sub assert(expression As Boolean, errMessage As String)
+ if ( Not expression ) Then
+ messages = messages + Chr(10) + ErrMessage
+ failedAssertion = True
+ EndIf
+End Sub