summaryrefslogtreecommitdiff
path: root/basic/qa
diff options
context:
space:
mode:
authorLibreOfficiant <LibreOfficiant@sfr.fr>2019-12-12 18:43:43 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2019-12-14 10:40:29 +0100
commit4171b99905a208de8a1a519f53b492ad24008f8e (patch)
tree68748d7fab012f95cd77aabb0fdac17539ccef39 /basic/qa
parent5bcdbf03012e9d2754c3eb166bd5a01201406d9b (diff)
VBA Enum statement TestCases
Change-Id: Ib8f730d22bc7de00736c9fb1bb9c1af1784eb5df Reviewed-on: https://gerrit.libreoffice.org/85074 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/qa')
-rw-r--r--basic/qa/cppunit/test_vba.cxx1
-rw-r--r--basic/qa/vba_tests/enum.vb87
2 files changed, 88 insertions, 0 deletions
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 7e6aa1726b50..74c9752cf1c5 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -82,6 +82,7 @@ void VBATest::testMiscVBAFunctions()
"datediff.vb",
"datepart.vb",
"day.vb",
+ "enum.vb",
"error.vb",
"exp.vb",
"fix.vb",
diff --git a/basic/qa/vba_tests/enum.vb b/basic/qa/vba_tests/enum.vb
new file mode 100644
index 000000000000..52dc95a7c9c0
--- /dev/null
+++ b/basic/qa/vba_tests/enum.vb
@@ -0,0 +1,87 @@
+'
+' 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 VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Enum CountDown ' Values get ROUNDED to Int32
+ FIVE = 4.11
+ FOUR = -4.25
+ THREE = 5
+ TWO = -.315E1
+ ONE = 286.0E-2 ' equals 3
+ LIFT_OFF = 7
+End Enum ' CountDown
+
+Function doUnitTest()
+ ''' test_vba.cxx main entry point '''
+ Call ENUM_TestCases
+ If failCount <> 0 Or passCount = 0 Then
+ doUnitTest = result
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
+
+
+Sub ENUM_TestCases()
+
+ passCount = 0
+ failCount = 0
+
+ result = "Test Results" & vbNewLine & "============" & vbNewLine
+
+try:
+ On Error Goto catch
+
+ With CountDown
+
+a: TestLog_ASSERT .ONE = 3, "case a", "CountDown.ONE equals " & Str(.ONE)
+
+b: TestLog_ASSERT .TWO = -3, "case b", "CountDown.TWO equals " & Str(.TWO)
+
+c: TestLog_ASSERT TypeName(.FOUR) = "Long", "case c", "CountDown.FOUR type is: " & TypeName(.FOUR)
+
+d: Dim sum As Double
+ sum = .FIVE + .FOUR + .THREE + .TWO + .ONE + .LIFT_OFF
+ TestLog_Assert sum = 12, "case d", "SUM of CountDown values is: " & Str(sum)
+
+ End With ' CountDown
+
+finally:
+ result = result & vbNewLine & "Tests passed: " & passCount & vbNewLine & "Tests failed: " & failCount & vbNewLine
+ Exit Sub
+
+catch:
+ TestLog_ASSERT (False), "ERROR", "#"& Str(Err.Number) &" in 'ENUM_TestCases' at line"& Str(Erl) &" - "& Error$
+ Resume Next
+End Sub
+
+Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
+
+ If assertion = True Then
+ passCount = passCount + 1
+ Else
+ Dim testMsg As String
+ If Not IsMissing(testId) Then
+ testMsg = testMsg + testId + ":"
+ End If
+ If Not IsMissing(testComment) And Not (testComment = "") Then
+ testMsg = testMsg + " (" + testComment + ")"
+ End If
+
+ result = result & vbNewLine & "Failed: " & testMsg
+ failCount = failCount + 1
+ End If
+
+End Sub
+
+'Sub DEV_TEST : doUnitTest : MsgBox result : End Sub