[Libreoffice-commits] core.git: basic/qa
Zdeněk Crhonek
zcrhonek at gmail.com
Sun Apr 2 11:03:01 UTC 2017
basic/qa/cppunit/test_vba.cxx | 4 ++
basic/qa/vba_tests/day.vb | 62 +++++++++++++++++++++++++++++++++++++
basic/qa/vba_tests/error.vb | 62 +++++++++++++++++++++++++++++++++++++
basic/qa/vba_tests/exp.vb | 62 +++++++++++++++++++++++++++++++++++++
basic/qa/vba_tests/fix.vb | 70 ++++++++++++++++++++++++++++++++++++++++++
5 files changed, 260 insertions(+)
New commits:
commit d9dc5dcd39740e82034823bb3a5c50ae56be6af8
Author: Zdeněk Crhonek <zcrhonek at gmail.com>
Date: Sat Apr 1 17:45:15 2017 +0200
add VBA tests- FIX,EXP,ERROR,DAY functions
Change-Id: I339abf03f88a0b8135184a892f5200ad381310bd
Reviewed-on: https://gerrit.libreoffice.org/36010
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 1f113cf79c86..8e5a5ecc4f8d 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -74,6 +74,10 @@ void VBATest::testMiscVBAFunctions()
"dateadd.vb",
"datediff.vb",
"datepart.vb",
+ "day.vb",
+ "error.vb",
+ "exp.vb",
+ "fix.vb",
#ifndef WIN32 // missing 64bit Currency marshalling.
"win32compat.vb", // windows compatibility hooks.
#endif
diff --git a/basic/qa/vba_tests/day.vb b/basic/qa/vba_tests/day.vb
new file mode 100644
index 000000000000..408d7b81d9e1
--- /dev/null
+++ b/basic/qa/vba_tests/day.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_testday()
+If failCount <> 0 And passCount > 0 Then
+ doUnitTest = result
+Else
+ doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testday() 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 'variables for test
+ testName = "Test day function"
+ On Error GoTo errorHandler
+
+ date2 = 12
+ date1 = Day("12.2.1969") '2/12/1969
+ TestLog_ASSERT date1 = date2, "the return day is: " & date1
+
+ result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ verify_testday = 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/error.vb b/basic/qa/vba_tests/error.vb
new file mode 100644
index 000000000000..8787c891c824
--- /dev/null
+++ b/basic/qa/vba_tests/error.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_testError()
+If failCount <> 0 And passCount > 0 Then
+ doUnitTest = result
+Else
+ doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testError() 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 Error function"
+ On Error GoTo errorHandler
+
+ date2 = Error(62) 'https://help.libreoffice.org/3.3/Basic/Error_Function_Runtime
+ date1 = "Input past end of file"
+ TestLog_ASSERT date1 = date2, "the return Error is: " & date1
+
+ result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ verify_testError = 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/exp.vb b/basic/qa/vba_tests/exp.vb
new file mode 100644
index 000000000000..7de010ae911b
--- /dev/null
+++ b/basic/qa/vba_tests/exp.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_testExp()
+If failCount <> 0 And passCount > 0 Then
+ doUnitTest = result
+Else
+ doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testExp() 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 Exp function"
+ On Error GoTo errorHandler
+
+ date2 = 2.7183
+ date1 = Exp(1)
+ TestLog_ASSERT Round(date1, 4) = Round(date2, 4), "the return Exp is: " & date1
+
+ result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ verify_testExp = 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/fix.vb b/basic/qa/vba_tests/fix.vb
new file mode 100644
index 000000000000..edb301b7c4c0
--- /dev/null
+++ b/basic/qa/vba_tests/fix.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_testFix()
+If failCount <> 0 And passCount > 0 Then
+ doUnitTest = result
+Else
+ doUnitTest = "OK"
+End If
+End Function
+
+
+
+Function verify_testFix() 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 Fix function"
+ On Error GoTo errorHandler
+
+ date2 = 12
+ date1 = Fix(12.34)
+ TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+
+ date2 = 12
+ date1 = Fix(12.99)
+ TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+
+ date2 = -8
+ date1 = Fix(-8.4)
+ TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+
+ result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ verify_testFix = 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