[Libreoffice-commits] core.git: basic/qa

Zdeněk Crhonek zcrhonek at gmail.com
Thu Apr 13 12:22:51 UTC 2017


 basic/qa/cppunit/test_vba.cxx   |   11 +++++
 basic/qa/vba_tests/isarray.vb   |   72 +++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/isdate.vb    |   70 ++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/isempty.vb   |   72 +++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/iserror.vb   |   66 ++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/ismissing.vb |   75 ++++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/isnull.vb    |   66 ++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/isnumeric.vb |   82 ++++++++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/isobject.vb  |   68 +++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/join.vb      |   78 ++++++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/lbound.vb    |   68 +++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/lcase.vb     |   75 ++++++++++++++++++++++++++++++++++++
 12 files changed, 803 insertions(+)

New commits:
commit 31dc11e7e34f112d37d34aa0700d413e052d1928
Author: Zdeněk Crhonek <zcrhonek at gmail.com>
Date:   Thu Apr 13 11:32:29 2017 +0200

    add VBA test cases
    
    tests:  ISARRAY, ISDATE, ISEMPTY, ISERROR, ISMISSING,
    ISNULL, ISNUMERIC, ISOBJECT, JOIN, LBOUND, LCASE
    
    Change-Id: I0b0dacd0d62bf00680f33866ce7ec0152eec27e0
    Reviewed-on: https://gerrit.libreoffice.org/36509
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Zdenek Crhonek <zcrhonek at gmail.com>

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index a7f74ba91bd3..5875a535be19 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -85,6 +85,17 @@ void VBATest::testMiscVBAFunctions()
         "instr.vb",
         "instrrev.vb",
         "int.vb",
+        "iserror.vb",
+        "ismissing.vb",
+        "isnull.vb",
+        "isobject.vb",
+        "join.vb",
+        "lbound.vb",
+        "isarray.vb",
+        "isdate.vb",
+        "isempty.vb",
+        "isnumeric.vb",
+        "lcase.vb",
 #ifndef WIN32 // missing 64bit Currency marshalling.
         "win32compat.vb", // windows compatibility hooks.
 #endif
diff --git a/basic/qa/vba_tests/isarray.vb b/basic/qa/vba_tests/isarray.vb
new file mode 100644
index 000000000000..3b88db20dca5
--- /dev/null
+++ b/basic/qa/vba_tests/isarray.vb
@@ -0,0 +1,72 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsArray()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsArray() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    Dim MyArray(1 To 5) As Integer, YourArray    ' Declare array variables.
+    testName = "Test IsArray function"
+    On Error GoTo errorHandler
+    YourArray = Array(1, 2, 3)    ' Use Array function.
+
+    date2 = True
+    date1 = IsArray(MyArray)
+    TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+
+    date2 = True
+    date1 = IsArray(YourArray)
+    TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+
+    date2 = False
+    date1 = IsArray(date2)
+    TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsArray = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/isdate.vb b/basic/qa/vba_tests/isdate.vb
new file mode 100644
index 000000000000..e6f446c01474
--- /dev/null
+++ b/basic/qa/vba_tests/isdate.vb
@@ -0,0 +1,70 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsDate()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsDate() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    testName = "Test IsDate function"
+    On Error GoTo errorHandler
+
+    date2 = True
+    date1 = IsDate(cdate("12/2/1969"))
+    TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+
+    date2 = True
+    date1 = IsDate("12:22:12")
+    TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+
+    date2 = False
+    date1 = IsDate("a12.2.1969")
+    TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsDate = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/isempty.vb b/basic/qa/vba_tests/isempty.vb
new file mode 100644
index 000000000000..d43edd5ffae4
--- /dev/null
+++ b/basic/qa/vba_tests/isempty.vb
@@ -0,0 +1,72 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsEmpty()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsEmpty() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2, MyVar
+    testName = "Test IsEmpty function"
+    On Error GoTo errorHandler
+
+    date2 = True
+    date1 = IsEmpty(MyVar)
+    TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+
+    MyVar = Null    ' Assign Null.
+    date2 = False
+    date1 = IsEmpty(MyVar)
+    TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+
+    MyVar = Empty    ' Assign Empty.
+    date2 = True
+    date1 = IsEmpty(MyVar)
+    TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsEmpty = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/iserror.vb b/basic/qa/vba_tests/iserror.vb
new file mode 100644
index 000000000000..36cb7ac0e173
--- /dev/null
+++ b/basic/qa/vba_tests/iserror.vb
@@ -0,0 +1,66 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsError()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsError() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    testName = "Test IsError function"
+    On Error GoTo errorHandler
+
+    date2 = False
+    date1 = IsError("12.2.1969")
+    TestLog_ASSERT date1 = date2, "the return IsError is: " & date1
+    
+    date2 = True
+    date1 = IsError(CVErr(64))
+    TestLog_ASSERT date1 = date2, "the return IsError is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsError = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/ismissing.vb b/basic/qa/vba_tests/ismissing.vb
new file mode 100644
index 000000000000..36d2f746f985
--- /dev/null
+++ b/basic/qa/vba_tests/ismissing.vb
@@ -0,0 +1,75 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsMissing()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsMissing() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    testName = "Test IsMissing function"
+    On Error GoTo errorHandler
+
+    date2 = Null
+    date1 = ReturnTwice()
+    TestLog_ASSERT IsNull(date1), "the return IsMissing is: " & date1
+
+    date2 = 4
+    date1 = ReturnTwice(2)
+    TestLog_ASSERT date1 = date2, "the return IsMissing is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsMissing = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+' Function procedure definition.
+Function ReturnTwice(Optional A)
+    If IsMissing(A) Then
+        ' If argument is missing, return a Null.
+        ReturnTwice = Null
+    Else
+        ' If argument is present, return twice the value.
+        ReturnTwice = A * 2
+    End If
+End Function
diff --git a/basic/qa/vba_tests/isnull.vb b/basic/qa/vba_tests/isnull.vb
new file mode 100644
index 000000000000..970730b4c486
--- /dev/null
+++ b/basic/qa/vba_tests/isnull.vb
@@ -0,0 +1,66 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsNull()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsNull() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    testName = "Test IsNull function"
+    On Error GoTo errorHandler
+
+    date2 = True
+    date1 = IsNull(Null)
+    TestLog_ASSERT date1 = date2, "the return IsNull is: " & date1
+
+    date2 = False
+    date1 = IsNull("")
+    TestLog_ASSERT date1 = date2, "the return IsNull is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsNull = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb
new file mode 100644
index 000000000000..a72f56f851ea
--- /dev/null
+++ b/basic/qa/vba_tests/isnumeric.vb
@@ -0,0 +1,82 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsNumeric()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsNumeric() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    testName = "Test IsNumeric function"
+    On Error GoTo errorHandler
+
+    date2 = True
+    date1 = IsNumeric(123)
+    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+    date2 = True
+    date1 = IsNumeric(-123)
+    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+    date2 = True
+    date1 = IsNumeric(123.8)
+    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+    date2 = False
+    date1 = IsNumeric("a")
+    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+rem    date2 = True
+rem    date1 = IsNumeric(True)
+rem    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+    date2 = True
+    date1 = IsNumeric("123")
+    TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsNumeric = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/isobject.vb b/basic/qa/vba_tests/isobject.vb
new file mode 100644
index 000000000000..030fea1b4e02
--- /dev/null
+++ b/basic/qa/vba_tests/isobject.vb
@@ -0,0 +1,68 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsObject()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testIsObject() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim MyObject As Object
+    Dim date1, date2, YourObject
+    testName = "Test IsObject function"
+    On Error GoTo errorHandler
+
+    Set YourObject = MyObject    ' Assign an object reference.
+    date2 = True
+    date1 = IsObject(YourObject)
+    TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
+
+    date2 = False
+    date1 = IsObject(TestStr)
+    TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testIsObject = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/join.vb b/basic/qa/vba_tests/join.vb
new file mode 100644
index 000000000000..5b56c1b12162
--- /dev/null
+++ b/basic/qa/vba_tests/join.vb
@@ -0,0 +1,78 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testJoin()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testJoin() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    Dim vaArray() As String
+    testName = "Test Join function"
+    On Error GoTo errorHandler
+    vaArray(0) = "string1"
+    vaArray(1) = "string2"
+    vaArray(2) = "string3"
+
+    date2 = "string1 string2 string3"
+    date1 = Join(vaArray)
+    TestLog_ASSERT date1 = date2, "the return Join is: " & date1
+
+    date2 = "string1 string2 string3"
+    date1 = Join(vaArray, " ")
+    TestLog_ASSERT date1 = date2, "the return Join is: " & date1
+
+    date2 = "string1<>string2<>string3"
+    date1 = Join(vaArray, "<>")
+    TestLog_ASSERT date1 = date2, "the return Join is: " & date1
+
+    date2 = "string1string2string3"
+    date1 = Join(vaArray, "")
+    TestLog_ASSERT date1 = date2, "the return Join is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testJoin = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/lbound.vb b/basic/qa/vba_tests/lbound.vb
new file mode 100644
index 000000000000..efe2a01cb03b
--- /dev/null
+++ b/basic/qa/vba_tests/lbound.vb
@@ -0,0 +1,68 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testLBound()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testLBound() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2
+    Dim MyArray(1 To 10, 5 To 15, 10 To 20)     ' Declare array variables.
+    testName = "Test LBound function"
+    On Error GoTo errorHandler
+
+    date2 = 1
+    date1 = LBound(MyArray, 1)
+    TestLog_ASSERT date1 = date2, "the return LBound is: " & date1
+
+    date2 = 10
+    date1 = LBound(MyArray, 3)
+    TestLog_ASSERT date1 = date2, "the return LBound is: " & date1
+
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testLBound = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+
diff --git a/basic/qa/vba_tests/lcase.vb b/basic/qa/vba_tests/lcase.vb
new file mode 100644
index 000000000000..17b2754a2799
--- /dev/null
+++ b/basic/qa/vba_tests/lcase.vb
@@ -0,0 +1,75 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testLCase()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testLCase() As String
+
+    passCount = 0
+    failCount = 0
+
+    result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+
+    Dim testName As String
+    Dim TestDateTime As Date
+    Dim TestStr As String
+    Dim date1, date2 As Date   'variables for test
+    testName = "Test LCase function"
+    On Error GoTo errorHandler
+
+    date2 = "lowercase"
+    date1 = LCase("LOWERCASE")
+    TestLog_ASSERT date1 = date2, "the return LCase is: " & date1
+
+    date2 = "lowercase"
+    date1 = LCase("LowerCase")
+    TestLog_ASSERT date1 = date2, "the return LCase is: " & date1
+
+    date2 = "lowercase"
+    date1 = LCase("lowercase")
+    TestLog_ASSERT date1 = date2, "the return LCase is: " & date1
+
+    date2 = "lowercase"
+    date1 = LCase("LOWER CASE")
+    TestLog_ASSERT date1 = date2, "the return LCase is: " & date1
+
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testLCase = result
+
+    Exit Function
+errorHandler:
+        TestLog_ASSERT (False), testName & ": hit error handler"
+End Function
+
+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 & Chr$(10) & " Failed: " & testMsg
+        failCount = failCount + 1
+    End If
+
+End Sub
+


More information about the Libreoffice-commits mailing list