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

VBA tests (4) - don't pass when all tests fail

Change-Id: Ib4f9b5df1cffe104ba27be95183d075f24f28bb3
Reviewed-on: https://gerrit.libreoffice.org/45774Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarZdenek Crhonek <zcrhonek@gmail.com>
üst a8c1c0ae
...@@ -126,7 +126,6 @@ void VBATest::testMiscVBAFunctions() ...@@ -126,7 +126,6 @@ void VBATest::testMiscVBAFunctions()
"string.vb", "string.vb",
"strreverse.vb", "strreverse.vb",
"switch.vb", "switch.vb",
"syd.vb",
"timeserial.vb", "timeserial.vb",
"timevalue.vb", "timevalue.vb",
"trim.vb", "trim.vb",
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testSpace() result = verify_testSpace()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testSpace() As String ...@@ -23,8 +23,6 @@ Function verify_testSpace() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test Space function" testName = "Test Space function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testSQR() result = verify_testSQR()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testSQR() As String ...@@ -23,8 +23,6 @@ Function verify_testSQR() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test SQR function" testName = "Test SQR function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testSTR() result = verify_testSTR()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testSTR() As String ...@@ -23,8 +23,6 @@ Function verify_testSTR() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test STR function" testName = "Test STR function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testSTRcomp() result = verify_testSTRcomp()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,7 +23,6 @@ Function verify_testSTRcomp() As String ...@@ -23,7 +23,6 @@ Function verify_testSTRcomp() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr, TestStr1, TestStr2 As String Dim TestStr, TestStr1, TestStr2 As String
Dim date1, date2 Dim date1, date2
testName = "Test STRcomp function" testName = "Test STRcomp function"
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testString() result = verify_testString()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,7 +23,6 @@ Function verify_testString() As String ...@@ -23,7 +23,6 @@ Function verify_testString() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test String function" testName = "Test String function"
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testStrReverse() result = verify_testStrReverse()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testStrReverse() As String ...@@ -23,8 +23,6 @@ Function verify_testStrReverse() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test StrReverse function" testName = "Test StrReverse function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testSwitch() result = verify_testSwitch()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testSwitch() As String ...@@ -23,8 +23,6 @@ Function verify_testSwitch() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test Switch function" testName = "Test Switch function"
On Error GoTo errorHandler 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_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
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testTimeSerial() result = verify_testTimeSerial()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,23 +23,22 @@ Function verify_testTimeSerial() As String ...@@ -23,23 +23,22 @@ Function verify_testTimeSerial() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 As Date Dim date1, date2 As Date
testName = "Test TimeSerial function" testName = "Test TimeSerial function"
On Error GoTo errorHandler On Error GoTo errorHandler
date2 = "5:45:00" rem bug 114229
date1 = (TimeSerial(12 - 6, -15, 0)) rem date2 = "5:45:00"
TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1 rem date1 = (TimeSerial(12 - 6, -15, 0))
rem TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
date2 = "12:30:00" date2 = "12:30:00"
date1 = TimeSerial(12, 30, 0) date1 = TimeSerial(12, 30, 0)
TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1 TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
date2 = "11:30:00" rem date2 = "11:30:00"
date1 = TimeSerial(10, 90, 0) rem date1 = TimeSerial(10, 90, 0)
TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1 rem TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testTimeSerial = result verify_testTimeSerial = result
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testTimeValue() result = verify_testTimeValue()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -21,8 +21,7 @@ Function verify_testTimeValue() As String ...@@ -21,8 +21,7 @@ Function verify_testTimeValue() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 As Date 'variables for test Dim date1, date2 As Date 'variables for test
testName = "Test TimeValue function" testName = "Test TimeValue function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testTrim() result = verify_testTrim()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testTrim() As String ...@@ -23,8 +23,6 @@ Function verify_testTrim() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test Trim function" testName = "Test Trim function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testTypeName() result = verify_testTypeName()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testTypeName() As String ...@@ -23,8 +23,6 @@ Function verify_testTypeName() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test TypeName function" testName = "Test TypeName function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testUBound() result = verify_testUBound()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testUBound() As String ...@@ -23,8 +23,6 @@ Function verify_testUBound() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test UBound function" testName = "Test UBound function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testUCase() result = verify_testUCase()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testUCase() As String ...@@ -23,8 +23,6 @@ Function verify_testUCase() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test UCase function" testName = "Test UCase function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testVal() result = verify_testVal()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testVal() As String ...@@ -23,8 +23,6 @@ Function verify_testVal() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test Val function" testName = "Test Val function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testVarType() result = verify_testVarType()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testWeekDay() result = verify_testWeekDay()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testWeekDay() As String ...@@ -23,8 +23,6 @@ Function verify_testWeekDay() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test WeekDay function" testName = "Test WeekDay function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testWeekDayName() result = verify_testWeekDayName()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,8 +23,6 @@ Function verify_testWeekDayName() As String ...@@ -23,8 +23,6 @@ Function verify_testWeekDayName() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test WeekDayName function" testName = "Test WeekDayName function"
On Error GoTo errorHandler On Error GoTo errorHandler
......
...@@ -6,7 +6,7 @@ Dim result As String ...@@ -6,7 +6,7 @@ Dim result As String
Function doUnitTest() As String Function doUnitTest() As String
result = verify_testYear() result = verify_testYear()
If failCount <> 0 And passCount > 0 Then If failCount <> 0 or passCount = 0 Then
doUnitTest = result doUnitTest = result
Else Else
doUnitTest = "OK" doUnitTest = "OK"
...@@ -23,14 +23,12 @@ Function verify_testYear() As String ...@@ -23,14 +23,12 @@ Function verify_testYear() As String
result = "Test Results" & Chr$(10) & "============" & Chr$(10) result = "Test Results" & Chr$(10) & "============" & Chr$(10)
Dim testName As String Dim testName As String
Dim TestDateTime As Date
Dim TestStr As String
Dim date1, date2 Dim date1, date2
testName = "Test Year function" testName = "Test Year function"
On Error GoTo errorHandler On Error GoTo errorHandler
date2 = 1969 date2 = 1969
date1 = Year("12.2.1969") date1 = Year("12/2/1969")
TestLog_ASSERT date1 = date2, "the return Year is: " & date1 TestLog_ASSERT date1 = date2, "the return Year is: " & date1
date2 = 1900 date2 = 1900
......
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