basic/qa/cppunit/test_vba.cxx | 8 ++++ basic/qa/vba_tests/right.vb | 70 +++++++++++++++++++++++++++++++++++++ basic/qa/vba_tests/rtrim.vb | 62 +++++++++++++++++++++++++++++++++ basic/qa/vba_tests/second.vb | 66 +++++++++++++++++++++++++++++++++++ basic/qa/vba_tests/sgn.vb | 78 ++++++++++++++++++++++++++++++++++++++++++ basic/qa/vba_tests/sin.vb | 62 +++++++++++++++++++++++++++++++++ basic/qa/vba_tests/sln.vb | 62 +++++++++++++++++++++++++++++++++ basic/qa/vba_tests/space.vb | 62 +++++++++++++++++++++++++++++++++ basic/qa/vba_tests/sqr.vb | 62 +++++++++++++++++++++++++++++++++ 9 files changed, 532 insertions(+)
New commits: commit fae4b84882adac35d7cc170cef555bd0b41bb3df Author: ZdenÄk Crhonek <zcrho...@gmail.com> Date: Sun Jul 23 21:39:33 2017 +0200 VBA tests-functions RIGHT,RTRIM,SECOND,SGN,SIN,SLN,SPACE,SQR Change-Id: I0db9233f20fccbc4b2c4f4b3e36cf0aaa8583c99 Reviewed-on: https://gerrit.libreoffice.org/40339 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Zdenek Crhonek <zcrho...@gmail.com> diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx index d4311c0c83b2..cad4c176713f 100644 --- a/basic/qa/cppunit/test_vba.cxx +++ b/basic/qa/cppunit/test_vba.cxx @@ -117,6 +117,14 @@ void VBATest::testMiscVBAFunctions() "qbcolor.vb", "rate.vb", "rgb.vb", + "rtrim.vb", + "right.vb", + "second.vb", + "sgn.vb", + "sin.vb", + "sln.vb", + "space.vb", + "sqr.vb", #ifndef WIN32 // missing 64bit Currency marshalling. "win32compat.vb", // windows compatibility hooks. #endif diff --git a/basic/qa/vba_tests/right.vb b/basic/qa/vba_tests/right.vb new file mode 100644 index 000000000000..d67523cd9358 --- /dev/null +++ b/basic/qa/vba_tests/right.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_testRight() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testRight() 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 Right function" + On Error GoTo errorHandler + + date2 = "text" + date1 = Right("sometext", 4) + TestLog_ASSERT date1 = date2, "the return Right is: " & date1 + + date2 = "sometext" + date1 = Right("sometext", 48) + TestLog_ASSERT date1 = date2, "the return Right is: " & date1 + + date2 = "" + date1 = Right("", 4) + TestLog_ASSERT date1 = date2, "the return Right is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testRight = 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/rtrim.vb b/basic/qa/vba_tests/rtrim.vb new file mode 100644 index 000000000000..0de1aea71b06 --- /dev/null +++ b/basic/qa/vba_tests/rtrim.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_testRTrim() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testRTrim() 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 RTrim function" + On Error GoTo errorHandler + + date2 = " some text" + date1 = RTrim(" some text ") + TestLog_ASSERT date1 = date2, "the return RTrim is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testRTrim = 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/second.vb b/basic/qa/vba_tests/second.vb new file mode 100644 index 000000000000..40e93ad1a6c3 --- /dev/null +++ b/basic/qa/vba_tests/second.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_testSecond() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testSecond() 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 Second function" + On Error GoTo errorHandler + + date2 = 0 + date1 = Second(37566.3) + TestLog_ASSERT date1 = date2, "the return Second is: " & date1 + + date2 = 17 + date1 = Second("4:35:17") + TestLog_ASSERT date1 = date2, "the return Second is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testSecond = 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/sgn.vb b/basic/qa/vba_tests/sgn.vb new file mode 100644 index 000000000000..c723e4153331 --- /dev/null +++ b/basic/qa/vba_tests/sgn.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_SGN() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_SGN() 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 SGN function" + On Error GoTo errorHandler + + date2 = 0 + date1 = DateValue(0) + TestLog_ASSERT date1 = date2, "the return SGN is: " & date1 + + date2 = -1 + date1 = DateValue(-1) + TestLog_ASSERT date1 = date2, "the return SGN is: " & date1 + + date2 = 1 + date1 = DateValue(1) + TestLog_ASSERT date1 = date2, "the return SGN is: " & date1 + + date2 = 1 + date1 = DateValue(50) + TestLog_ASSERT date1 = date2, "the return SGN is: " & date1 + + date2 = -1 + date1 = DateValue(-50) + TestLog_ASSERT date1 = date2, "the return SGN is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_SGN = 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/sin.vb b/basic/qa/vba_tests/sin.vb new file mode 100644 index 000000000000..a8f7c548343e --- /dev/null +++ b/basic/qa/vba_tests/sin.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_testSIN() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testSIN() 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 SIN function" + On Error GoTo errorHandler + + date2 = 0.43 + date1 = Sin(0.45) + TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return SIN is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testSIN = 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/sln.vb b/basic/qa/vba_tests/sln.vb new file mode 100644 index 000000000000..fcd4ad416d0f --- /dev/null +++ b/basic/qa/vba_tests/sln.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_testSLN() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testSLN() 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 SLN function" + On Error GoTo errorHandler + + date2 = 395.83 + date1 = SLN(10000, 500, 24) + TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return SLN is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testSLN = 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/space.vb b/basic/qa/vba_tests/space.vb new file mode 100644 index 000000000000..a49af12c997f --- /dev/null +++ b/basic/qa/vba_tests/space.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_testSpace() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testSpace() 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 Space function" + On Error GoTo errorHandler + + date2 = " " + date1 = Space(2) + TestLog_ASSERT date1 = date2, "the return Space is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testSpace = 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/sqr.vb b/basic/qa/vba_tests/sqr.vb new file mode 100644 index 000000000000..20005400b4f9 --- /dev/null +++ b/basic/qa/vba_tests/sqr.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_testSQR() +If failCount <> 0 And passCount > 0 Then + doUnitTest = result +Else + doUnitTest = "OK" +End If +End Function + + + +Function verify_testSQR() 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 SQR function" + On Error GoTo errorHandler + + date2 = 3 + date1 = Sqr(9) + TestLog_ASSERT date1 = date2, "the return SQR is: " & date1 + + result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + verify_testSQR = 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 +
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits