Kaydet (Commit) baaf6c12 authored tarafından Zdeněk Crhonek's avatar Zdeněk Crhonek Kaydeden (comit) Zdenek Crhonek

VB tests (3)-don't pass whe all tests fail

Change-Id: I7dd99a43a3d41c8ca31a070028a19bd032d06435
Reviewed-on: https://gerrit.libreoffice.org/45739Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarZdenek Crhonek <zcrhonek@gmail.com>
üst 8f3f6755
......@@ -109,24 +109,16 @@ void VBATest::testMiscVBAFunctions()
"ltrim.vb",
"mid.vb",
"minute.vb",
"mirr.vb",
"month.vb",
"monthname.vb",
"oct.vb",
"nper.vb",
"npv.vb",
"pmt.vb",
"ppmt.vb",
"pv.vb",
"qbcolor.vb",
"rate.vb",
"rgb.vb",
"rtrim.vb",
"right.vb",
"second.vb",
"sgn.vb",
"sin.vb",
"sln.vb",
"space.vb",
"sqr.vb",
"str.vb",
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testLog()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testMIRR()
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testMIRR() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2, LoanAPR, InvAPR, Fmt, RetRate, Msg
testName = "Test MIRR function"
On Error GoTo errorHandler
Static Values(5) As Double ' Set up array.
LoanAPR = 0.1 ' Loan rate.
InvAPR = 0.12 ' Reinvestment rate.
Values(0) = -70000 ' Business start-up costs.
Values(1) = 22000: Values(2) = 25000
Values(3) = 28000: Values(4) = 31000
date2 = 0.148
date1 = MIRR(Values(), LoanAPR, InvAPR)
TestLog_ASSERT Round(date1, 3) = Round(date2, 3), "the return MIRR is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testMIRR = 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
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testMonthName()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testNPer
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testNPer() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2
testName = "Test NPER function"
On Error GoTo errorHandler
date2 = -4.359
date1 = NPer(0.0821, 400, 2000)
TestLog_ASSERT Round(date1, 3) = Round(date2, 3), "the return NPer is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testNPer = 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
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testNPV()
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testNPV() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2
testName = "Test NPV function"
On Error GoTo errorHandler
Static Values(5) As Double ' Set up array.
Values(0) = -70000 ' Business start-up costs.
' Positive cash flows reflecting income for four successive years.
Values(1) = 22000: Values(2) = 25000
Values(3) = 28000: Values(4) = 31000
date2 = 19312.57
date1 = NPV(0.0625, Values()) ' Calculate net present value.
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return NPV is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testNPV = 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
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testPMT()
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testPMT() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2
testName = "Test PMT function"
On Error GoTo errorHandler
date2 = -255.14
date1 = Pmt(0.0083, 48, 10000, 100, 0)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PMT is: " & date1
date2 = -253.04
date1 = Pmt(0.0083, 48, 10000, 100, 1)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PMT is: " & date1
date2 = -253.43
date1 = Pmt(0.0083, 48, 10000)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PMT is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testPMT = 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
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testPPMT()
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testPPMT() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2
testName = "Test PPMT function"
On Error GoTo errorHandler
date2 = -188.52
date1 = PPmt(0.0083, 12, 48, 10000, 100, 0)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PPMT is: " & date1
date2 = -186.97
date1 = PPmt(0.0083, 12, 48, 10000, 100, 1)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PPMT is: " & date1
date2 = -186.66
date1 = PPmt(0.0083, 12, 48, 10000)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PPMT is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testPPMT = 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
Option VBASupport 1
Option Explicit
Dim passCount As Integer
Dim failCount As Integer
Dim result As String
Function doUnitTest() As String
result = verify_testPV()
If failCount <> 0 And passCount > 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
End If
End Function
Function verify_testPV() As String
passCount = 0
failCount = 0
result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String
Dim date1, date2
testName = "Test PV function"
On Error GoTo errorHandler
date2 = -394647.64
date1 = PV(0.0083, 48, 10000, 100, 0)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PV is: " & date1
date2 = -397922.66
date1 = PV(0.0083, 48, 10000, 100, 1)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PV is: " & date1
date2 = -394580.39
date1 = PV(0.0083, 48, 10000)
TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return PV is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testPV = 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
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testQBcolor()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......
......@@ -7,7 +7,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testRATE()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......
......@@ -7,7 +7,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testRGB()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testRight()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......@@ -23,8 +23,6 @@ Function verify_testRight() As String
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
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testRTrim()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......@@ -23,8 +23,6 @@ Function verify_testRTrim() As String
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
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testSecond()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......@@ -23,8 +23,6 @@ Function verify_testSecond() As String
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
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_SGN()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......@@ -23,30 +23,28 @@ Function verify_SGN() As String
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)
date1 = sgn(0)
TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
date2 = -1
date1 = DateValue(-1)
date1 = sgn(-1)
TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
date2 = 1
date1 = DateValue(1)
date1 = sgn(1)
TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
date2 = 1
date1 = DateValue(50)
date1 = sgn(50)
TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
date2 = -1
date1 = DateValue(-50)
date1 = sgn(-50)
TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
......
......@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String
result = verify_testSIN()
If failCount <> 0 And passCount > 0 Then
If failCount <> 0 or passCount = 0 Then
doUnitTest = result
Else
doUnitTest = "OK"
......@@ -23,8 +23,6 @@ Function verify_testSIN() As String
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
......
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment