/sd/xsl/

nlong.cn:88/cgit/lo/core/atom/?h=master' type='application/atom+xml'/>
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdeněk Crhonek <zcrhonek@gmail.com>2017-08-08 18:43:49 +0200
committerZdenek Crhonek <zcrhonek@gmail.com>2017-08-08 19:36:00 +0200
commit57ece564ac90ee13dd0193e2c29a602a64ec8ff1 (patch)
tree0cde6bf618f8b3be8d4b6e7404afe6b35b2b5a72
parent3b66be90d4fffed9cbe61ba99b4ad94daa04f68c (diff)
VBA functions tests-SYD, TIMESERIAL, TIMEVALUE, TRIM, TYPENAME, UBOUND,UCASE
Change-Id: I7ea7757291d996375584ef05d822701737020b1c Reviewed-on: https://gerrit.libreoffice.org/40894 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Zdenek Crhonek <zcrhonek@gmail.com>
-rw-r--r--basic/qa/cppunit/test_vba.cxx7
-rw-r--r--basic/qa/vba_tests/syd.vb62
-rw-r--r--basic/qa/vba_tests/timeserial.vb70
-rw-r--r--basic/qa/vba_tests/timevalue.vb60
-rw-r--r--basic/qa/vba_tests/trim.vb62
-rw-r--r--basic/qa/vba_tests/typename.vb92
-rw-r--r--basic/qa/vba_tests/ubound.vb71
-rw-r--r--basic/qa/vba_tests/ucase.vb62
8 files changed, 486 insertions, 0 deletions
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