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

Zdeněk Crhonek zcrhonek at gmail.com
Tue Aug 8 17:36:42 UTC 2017


 basic/qa/cppunit/test_vba.cxx    |    7 ++
 basic/qa/vba_tests/syd.vb        |   62 ++++++++++++++++++++++++++
 basic/qa/vba_tests/timeserial.vb |   70 +++++++++++++++++++++++++++++
 basic/qa/vba_tests/timevalue.vb  |   60 +++++++++++++++++++++++++
 basic/qa/vba_tests/trim.vb       |   62 ++++++++++++++++++++++++++
 basic/qa/vba_tests/typename.vb   |   92 +++++++++++++++++++++++++++++++++++++++
 basic/qa/vba_tests/ubound.vb     |   71 ++++++++++++++++++++++++++++++
 basic/qa/vba_tests/ucase.vb      |   62 ++++++++++++++++++++++++++
 8 files changed, 486 insertions(+)

New commits:
commit 57ece564ac90ee13dd0193e2c29a602a64ec8ff1
Author: Zdeněk Crhonek <zcrhonek at gmail.com>
Date:   Tue Aug 8 18:43:49 2017 +0200

    VBA functions tests-SYD, TIMESERIAL, TIMEVALUE, TRIM, TYPENAME, UBOUND,UCASE
    
    Change-Id: I7ea7757291d996375584ef05d822701737020b1c
    Reviewed-on: https://gerrit.libreoffice.org/40894
    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 ff6e26db415c..9ba9521036a5 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -130,6 +130,13 @@ void VBATest::testMiscVBAFunctions()
         "string.vb",
         "strreverse.vb",
         "switch.vb",
+        "syd.vb",
+        "timeserial.vb",
+        "timevalue.vb",
+        "trim.vb",
+        "typename.vb",
+        "ubound.vb",
+        "ucase.vb",
 #ifndef WIN32 // missing 64bit Currency marshalling.
         "win32compat.vb", // windows compatibility hooks.
 #endif
diff --git a/basic/qa/vba_tests/syd.vb b/basic/qa/vba_tests/syd.vb
new file mode 100644
index 000000000000..8fb164feb5d6
--- /dev/null
+++ b/basic/qa/vba_tests/syd.vb
@@ -0,0 +1,62 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testSYD()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testSYD() 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 SYD function"
+    On Error GoTo errorHandler
+
+    date2 = 411.67
+    date1 = SYD(10000, 500, 24, 12)
+    TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return SYD is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testSYD = 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/timeserial.vb b/basic/qa/vba_tests/timeserial.vb
new file mode 100644
index 000000000000..f338f986e2df
--- /dev/null
+++ b/basic/qa/vba_tests/timeserial.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_testTimeSerial()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testTimeSerial() 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
+    testName = "Test TimeSerial function"
+    On Error GoTo errorHandler
+
+    date2 = "5:45:00"
+    date1 = (TimeSerial(12 - 6, -15, 0))
+    TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+
+    date2 = "12:30:00"
+    date1 = TimeSerial(12, 30, 0)
+    TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+
+    date2 = "11:30:00"
+    date1 = TimeSerial(10, 90, 0)
+    TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testTimeSerial = 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/timevalue.vb b/basic/qa/vba_tests/timevalue.vb
new file mode 100644
index 000000000000..cac5ed01cb09
--- /dev/null
+++ b/basic/qa/vba_tests/timevalue.vb
@@ -0,0 +1,60 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testTimeValue()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+Function verify_testTimeValue() 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 TimeValue function"
+    On Error GoTo errorHandler
+
+    date2 = "16:35:17"
+    date1 = TimeValue("4:35:17 PM")
+    TestLog_ASSERT date1 = date2, "the return TimeValue is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testTimeValue = 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/trim.vb b/basic/qa/vba_tests/trim.vb
new file mode 100644
index 000000000000..2a1c4b09b7a9
--- /dev/null
+++ b/basic/qa/vba_tests/trim.vb
@@ -0,0 +1,62 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testTrim()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testTrim() 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 Trim function"
+    On Error GoTo errorHandler
+
+    date2 = "some text"
+    date1 = Trim("   some text  ")
+    TestLog_ASSERT date1 = date2, "the return Trim is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testTrim = 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/typename.vb b/basic/qa/vba_tests/typename.vb
new file mode 100644
index 000000000000..33d72e462c4e
--- /dev/null
+++ b/basic/qa/vba_tests/typename.vb
@@ -0,0 +1,92 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testTypeName()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testTypeName() 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 TypeName function"
+    On Error GoTo errorHandler
+    Dim b1 As Boolean
+    Dim c1 As Byte
+    Dim d1 As Date
+    Dim d2 As Double
+    Dim i1 As Integer
+    Dim l1 As Long
+
+    date2 = "String"
+    date1 = TypeName(testName)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Boolean"
+    date1 = TypeName(b1)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Byte"
+    date1 = TypeName(c1)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Date"
+    date1 = TypeName(d1)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Double"
+    date1 = TypeName(d2)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Integer"
+    date1 = TypeName(i1)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    date2 = "Long"
+    date1 = TypeName(l1)
+    TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testTypeName = 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/ubound.vb b/basic/qa/vba_tests/ubound.vb
new file mode 100644
index 000000000000..609070775428
--- /dev/null
+++ b/basic/qa/vba_tests/ubound.vb
@@ -0,0 +1,71 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testUBound()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testUBound() 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 UBound function"
+    On Error GoTo errorHandler
+    Dim A(1 To 100, 0 To 3, -3 To 4)
+
+    date2 = 100
+    date1 = UBound(A, 1)
+    TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+
+    date2 = 3
+    date1 = UBound(A, 2)
+    TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+
+    date2 = 4
+    date1 = UBound(A, 3)
+    TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testUBound = 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/ucase.vb b/basic/qa/vba_tests/ucase.vb
new file mode 100644
index 000000000000..11f366aa572a
--- /dev/null
+++ b/basic/qa/vba_tests/ucase.vb
@@ -0,0 +1,62 @@
+Option VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testUCase()
+If failCount <> 0 And passCount > 0 Then
+    doUnitTest = result
+Else
+    doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testUCase() 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 UCase function"
+    On Error GoTo errorHandler
+
+    date2 = "HELLO 12"
+    date1 = UCase("hello 12") '2/12/1969
+    TestLog_ASSERT date1 = date2, "the return UCase is: " & date1
+
+    result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+    verify_testUCase = 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