diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-07-01 18:23:08 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-07-02 17:50:10 +0200 |
commit | a6178d172ebc47c623b1c1435d4c2e24966fce56 (patch) | |
tree | c2474d58e8050dcb45d06d8f288cac6401ea4e5e /basic | |
parent | a43dac7964a889c8a0f01a38f0a9d178f4edb44d (diff) |
tdf#84098 kill copy+paste in basic/qa/basic_coverage
This also fix the problem of basic_coverage tests not showing
the results when they were failing, since doUnitTest
returned a Integer
Change-Id: I637cd4cfaa34047bc99bfe6e0930f2945f1a9315
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118234
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'basic')
145 files changed, 821 insertions, 980 deletions
diff --git a/basic/qa/basic_coverage/_test_asserts.vb b/basic/qa/basic_coverage/_test_asserts.vb new file mode 100644 index 000000000000..0ecbf6828bcd --- /dev/null +++ b/basic/qa/basic_coverage/_test_asserts.vb @@ -0,0 +1,57 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + +Option Explicit + +Dim passCount As Integer +Dim failCount As Integer +Dim result As String + +Function GetResult() + If passCount <> 0 and failCount = 0 Then + GetResult = "OK" + Else + GetResult = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) + End If +End Function + +Sub TestInit() + passCount = 0 + failCount = 0 + result = result & "Test Results" & Chr$(10) & "============" & Chr$(10) +End Sub + +Sub 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 = " " + 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 + +Sub AssertEqual(actual As Variant, expected As Variant, testName As String) + If expected = actual Then + passCount = passCount + 1 + Else + result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected + failCount = failCount + 1 + End If +End Sub + +Sub ReportErrorHandler(testName As String, aErr, sError, nErl) + Assert False, testName, "hit error handler - " & aErr & ": " & sError & " line : " & nErl +End Sub diff --git a/basic/qa/basic_coverage/da-DK/cdbl-2.vb b/basic/qa/basic_coverage/da-DK/cdbl-2.vb index a219304d4230..46468ac63f31 100644 --- a/basic/qa/basic_coverage/da-DK/cdbl-2.vb +++ b/basic/qa/basic_coverage/da-DK/cdbl-2.vb @@ -1,4 +1,4 @@ -Function doUnitTest() as Integer +Function doUnitTest() as String Dim A As String Dim B As Double Dim Expected As Double @@ -7,8 +7,8 @@ Function doUnitTest() as Integer Expected = 222.222 B = Cdbl(A) If B <> Expected Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/da-DK/cdbl.vb b/basic/qa/basic_coverage/da-DK/cdbl.vb index 128cfcc9903d..9b849d094724 100644 --- a/basic/qa/basic_coverage/da-DK/cdbl.vb +++ b/basic/qa/basic_coverage/da-DK/cdbl.vb @@ -1,4 +1,4 @@ -Function doUnitTest() as Integer +Function doUnitTest() as String Dim A As String Dim B As Double Dim Expected As String @@ -7,8 +7,8 @@ Function doUnitTest() as Integer Expected = "222222" B = Cdbl(A) If B <> Expected Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/string_left_01.vb b/basic/qa/basic_coverage/string_left_01.vb index ef896bef1009..a17522979d36 100644 --- a/basic/qa/basic_coverage/string_left_01.vb +++ b/basic/qa/basic_coverage/string_left_01.vb @@ -7,7 +7,7 @@ ' -Function doUnitTest as Integer +Function doUnitTest as String Dim s1 As String Dim s2 As String @@ -17,9 +17,9 @@ Dim s2 As String s2 = Left(s1, 2) If s2 = "ab" Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/string_right_01.vb b/basic/qa/basic_coverage/string_right_01.vb index 65b16c6a8762..9189b8846776 100644 --- a/basic/qa/basic_coverage/string_right_01.vb +++ b/basic/qa/basic_coverage/string_right_01.vb @@ -6,7 +6,7 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String Dim s1 As String Dim s2 As String @@ -16,9 +16,9 @@ Dim s2 As String s2 = Right(s1, 2) If s2 = "bc" Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_Date.vb b/basic/qa/basic_coverage/test_Date.vb index c21d8cc05910..3056040a41f0 100644 --- a/basic/qa/basic_coverage/test_Date.vb +++ b/basic/qa/basic_coverage/test_Date.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ''' Return 'text' OR 'date' variable ''' If ( TypeName(Date$)<>"String" Or Vartype(Date())<>V_DATE) Then - doUnitTest = 0 ' not successful + doUnitTest = "FAIL" ' not successful Else - doUnitTest = 1 ' Ok + doUnitTest = "OK" ' Ok End If End Function diff --git a/basic/qa/basic_coverage/test_Property.GetLet.vb b/basic/qa/basic_coverage/test_Property.GetLet.vb index 992496a21015..97e377cc3448 100644 --- a/basic/qa/basic_coverage/test_Property.GetLet.vb +++ b/basic/qa/basic_coverage/test_Property.GetLet.vb @@ -8,13 +8,13 @@ Option Compatible -Function doUnitTest as Integer +Function doUnitTest as String ' PROPERTY GET/LET aString = "Office" If ( aString <> "LibreOffice") Then - doUnitTest = 0 ' Ko + doUnitTest = "FAIL" ' Ko Else - doUnitTest = 1 ' Ok + doUnitTest = "OK" ' Ok End If End Function diff --git a/basic/qa/basic_coverage/test_Property.GetSet.vb b/basic/qa/basic_coverage/test_Property.GetSet.vb index 4a23867c2cfa..339ffe214227 100644 --- a/basic/qa/basic_coverage/test_Property.GetSet.vb +++ b/basic/qa/basic_coverage/test_Property.GetSet.vb @@ -8,14 +8,14 @@ Option Compatible -Function doUnitTest as Integer +Function doUnitTest as String ' PROPERTY GET/SET for classes or UNO services Set objSetter = New Collection ' OR objLetter = New Collection If ( objGetter.Count <> 3 ) Then - doUnitTest = 0 ' not Ok + doUnitTest = "FAIL" ' not Ok Else - doUnitTest = 1 ' Ok + doUnitTest = "OK" ' Ok End If End Function diff --git a/basic/qa/basic_coverage/test_abs_method.vb b/basic/qa/basic_coverage/test_abs_method.vb index b79b9bcbb562..fb1ed22af42a 100644 --- a/basic/qa/basic_coverage/test_abs_method.vb +++ b/basic/qa/basic_coverage/test_abs_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ABS If (Abs(-3.5) <> 3.5) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf (Abs(3.5) <> 3.5) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_array_method.vb b/basic/qa/basic_coverage/test_array_method.vb index 42f10a25ae8a..7d9c65522803 100644 --- a/basic/qa/basic_coverage/test_array_method.vb +++ b/basic/qa/basic_coverage/test_array_method.vb @@ -6,15 +6,15 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVector as Variant ' ARRAY aVector = Array( "Hello", -3.14) If (aVector(0) <> "Hello") Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( aVector(1) <> -3.14 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_asc_method.vb b/basic/qa/basic_coverage/test_asc_method.vb index 48b88933f9ac..982df81d1dc1 100644 --- a/basic/qa/basic_coverage/test_asc_method.vb +++ b/basic/qa/basic_coverage/test_asc_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ASC If (Asc("€a") <> 8364) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_atn_method.vb b/basic/qa/basic_coverage/test_atn_method.vb index 771714134fcc..08318eae007f 100644 --- a/basic/qa/basic_coverage/test_atn_method.vb +++ b/basic/qa/basic_coverage/test_atn_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ATN (arc tan) If (Atn(1) <> PI/4) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_beep_method.vb b/basic/qa/basic_coverage/test_beep_method.vb index 28eed61a6c1d..2952436df111 100644 --- a/basic/qa/basic_coverage/test_beep_method.vb +++ b/basic/qa/basic_coverage/test_beep_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' BEEP Beep - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_cbool_method.vb b/basic/qa/basic_coverage/test_cbool_method.vb index d1d995f19db3..11b88193896a 100644 --- a/basic/qa/basic_coverage/test_cbool_method.vb +++ b/basic/qa/basic_coverage/test_cbool_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CBOOL If (CBool(3) <> True) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cbyte_method.vb b/basic/qa/basic_coverage/test_cbyte_method.vb index 35bb1654c63e..bdcfd1f798cd 100644 --- a/basic/qa/basic_coverage/test_cbyte_method.vb +++ b/basic/qa/basic_coverage/test_cbyte_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CBYTE If (CByte("3") <> 3) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_ccur_method.vb b/basic/qa/basic_coverage/test_ccur_method.vb index e4eef652441f..da6688500a2e 100644 --- a/basic/qa/basic_coverage/test_ccur_method.vb +++ b/basic/qa/basic_coverage/test_ccur_method.vb @@ -6,9 +6,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" ' CCUR if (CCur("100") <> 100) Then Exit Function @@ -17,6 +17,6 @@ Function doUnitTest as Integer ' tdf#141050 - passing a number with - sign if (CCur("-100") <> -100) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_cdate_method.vb b/basic/qa/basic_coverage/test_cdate_method.vb index c26287b1f013..9f2e357b8f39 100644 --- a/basic/qa/basic_coverage/test_cdate_method.vb +++ b/basic/qa/basic_coverage/test_cdate_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CDATE If (CDate(100) <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cdatetofromiso_methods.vb b/basic/qa/basic_coverage/test_cdatetofromiso_methods.vb index d2f4ce9c7816..9d53cca3a3d5 100644 --- a/basic/qa/basic_coverage/test_cdatetofromiso_methods.vb +++ b/basic/qa/basic_coverage/test_cdatetofromiso_methods.vb @@ -6,36 +6,36 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CDateFromIso CDateToIso If ( CDateToIso( CDateFromIso("20161016") ) <> "20161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("2016-10-16") ) <> "20161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-2016-10-16") ) <> "-20161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-20161016") ) <> "-20161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("12016-10-16") ) <> "120161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("120161016") ) <> "120161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-12016-10-16") ) <> "-120161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-120161016") ) <> "-120161016" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("0001-01-01") ) <> "00010101" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("00010101") ) <> "00010101" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-0001-12-31") ) <> "-00011231" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("-00011231") ) <> "-00011231" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" ElseIf ( CDateToIso( CDateFromIso("991231") ) <> "19991231" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If ' TODO: add some failure tests for misformed input, On Error whatever? End Function diff --git a/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.vb b/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.vb index 2aa735c54d17..e5da681c837b 100644 --- a/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.vb +++ b/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' CDateToUnoDate CDateFromUnoDate If ( CDateFromUnoDate( CDateToUnoDate( aDate ) ) <> aDate ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.vb b/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.vb index 9aa5680b1f8c..82bbb49ddcff 100644 --- a/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.vb +++ b/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Now() ' CDateToUnoDateTime CDateFromUnoDateTime If ( CDateFromUnoDateTime( CDateToUnoDateTime( aDate ) ) <> aDate ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.vb b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.vb index 38fd9da45f47..b84ee48f2263 100644 --- a/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.vb +++ b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Time() ' CDateToUnoTime CDateFromUnoTime If ( CDateFromUnoTime( CDateToUnoTime( aDate ) ) <> aDate ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cdbl_method.vb b/basic/qa/basic_coverage/test_cdbl_method.vb index a0ba8f0298c8..bed575c07fbd 100644 --- a/basic/qa/basic_coverage/test_cdbl_method.vb +++ b/basic/qa/basic_coverage/test_cdbl_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CDBL If (CDbl("100") <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_chdircurdir_methods.vb b/basic/qa/basic_coverage/test_chdircurdir_methods.vb index dadd65b100e5..414ab60dd565 100644 --- a/basic/qa/basic_coverage/test_chdircurdir_methods.vb +++ b/basic/qa/basic_coverage/test_chdircurdir_methods.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CHDIR CURDIR ChDir( CurDir ) - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_choose_method.vb b/basic/qa/basic_coverage/test_choose_method.vb index 6ab2aea80f09..4f072f608f4e 100644 --- a/basic/qa/basic_coverage/test_choose_method.vb +++ b/basic/qa/basic_coverage/test_choose_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CHOOSE If (Choose(2, 1, 100, 3) <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_chr_method.vb b/basic/qa/basic_coverage/test_chr_method.vb index 8e8179463535..a927873f5322 100644 --- a/basic/qa/basic_coverage/test_chr_method.vb +++ b/basic/qa/basic_coverage/test_chr_method.vb @@ -43,22 +43,22 @@ handler: overflow3 = 1 End Function -Function doUnitTest as Integer +Function doUnitTest as String Chr(-32768) Chr(65535) Chr(&H8000) Chr(&HFFFF) if (overflow1 = 0) Then - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function Endif if (overflow2 = 0) Then - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function Endif if (overflow3 = 0) Then - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function Endif - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_cint_method.vb b/basic/qa/basic_coverage/test_cint_method.vb index b84af04d74fe..4f4692ca5752 100644 --- a/basic/qa/basic_coverage/test_cint_method.vb +++ b/basic/qa/basic_coverage/test_cint_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CINT If (CInt("100") <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_compatibilitymode_method.vb b/basic/qa/basic_coverage/test_compatibilitymode_method.vb index 599adb963f66..0a6adaae1284 100644 --- a/basic/qa/basic_coverage/test_compatibilitymode_method.vb +++ b/basic/qa/basic_coverage/test_compatibilitymode_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CompatibilityMode If (CompatibilityMode(True) <> True) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_converttofromurl_methods.vb b/basic/qa/basic_coverage/test_converttofromurl_methods.vb index 40c6494bd314..0bcaf4cac48f 100644 --- a/basic/qa/basic_coverage/test_converttofromurl_methods.vb +++ b/basic/qa/basic_coverage/test_converttofromurl_methods.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ConvertFromUrl ConvertToUrl If ( ConvertToUrl( ConvertFromUrl("") ) <> "") Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cossin_methods.vb b/basic/qa/basic_coverage/test_cossin_methods.vb index c4a5cc5e537b..3bbdd95f0fd4 100644 --- a/basic/qa/basic_coverage/test_cossin_methods.vb +++ b/basic/qa/basic_coverage/test_cossin_methods.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' COS SIN If ( Abs(Cos(PI/3) - Sin(PI/6)) > 1E-6 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_createobject_method.vb b/basic/qa/basic_coverage/test_createobject_method.vb index 6ae316b5795f..50fa536f9ad2 100644 --- a/basic/qa/basic_coverage/test_createobject_method.vb +++ b/basic/qa/basic_coverage/test_createobject_method.vb @@ -11,11 +11,11 @@ Type address City As String End Type -Function doUnitTest as Integer +Function doUnitTest as String ' CREATEOBJECT If ( IsObject( CreateObject("address") ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_createunolistener_method.vb b/basic/qa/basic_coverage/test_createunolistener_method.vb index 08c71fd8aaa0..dca9c9a1fc30 100644 --- a/basic/qa/basic_coverage/test_createunolistener_method.vb +++ b/basic/qa/basic_coverage/test_createunolistener_method.vb @@ -5,9 +5,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CreateUnoListener Dim oListener oListener = CreateUnoListener( "ContListener_","com.sun.star.container.XContainerListener" ) - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_createunoservice_method.vb b/basic/qa/basic_coverage/test_createunoservice_method.vb index 8fc043fd3e1d..90cc3affd993 100644 --- a/basic/qa/basic_coverage/test_createunoservice_method.vb +++ b/basic/qa/basic_coverage/test_createunoservice_method.vb @@ -5,9 +5,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CreateUnoService Dim filepicker filepicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_createunostruct_method.vb b/basic/qa/basic_coverage/test_createunostruct_method.vb index f08368fed219..e8eb72061b9c 100644 --- a/basic/qa/basic_coverage/test_createunostruct_method.vb +++ b/basic/qa/basic_coverage/test_createunostruct_method.vb @@ -5,9 +5,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CreateUnoStruct Dim oStruct oStruct = CreateUnoStruct( "com.sun.star.beans.Property" ) - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_createunovalue_method.vb b/basic/qa/basic_coverage/test_createunovalue_method.vb index e640354acba9..40268ef90639 100644 --- a/basic/qa/basic_coverage/test_createunovalue_method.vb +++ b/basic/qa/basic_coverage/test_createunovalue_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CreateUnoValue Dim oUnoValue as Variant Dim aValue as Variant aValue = Array ( 1, 1 ) oUnoValue = CreateUnoValue( "[]byte", aValue ) - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_csng_method.vb b/basic/qa/basic_coverage/test_csng_method.vb index 87704ec1d431..64ad3ce80196 100644 --- a/basic/qa/basic_coverage/test_csng_method.vb +++ b/basic/qa/basic_coverage/test_csng_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CSNG If (CSng("100") <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cstr_method.vb b/basic/qa/basic_coverage/test_cstr_method.vb index 53484b06fe17..d7f25a3887b4 100644 --- a/basic/qa/basic_coverage/test_cstr_method.vb +++ b/basic/qa/basic_coverage/test_cstr_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CSTR If (CStr(100) <> "100") Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cvar_method.vb b/basic/qa/basic_coverage/test_cvar_method.vb index cc13bef6c8f9..65dd8292574b 100644 --- a/basic/qa/basic_coverage/test_cvar_method.vb +++ b/basic/qa/basic_coverage/test_cvar_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' CVAR If (CVar(100) <> 100) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_cverr_method.vb b/basic/qa/basic_coverage/test_cverr_method.vb index 9bc8b4f953f1..cc7ee4fe0825 100644 --- a/basic/qa/basic_coverage/test_cverr_method.vb +++ b/basic/qa/basic_coverage/test_cverr_method.vb @@ -6,9 +6,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" ' CVERR If (CVerr(100) <> 100) Then Exit Function @@ -17,7 +17,7 @@ Function doUnitTest as Integer ' tdf#79426 - test with Error-Code 448 ( ERRCODE_BASIC_NAMED_NOT_FOUND ) If (TestCVErr(CVErr(448)) <> 448) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_date_literal.vb b/basic/qa/basic_coverage/test_date_literal.vb index a175368f3598..4042809ca22e 100644 --- a/basic/qa/basic_coverage/test_date_literal.vb +++ b/basic/qa/basic_coverage/test_date_literal.vb @@ -7,10 +7,10 @@ ' -Function doUnitTest as Integer +Function doUnitTest as String If #07/28/1977# = 28334 And #1977-07-28# = 28334 Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_datedateadddatediff_methods.vb b/basic/qa/basic_coverage/test_datedateadddatediff_methods.vb index 4ba40f8ebe29..edf000647535 100644 --- a/basic/qa/basic_coverage/test_datedateadddatediff_methods.vb +++ b/basic/qa/basic_coverage/test_datedateadddatediff_methods.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' DATE DATEDIFF DATEADD If ( DateDiff( "d", aDate, DateAdd("d", 1, aDate) ) <> 1 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_datedatepartday_methods.vb b/basic/qa/basic_coverage/test_datedatepartday_methods.vb index 04cc326f7d52..babdffbf1c8b 100644 --- a/basic/qa/basic_coverage/test_datedatepartday_methods.vb +++ b/basic/qa/basic_coverage/test_datedatepartday_methods.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' DATEPART DAY If ( DatePart( "d", aDate ) <> Day( aDate ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_dimarray_method.vb b/basic/qa/basic_coverage/test_dimarray_method.vb index f92c7459dbe7..fde2a5b57191 100644 --- a/basic/qa/basic_coverage/test_dimarray_method.vb +++ b/basic/qa/basic_coverage/test_dimarray_method.vb @@ -5,14 +5,14 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String Dim aValue as variant aValue = DimArray( 1, 2, 4 ) aValue( 1, 2, 4 ) = 3 ' DIMARRAY If ( aValue( 1, 2, 4 ) <> 3 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_empty_parameter.vb b/basic/qa/basic_coverage/test_empty_parameter.vb index fe6e2651c094..913f8e0cc42e 100644 --- a/basic/qa/basic_coverage/test_empty_parameter.vb +++ b/basic/qa/basic_coverage/test_empty_parameter.vb @@ -10,13 +10,13 @@ Sub assignVar(v As Variant) v = 1
End Sub
-Function doUnitTest() As Integer +Function doUnitTest() As String ' tdf#132563 - check if empty parameters are converted to their respective types
anEmptyVar = Empty
assignVar(anEmptyVar)
If (anEmptyVar = 1 And TypeName(anEmptyVar) = "Integer") Then
- doUnitTest = 1
+ doUnitTest = "OK"
Else
- doUnitTest = 0
+ doUnitTest = "FAIL"
End If
End Function diff --git a/basic/qa/basic_coverage/test_environ_method.vb b/basic/qa/basic_coverage/test_environ_method.vb index 63b6f360aa61..091b0edfea5d 100644 --- a/basic/qa/basic_coverage/test_environ_method.vb +++ b/basic/qa/basic_coverage/test_environ_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ENVIRON Environ ("TMP") - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_equalunoobjects_method.vb b/basic/qa/basic_coverage/test_equalunoobjects_method.vb index b48111546cb3..9e7666ae5b74 100644 --- a/basic/qa/basic_coverage/test_equalunoobjects_method.vb +++ b/basic/qa/basic_coverage/test_equalunoobjects_method.vb @@ -5,21 +5,21 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' EqualUnoObjects ' Copy of objects -> same instance oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) oIntro2 = oIntrospection If ( EqualUnoObjects( oIntrospection, oIntro2 ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else ' Copy of structs as value -> new instance Dim Struct1 as new com.sun.star.beans.Property Struct2 = Struct1 If ( EqualUnoObjects( Struct1, Struct2 ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End If End Function diff --git a/basic/qa/basic_coverage/test_erl_method.vb b/basic/qa/basic_coverage/test_erl_method.vb index b541b15faf9f..ab834650c998 100644 --- a/basic/qa/basic_coverage/test_erl_method.vb +++ b/basic/qa/basic_coverage/test_erl_method.vb @@ -5,18 +5,18 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ERL On Error GoTo ErrorHandler ' Set up error handler Dim nVar As Integer nVar = 0 nVar = 1/nVar - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function ErrorHandler: If ( Erl <> 13 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" Endif End Function diff --git a/basic/qa/basic_coverage/test_err_method.vb b/basic/qa/basic_coverage/test_err_method.vb index c21b417b4200..36d49ee843ce 100644 --- a/basic/qa/basic_coverage/test_err_method.vb +++ b/basic/qa/basic_coverage/test_err_method.vb @@ -5,18 +5,18 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' ERR On Error GoTo ErrorHandler ' Set up error handler Dim nVar As Integer nVar = 0 nVar = 1/nVar - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function ErrorHandler: If ( Err <> 11 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" Endif End Function diff --git a/basic/qa/basic_coverage/test_falsetrue_method.vb b/basic/qa/basic_coverage/test_falsetrue_method.vb index f99b8032b4eb..ae8e5ff5fd35 100644 --- a/basic/qa/basic_coverage/test_falsetrue_method.vb +++ b/basic/qa/basic_coverage/test_falsetrue_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' FALSE TRUE If (False = True) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_filedatetime_nonexistent.vb b/basic/qa/basic_coverage/test_filedatetime_nonexistent.vb index 53a72549c846..2aac2fe0338e 100644 --- a/basic/qa/basic_coverage/test_filedatetime_nonexistent.vb +++ b/basic/qa/basic_coverage/test_filedatetime_nonexistent.vb @@ -5,16 +5,16 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' 'Bug 121337 - FileDateTime("\\nonexistent\smb\path") returns bogus result rather than throwing error -Function doUnitTest as Integer +Function doUnitTest as String On Error GoTo ErrorHandler ' Set up error handler Dim result result = FileDateTime("/bogus/unix/path") - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function ErrorHandler: If ( Err <> 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" Endif End Function diff --git a/basic/qa/basic_coverage/test_filedatetime_nonexistent2.vb b/basic/qa/basic_coverage/test_filedatetime_nonexistent2.vb index 2135b25d27ec..ffce5b1f2732 100644 --- a/basic/qa/basic_coverage/test_filedatetime_nonexistent2.vb +++ b/basic/qa/basic_coverage/test_filedatetime_nonexistent2.vb @@ -5,16 +5,16 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' 'Bug 121337 - FileDateTime("\\nonexistent\smb\path") returns bogus result rather than throwing error -Function doUnitTest as Integer +Function doUnitTest as String On Error GoTo ErrorHandler ' Set up error handler Dim result result = FileDateTime("\\bogus\smb\path") - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function ErrorHandler: If ( Err <> 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" Endif End Function diff --git a/basic/qa/basic_coverage/test_fix_method.vb b/basic/qa/basic_coverage/test_fix_method.vb index 91d2f01fc433..e91a464b14bc 100644 --- a/basic/qa/basic_coverage/test_fix_method.vb +++ b/basic/qa/basic_coverage/test_fix_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' FIX If (Fix(PI) <> 3) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_for_each.vb b/basic/qa/basic_coverage/test_for_each.vb index 654513e88332..3d9b74c273c9 100644 --- a/basic/qa/basic_coverage/test_for_each.vb +++ b/basic/qa/basic_coverage/test_for_each.vb @@ -6,7 +6,7 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String Dim n As Integer, i Dim a(3) n = 0 @@ -23,7 +23,7 @@ Function doUnitTest as Integer Exit Function End If - doUnitTest = 1 + doUnitTest = "OK" End Function Function TestInvalidForEachWithErrorHandler diff --git a/basic/qa/basic_coverage/test_frac_method.vb b/basic/qa/basic_coverage/test_frac_method.vb index 14d6863dbe40..1e86afc43534 100644 --- a/basic/qa/basic_coverage/test_frac_method.vb +++ b/basic/qa/basic_coverage/test_frac_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' FRAC If ( 3+Frac(PI) <> PI) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_freefile_method.vb b/basic/qa/basic_coverage/test_freefile_method.vb index d2a5cb93bae9..78ee24ab4ff5 100644 --- a/basic/qa/basic_coverage/test_freefile_method.vb +++ b/basic/qa/basic_coverage/test_freefile_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' FREEFILE If ( FreeFile < 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_freelibrary_method.vb b/basic/qa/basic_coverage/test_freelibrary_method.vb index 4f6f9cd2d866..e30f2e64f009 100644 --- a/basic/qa/basic_coverage/test_freelibrary_method.vb +++ b/basic/qa/basic_coverage/test_freelibrary_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' FREELIBRARY FreeLibrary("") - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_getdefaultcontext_method.vb b/basic/qa/basic_coverage/test_getdefaultcontext_method.vb index 8a90d6e96453..9d6efd4fcd8b 100644 --- a/basic/qa/basic_coverage/test_getdefaultcontext_method.vb +++ b/basic/qa/basic_coverage/test_getdefaultcontext_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GetDefaultContext GetDefaultContext() - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.vb b/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.vb index 279fc005d731..d2d032c54a82 100644 --- a/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.vb +++ b/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETDIALOGFACTORX If ( GetDialogZoomFactorX(100) < 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getdialogzoomfactory_method.vb b/basic/qa/basic_coverage/test_getdialogzoomfactory_method.vb index f4139bed591c..fdc8ce43d09a 100644 --- a/basic/qa/basic_coverage/test_getdialogzoomfactory_method.vb +++ b/basic/qa/basic_coverage/test_getdialogzoomfactory_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETDIALOGFACTORY If ( GetDialogZoomFactorY(100) < 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getguitype_method.vb b/basic/qa/basic_coverage/test_getguitype_method.vb index c1606da10339..5a3d345b71b9 100644 --- a/basic/qa/basic_coverage/test_getguitype_method.vb +++ b/basic/qa/basic_coverage/test_getguitype_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETGUITYPE If ( GetGuiType = 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getguiversion_method.vb b/basic/qa/basic_coverage/test_getguiversion_method.vb index a70ff07e6d88..37cd852bcd44 100644 --- a/basic/qa/basic_coverage/test_getguiversion_method.vb +++ b/basic/qa/basic_coverage/test_getguiversion_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETGUIVERSION If ( GetGuiVersion = 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getpathseparator_method.vb b/basic/qa/basic_coverage/test_getpathseparator_method.vb index 63a7b6737b92..f3e2915e99ea 100644 --- a/basic/qa/basic_coverage/test_getpathseparator_method.vb +++ b/basic/qa/basic_coverage/test_getpathseparator_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETPATHSEPARATOR If ( GetPathSeparator = "" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getprocessservicemanager_method.vb b/basic/qa/basic_coverage/test_getprocessservicemanager_method.vb index 90e2012d698d..68a112b910d7 100644 --- a/basic/qa/basic_coverage/test_getprocessservicemanager_method.vb +++ b/basic/qa/basic_coverage/test_getprocessservicemanager_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GetProcessServiceManager GetProcessServiceManager() - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_getsolarversion_method.vb b/basic/qa/basic_coverage/test_getsolarversion_method.vb index c2a75d11d44e..12a4eb1b855d 100644 --- a/basic/qa/basic_coverage/test_getsolarversion_method.vb +++ b/basic/qa/basic_coverage/test_getsolarversion_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GetSolarVersion If ( GetSolarVersion() < 50000) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_getsystemtype_method.vb b/basic/qa/basic_coverage/test_getsystemtype_method.vb index eced70204891..b5289dd2569f 100644 --- a/basic/qa/basic_coverage/test_getsystemtype_method.vb +++ b/basic/qa/basic_coverage/test_getsystemtype_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' GETSYSTEMTYPE If ( GetSystemType <> -1 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_hasunointerfaces_method.vb b/basic/qa/basic_coverage/test_hasunointerfaces_method.vb index 06472d847200..d3313c2b2272 100644 --- a/basic/qa/basic_coverage/test_hasunointerfaces_method.vb +++ b/basic/qa/basic_coverage/test_hasunointerfaces_method.vb @@ -5,12 +5,12 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' HASUNOINTERFACES dim aObject as Object If ( HasUnoInterfaces( aObject, "com.sun.star.beans.XIntrospection" ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_hex_method.vb b/basic/qa/basic_coverage/test_hex_method.vb index 72edd9d8e573..56fa257c5a3c 100644 --- a/basic/qa/basic_coverage/test_hex_method.vb +++ b/basic/qa/basic_coverage/test_hex_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' HEX If ( Hex(100) <> "64") Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_hour_method.vb b/basic/qa/basic_coverage/test_hour_method.vb index e132775f8473..7b40e09ca704 100644 --- a/basic/qa/basic_coverage/test_hour_method.vb +++ b/basic/qa/basic_coverage/test_hour_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' HOUR If ( Hour(TimeSerial(12,30,41)) <> 12 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_iif_method.vb b/basic/qa/basic_coverage/test_iif_method.vb index 502cadcb35c1..fce0620ad584 100644 --- a/basic/qa/basic_coverage/test_iif_method.vb +++ b/basic/qa/basic_coverage/test_iif_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' IIF If ( IIF(True, 10, 12) <> 10 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_instr_method.vb b/basic/qa/basic_coverage/test_instr_method.vb index 47fa7a94ede1..435e48a31c96 100644 --- a/basic/qa/basic_coverage/test_instr_method.vb +++ b/basic/qa/basic_coverage/test_instr_method.vb @@ -5,9 +5,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" Dim aString As Variant aString = "Hello" @@ -17,6 +17,6 @@ Function doUnitTest as Integer ' tdf#139840 - case-insensitive operation for non-ASCII characters If (InStr(1, "α", "Α", 1) <> 1) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_int_method.vb b/basic/qa/basic_coverage/test_int_method.vb index 69e811648d1d..7108e4bbb709 100644 --- a/basic/qa/basic_coverage/test_int_method.vb +++ b/basic/qa/basic_coverage/test_int_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' INT If ( Int(PI) <> 3 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isarray_method.vb b/basic/qa/basic_coverage/test_isarray_method.vb index 9d73984b5f59..ec8c1c520560 100644 --- a/basic/qa/basic_coverage/test_isarray_method.vb +++ b/basic/qa/basic_coverage/test_isarray_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVector as Variant aVector = Array( 123, "Hello", -3.14) ' ISARRAY If ( IsArray( aVector ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isdate_method.vb b/basic/qa/basic_coverage/test_isdate_method.vb index 5ce72f87b146..c2a4c342cfcf 100644 --- a/basic/qa/basic_coverage/test_isdate_method.vb +++ b/basic/qa/basic_coverage/test_isdate_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date( ) ' ISDATE If ( IsDate( aDate ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isempty_method.vb b/basic/qa/basic_coverage/test_isempty_method.vb index 6ca2fae6d498..3a8a508b00dc 100644 --- a/basic/qa/basic_coverage/test_isempty_method.vb +++ b/basic/qa/basic_coverage/test_isempty_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Variant aVariant = Date( ) ' ISEMPTY If ( IsEmpty( aVariant ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_iserror_method.vb b/basic/qa/basic_coverage/test_iserror_method.vb index fb12abe6a257..ab33f2b9a130 100644 --- a/basic/qa/basic_coverage/test_iserror_method.vb +++ b/basic/qa/basic_coverage/test_iserror_method.vb @@ -10,13 +10,13 @@ Type MyType tName as String End Type -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as MyType aVariant.tName = "A string" ' ISERROR If ( IsError( aVariant ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_ismissing_basic.vb b/basic/qa/basic_coverage/test_ismissing_basic.vb index b838ce718c36..85efb401274b 100644 --- a/basic/qa/basic_coverage/test_ismissing_basic.vb +++ b/basic/qa/basic_coverage/test_ismissing_basic.vb @@ -1,80 +1,68 @@ -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Const IsMissingNone = -1 Const IsMissingA = 0 Const IsMissingB = 1 Const IsMissingAB = 2 Function doUnitTest() As String - result = verify_testIsMissingBasic() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_testIsMissingBasic + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test optionals with different datatypes. In LO Basic, optional ' parameters are allowed, but without any default values. Missing optional parameters ' will not be initialized to their respective default values of its datatype, either. -Function verify_testIsMissingBasic() As String +Sub verify_testIsMissingBasic() - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - testName = "Test missing (Basic)" On Error GoTo errorHandler ' optionals with variant datatypes - TestLog_ASSERT TestOptVariant(), IsMissingAB, "TestOptVariant()" - TestLog_ASSERT TestOptVariant(123), IsMissingB, "TestOptVariant(123)" - TestLog_ASSERT TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)" - TestLog_ASSERT TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)" + TestUtil.AssertEqual(TestOptVariant(), IsMissingAB, "TestOptVariant()") + TestUtil.AssertEqual(TestOptVariant(123), IsMissingB, "TestOptVariant(123)") + TestUtil.AssertEqual(TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)") + TestUtil.AssertEqual(TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)") ' optionals with variant datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptVariantByRefByVal(), IsMissingAB, "TestOptVariantByRefByVal()" - TestLog_ASSERT TestOptVariantByRefByVal(123), IsMissingB, "TestOptVariantByRefByVal(123)" - TestLog_ASSERT TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)" - TestLog_ASSERT TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptVariantByRefByVal(), IsMissingAB, "TestOptVariantByRefByVal()") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123), IsMissingB, "TestOptVariantByRefByVal(123)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)") ' optionals with double datatypes - TestLog_ASSERT TestOptDouble(), IsMissingAB, "TestOptDouble()" - TestLog_ASSERT TestOptDouble(123.4), IsMissingB, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDouble(, 567.8), IsMissingA, "TestOptDouble(, 567.8)" - TestLog_ASSERT TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDouble(), IsMissingAB, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingB, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingA, "TestOptDouble(, 567.8)") + TestUtil.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptDoubleByRefByVal(), IsMissingAB, "TestOptDouble()" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4), IsMissingB, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDoubleByRefByVal(), IsMissingAB, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingB, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestLog_ASSERT TestOptInteger(), IsMissingAB, "TestOptInteger()" - TestLog_ASSERT TestOptInteger(123), IsMissingB, "TestOptInteger(123)" - TestLog_ASSERT TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)" - TestLog_ASSERT TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)" + TestUtil.AssertEqual(TestOptInteger(), IsMissingAB, "TestOptInteger()") + TestUtil.AssertEqual(TestOptInteger(123), IsMissingB, "TestOptInteger(123)") + TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)") + TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)") ' optionals with integer datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptIntegerByRefByVal(), IsMissingAB, "TestOptIntegerByRefByVal()" - TestLog_ASSERT TestOptIntegerByRefByVal(123), IsMissingB, "TestOptIntegerByRefByVal(123)" - TestLog_ASSERT TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)" - TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingAB, "TestOptIntegerByRefByVal()") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingB, "TestOptIntegerByRefByVal(123)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)") ' optionals with string datatypes - TestLog_ASSERT TestOptString(), IsMissingAB, "TestOptString()" - TestLog_ASSERT TestOptString("123"), IsMissingB, "TestOptString(""123"")" - TestLog_ASSERT TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")" - TestLog_ASSERT TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")" + TestUtil.AssertEqual(TestOptString(), IsMissingAB, "TestOptString()") + TestUtil.AssertEqual(TestOptString("123"), IsMissingB, "TestOptString(""123"")") + TestUtil.AssertEqual(TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")") + TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")") ' optionals with string datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptStringByRefByVal(), IsMissingAB, "TestOptStringByRefByVal()" - TestLog_ASSERT TestOptStringByRefByVal("123"), IsMissingB, "TestOptStringByRefByVal(""123"")" - TestLog_ASSERT TestOptStringByRefByVal(, "456"), IsMissingA, "TestOptStringByRefByVal(, ""456"")" - TestLog_ASSERT TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")" + TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingAB, "TestOptStringByRefByVal()") + TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingB, "TestOptStringByRefByVal(""123"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingA, "TestOptStringByRefByVal(, ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")") ' optionals with object datatypes Dim cA As New Collection @@ -83,16 +71,16 @@ Function verify_testIsMissingBasic() As String Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestLog_ASSERT TestOptObject(), IsMissingAB, "TestOptObject()" - TestLog_ASSERT TestOptObject(cA), IsMissingB, "TestOptObject(A)" - TestLog_ASSERT TestOptObject(, cB), IsMissingA, "TestOptObject(, B)" - TestLog_ASSERT TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)" + TestUtil.AssertEqual(TestOptObject(), IsMissingAB, "TestOptObject()") + TestUtil.AssertEqual(TestOptObject(cA), IsMissingB, "TestOptObject(A)") + TestUtil.AssertEqual(TestOptObject(, cB), IsMissingA, "TestOptObject(, B)") + TestUtil.AssertEqual(TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)") ' optionals with object datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()" - TestLog_ASSERT TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)" - TestLog_ASSERT TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)" - TestLog_ASSERT TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)") + TestUtil.AssertEqual(TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)") ' optionals with array datatypes Dim aA(0 To 1) As Integer @@ -101,24 +89,21 @@ Function verify_testIsMissingBasic() As String Dim aB(0 To 1) As Variant aB(0) = 123.4 aB(1) = 567.8 - TestLog_ASSERT TestOptArray(), IsMissingAB, "TestOptArray()" - TestLog_ASSERT TestOptArray(aA), IsMissingB, "TestOptArray(A)" - TestLog_ASSERT TestOptArray(, aB), IsMissingA, "TestOptArray(, B)" - TestLog_ASSERT TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)" + TestUtil.AssertEqual(TestOptArray(), IsMissingAB, "TestOptArray()") + TestUtil.AssertEqual(TestOptArray(aA), IsMissingB, "TestOptArray(A)") + TestUtil.AssertEqual(TestOptArray(, aB), IsMissingA, "TestOptArray(, B)") + TestUtil.AssertEqual(TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)") ' optionals with array datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()" - TestLog_ASSERT TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)" - TestLog_ASSERT TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)" - TestLog_ASSERT TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)" - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_testIsMissingBasic = result + TestUtil.AssertEqual(TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)") + TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)") - Exit Function + Exit Sub errorHandler: - TestLog_ASSERT False, True, Err.Description -End Function + TestUtil.ReportErrorHandler("verify_testIsMissingBasic", Err, Error$, Erl) +End Sub Function TestOptVariant(Optional A, Optional B As Variant) TestOptVariant = WhatIsMissing(IsMissing(A), IsMissing(B)) @@ -179,12 +164,3 @@ Function WhatIsMissing(is_missingA, is_missingB) WhatIsMissing = IsMissingNone End If End Function - -Sub TestLog_ASSERT(actual As Variant, expected As Integer, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If -End Sub
\ No newline at end of file diff --git a/basic/qa/basic_coverage/test_ismissing_cascade.vb b/basic/qa/basic_coverage/test_ismissing_cascade.vb index ad967c7bbd81..eadce0b2b00c 100644 --- a/basic/qa/basic_coverage/test_ismissing_cascade.vb +++ b/basic/qa/basic_coverage/test_ismissing_cascade.vb @@ -1,36 +1,21 @@ -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Function doUnitTest() As String - result = verify_testIsMissingCascade() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_testIsMissingCascade + doUnitTest = TestUtil.GetResult() End Function -Function verify_testIsMissingCascade() As String - - passCount = 0 - failCount = 0 +Sub verify_testIsMissingCascade() - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - testName = "Test missing (IsMissing with cascading optionals)" On Error GoTo errorHandler ' tdf#136143 - test cascading optionals in order to prevent type conversion errors, because ' optional arguments are of type SbxERROR and set to not fixed. - TestLog_ASSERT TestOpt(), 2, "Cascading optionals" - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_testIsMissingCascade = result + TestUtil.AssertEqual(TestOpt(), 2, "Cascading optionals") - Exit Function + Exit Sub errorHandler: - TestLog_ASSERT False, True, Err.Description -End Function + TestUtil.ReportErrorHandler("verify_testIsMissingCascade", Err, Error$, Erl) +End Sub Function TestOpt(Optional A) TestOpt = TestOptCascade(A) @@ -40,12 +25,3 @@ Function TestOptCascade(Optional A) If IsMissing(A) Then A = 2 TestOptCascade = A End Function - -Sub TestLog_ASSERT(actual As Variant, expected As Integer, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If -End Sub
\ No newline at end of file diff --git a/basic/qa/basic_coverage/test_ismissing_compatible.vb b/basic/qa/basic_coverage/test_ismissing_compatible.vb index dbe2a815d25d..5acc0712eb0a 100644 --- a/basic/qa/basic_coverage/test_ismissing_compatible.vb +++ b/basic/qa/basic_coverage/test_ismissing_compatible.vb @@ -1,83 +1,70 @@ Option Compatible -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Const IsMissingNone = -1 Const IsMissingA = 0 Const IsMissingB = 1 Const IsMissingAB = 2 Function doUnitTest() As String - result = verify_testIsMissingCompatible() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_testIsMissingCompatible + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test isMissing function with different datatypes. In LO Basic ' with option Compatible, optional parameters are allowed with default values. ' Missing optional parameters that don't have explicit default values will ' not be initialized to their default values of its datatype. -Function verify_testIsMissingCompatible() As String - - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - testName = "Test missing (Compatible)" +Sub verify_testIsMissingCompatible() On Error GoTo errorHandler ' optionals with variant datatypes - TestLog_ASSERT TestOptVariant(), IsMissingA, "TestOptVariant()" - TestLog_ASSERT TestOptVariant(123), IsMissingNone, "TestOptVariant(123)" - TestLog_ASSERT TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)" - TestLog_ASSERT TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)" + TestUtil.AssertEqual(TestOptVariant(), IsMissingA, "TestOptVariant()") + TestUtil.AssertEqual(TestOptVariant(123), IsMissingNone, "TestOptVariant(123)") + TestUtil.AssertEqual(TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)") + TestUtil.AssertEqual(TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)") ' optionals with variant datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()" - TestLog_ASSERT TestOptVariantByRefByVal(123), IsMissingNone, "TestOptVariantByRefByVal(123)" - TestLog_ASSERT TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)" - TestLog_ASSERT TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123), IsMissingNone, "TestOptVariantByRefByVal(123)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)") ' optionals with double datatypes - TestLog_ASSERT TestOptDouble(), IsMissingA, "TestOptDouble()" - TestLog_ASSERT TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDouble(, 567.8), IsMissingA, "TestOptDouble(, 567.8)" - TestLog_ASSERT TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDouble(), IsMissingA, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingA, "TestOptDouble(, 567.8)") + TestUtil.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptDoubleByRefByVal(), IsMissingA, "TestOptDouble()" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDoubleByRefByVal(), IsMissingA, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestLog_ASSERT TestOptInteger(), IsMissingA, "TestOptInteger()" - TestLog_ASSERT TestOptInteger(123), IsMissingNone, "TestOptInteger(123)" - TestLog_ASSERT TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)" - TestLog_ASSERT TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)" + TestUtil.AssertEqual(TestOptInteger(), IsMissingA, "TestOptInteger()") + TestUtil.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)") + TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)") + TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)") ' optionals with integer datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptIntegerByRefByVal(), IsMissingA, "TestOptIntegerByRefByVal()" - TestLog_ASSERT TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)" - TestLog_ASSERT TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)" - TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingA, "TestOptIntegerByRefByVal()") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)") ' optionals with string datatypes - TestLog_ASSERT TestOptString(), IsMissingA, "TestOptString()" - TestLog_ASSERT TestOptString("123"), IsMissingNone, "TestOptString(""123"")" - TestLog_ASSERT TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")" - TestLog_ASSERT TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")" + TestUtil.AssertEqual(TestOptString(), IsMissingA, "TestOptString()") + TestUtil.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")") + TestUtil.AssertEqual(TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")") + TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")") ' optionals with string datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptStringByRefByVal(), IsMissingA, "TestOptStringByRefByVal()" - TestLog_ASSERT TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")" - TestLog_ASSERT TestOptStringByRefByVal(, "456"), IsMissingA, "TestOptStringByRefByVal(, ""456"")" - TestLog_ASSERT TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")" + TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingA, "TestOptStringByRefByVal()") + TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingA, "TestOptStringByRefByVal(, ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")") ' optionals with object datatypes Dim cA As New Collection @@ -86,16 +73,16 @@ Function verify_testIsMissingCompatible() As String Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestLog_ASSERT TestOptObject(), IsMissingAB, "TestOptObject()" - TestLog_ASSERT TestOptObject(cA), IsMissingB, "TestOptObject(A)" - TestLog_ASSERT TestOptObject(, cB), IsMissingA, "TestOptObject(, B)" - TestLog_ASSERT TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)" + TestUtil.AssertEqual(TestOptObject(), IsMissingAB, "TestOptObject()") + TestUtil.AssertEqual(TestOptObject(cA), IsMissingB, "TestOptObject(A)") + TestUtil.AssertEqual(TestOptObject(, cB), IsMissingA, "TestOptObject(, B)") + TestUtil.AssertEqual(TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)") ' optionals with object datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()" - TestLog_ASSERT TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)" - TestLog_ASSERT TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)" - TestLog_ASSERT TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)") + TestUtil.AssertEqual(TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)") ' optionals with array datatypes Dim aA(0 To 1) As Integer @@ -104,24 +91,21 @@ Function verify_testIsMissingCompatible() As String Dim aB(0 To 1) As Variant aB(0) = 123.4 aB(1) = 567.8 - TestLog_ASSERT TestOptArray(), IsMissingAB, "TestOptArray()" - TestLog_ASSERT TestOptArray(aA), IsMissingB, "TestOptArray(A)" - TestLog_ASSERT TestOptArray(, aB), IsMissingA, "TestOptArray(, B)" - TestLog_ASSERT TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)" + TestUtil.AssertEqual(TestOptArray(), IsMissingAB, "TestOptArray()") + TestUtil.AssertEqual(TestOptArray(aA), IsMissingB, "TestOptArray(A)") + TestUtil.AssertEqual(TestOptArray(, aB), IsMissingA, "TestOptArray(, B)") + TestUtil.AssertEqual(TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)") ' optionals with array datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()" - TestLog_ASSERT TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)" - TestLog_ASSERT TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)" - TestLog_ASSERT TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)") + TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)") - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_testIsMissingCompatible = result - - Exit Function + Exit Sub errorHandler: - TestLog_ASSERT False, True, Err.Description -End Function + TestUtil.ReportErrorHandler("verify_testIsMissingCompatible", Err, Error$, Erl) +End Sub Function TestOptVariant(Optional A, Optional B As Variant = 123) TestOptVariant = WhatIsMissing(IsMissing(A), IsMissing(B)) @@ -182,12 +166,3 @@ Function WhatIsMissing(is_missingA, is_missingB) WhatIsMissing = IsMissingNone End If End Function - -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If -End Sub
\ No newline at end of file diff --git a/basic/qa/basic_coverage/test_isnull_method.vb b/basic/qa/basic_coverage/test_isnull_method.vb index 0d9044d8f0d4..8378f9691ac1 100644 --- a/basic/qa/basic_coverage/test_isnull_method.vb +++ b/basic/qa/basic_coverage/test_isnull_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Variant aVariant = Null ' ISNULL If ( IsNull( aVariant ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isnumeric_method.vb b/basic/qa/basic_coverage/test_isnumeric_method.vb index d3b614f564bd..db947dbe7044 100644 --- a/basic/qa/basic_coverage/test_isnumeric_method.vb +++ b/basic/qa/basic_coverage/test_isnumeric_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Variant aVariant = 3 ' ISNUMERIC If ( IsNumeric( aVariant ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isobject_method.vb b/basic/qa/basic_coverage/test_isobject_method.vb index bb5e270b3dfb..f9690722cb6d 100644 --- a/basic/qa/basic_coverage/test_isobject_method.vb +++ b/basic/qa/basic_coverage/test_isobject_method.vb @@ -6,12 +6,12 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Object ' ISOBJECT If ( IsObject( aVariant ) = False ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_isunostruct_method.vb b/basic/qa/basic_coverage/test_isunostruct_method.vb index ac45f1961f7e..44d5a5079834 100644 --- a/basic/qa/basic_coverage/test_isunostruct_method.vb +++ b/basic/qa/basic_coverage/test_isunostruct_method.vb @@ -6,12 +6,12 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Object ' ISUNOSTRUCT If ( IsUnoStruct( aVariant ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_join_method.vb b/basic/qa/basic_coverage/test_join_method.vb index 236062516826..9554d12e8cf0 100644 --- a/basic/qa/basic_coverage/test_join_method.vb +++ b/basic/qa/basic_coverage/test_join_method.vb @@ -5,14 +5,14 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' Join Dim aStrings(2) as String aStrings(0) = "Hello" aStrings(1) = "world" If ( Join( aStrings, " " ) <> "Hello world " ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_lbound_method.vb b/basic/qa/basic_coverage/test_lbound_method.vb index b7a91fd3f106..954fa94e4f60 100644 --- a/basic/qa/basic_coverage/test_lbound_method.vb +++ b/basic/qa/basic_coverage/test_lbound_method.vb @@ -6,14 +6,14 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVector as Variant ' ARRAY aVector = Array( "Hello", -3.14) ' LBOUND If ( LBound( aVector() ) <> 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_lcase_method.vb b/basic/qa/basic_coverage/test_lcase_method.vb index 65df764ef6d5..ec0ab07d2956 100644 --- a/basic/qa/basic_coverage/test_lcase_method.vb +++ b/basic/qa/basic_coverage/test_lcase_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' LCASE If ( LCase( aString ) <> "hello" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_len_method.vb b/basic/qa/basic_coverage/test_len_method.vb index 0a7e1abf2ceb..988510add0c2 100644 --- a/basic/qa/basic_coverage/test_len_method.vb +++ b/basic/qa/basic_coverage/test_len_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' LEN If ( Len( aString ) <> 5 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_lenb_method.vb b/basic/qa/basic_coverage/test_lenb_method.vb index 550b8313afec..a3096c819f7b 100644 --- a/basic/qa/basic_coverage/test_lenb_method.vb +++ b/basic/qa/basic_coverage/test_lenb_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' LENB If ( LenB( aString ) <> 5 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_logexp_methods.vb b/basic/qa/basic_coverage/test_logexp_methods.vb index 00db9983754a..45ddeb16855b 100644 --- a/basic/qa/basic_coverage/test_logexp_methods.vb +++ b/basic/qa/basic_coverage/test_logexp_methods.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' EXP LOG If ( Log( Exp(1) ) <> 1 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_ltrim_method.vb b/basic/qa/basic_coverage/test_ltrim_method.vb index 562193c8b036..f3be267dbeb1 100644 --- a/basic/qa/basic_coverage/test_ltrim_method.vb +++ b/basic/qa/basic_coverage/test_ltrim_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' LTRIM If ( LTrim( " Hello" ) <> aString ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_method_name_variable.vb b/basic/qa/basic_coverage/test_method_name_variable.vb index ea45366c0f7d..5f3689ad8752 100644 --- a/basic/qa/basic_coverage/test_method_name_variable.vb +++ b/basic/qa/basic_coverage/test_method_name_variable.vb @@ -20,9 +20,9 @@ Function assignVarToMethod() As Integer End Function -Function doUnitTest() As Integer +Function doUnitTest() As String - doUnitTest = 0 + doUnitTest = "FAIL" ' tdf#85371 - check if the name of the method can be used as a variable in certain statements If (assignVarToMethod() <> 6) Then Exit Function @@ -30,6 +30,6 @@ Function doUnitTest() As Integer assignVarToMethod = 0 If (assignVarToMethod() <> 6) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_mid_CountNegative_3args.vb b/basic/qa/basic_coverage/test_mid_CountNegative_3args.vb index d67370626165..01d1cd998217 100644 --- a/basic/qa/basic_coverage/test_mid_CountNegative_3args.vb +++ b/basic/qa/basic_coverage/test_mid_CountNegative_3args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 5, -3) = "") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.vb b/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.vb index f54ee9444f30..04bf521a9f68 100644 --- a/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.vb +++ b/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 1, 4) = "abc") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.vb b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.vb index 5ab01f987bc7..29f489981e45 100644 --- a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.vb +++ b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 5) = "") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.vb b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.vb index 9c623ce5106f..a38c73153574 100644 --- a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.vb +++ b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 5, 1) = "") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_firstletter_3args.vb b/basic/qa/basic_coverage/test_mid_firstletter_3args.vb index 72c65099f7fa..bdc3ea687961 100644 --- a/basic/qa/basic_coverage/test_mid_firstletter_3args.vb +++ b/basic/qa/basic_coverage/test_mid_firstletter_3args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 1, 1) = "a") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_replace_less.vb b/basic/qa/basic_coverage/test_mid_replace_less.vb index 27a02382c3fd..00885638871f 100644 --- a/basic/qa/basic_coverage/test_mid_replace_less.vb +++ b/basic/qa/basic_coverage/test_mid_replace_less.vb @@ -8,12 +8,12 @@ ' cf. <https://bugs.documentfoundation.org/show_bug.cgi?id=62090> "Mid statement doesn't work as ' expected": -Function doUnitTest as Integer +Function doUnitTest as String s = "The lightbrown fox" Mid(s, 5, 10, "lazy") If (s = "The lazy fox") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_replace_more.vb b/basic/qa/basic_coverage/test_mid_replace_more.vb index 880a3f2008de..40b9ac33792a 100644 --- a/basic/qa/basic_coverage/test_mid_replace_more.vb +++ b/basic/qa/basic_coverage/test_mid_replace_more.vb @@ -8,12 +8,12 @@ ' cf. examples at <https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/ ' statements/mid-statement>: -Function doUnitTest as Integer +Function doUnitTest as String s = "The fox jumps" Mid(s, 5, 3, "duck") If (s = "The duc jumps") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_replace_more_end.vb b/basic/qa/basic_coverage/test_mid_replace_more_end.vb index c5d26a46a8db..593cf1abb0fc 100644 --- a/basic/qa/basic_coverage/test_mid_replace_more_end.vb +++ b/basic/qa/basic_coverage/test_mid_replace_more_end.vb @@ -8,12 +8,12 @@ ' cf. examples at <https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/ ' statements/mid-statement>: -Function doUnitTest as Integer +Function doUnitTest as String s = "The fox jumps" Mid(s, 5, 100, "cow jumped over") If (s = "The cow jumpe") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_mid_sub2letters_2args.vb b/basic/qa/basic_coverage/test_mid_sub2letters_2args.vb index 76c5360d8bc8..88ec1a8f2b3e 100644 --- a/basic/qa/basic_coverage/test_mid_sub2letters_2args.vb +++ b/basic/qa/basic_coverage/test_mid_sub2letters_2args.vb @@ -6,10 +6,10 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String If (Mid("abc", 2) = "bc") Then - doUnitTest = 1 + doUnitTest = "OK" Else - doUnitTest = 0 + doUnitTest = "FAIL" End If End Function diff --git a/basic/qa/basic_coverage/test_minute_method.vb b/basic/qa/basic_coverage/test_minute_method.vb index 0f1230462242..5c4f7d5ceba1 100644 --- a/basic/qa/basic_coverage/test_minute_method.vb +++ b/basic/qa/basic_coverage/test_minute_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' MINUTE If ( Minute(TimeSerial(12,30,41)) <> 30 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_mod_operator.vb b/basic/qa/basic_coverage/test_mod_operator.vb index 006d97558052..5692e7bb50fc 100644 --- a/basic/qa/basic_coverage/test_mod_operator.vb +++ b/basic/qa/basic_coverage/test_mod_operator.vb @@ -6,9 +6,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" Dim a As Double, b as Double a = 16.4 @@ -20,6 +20,6 @@ Function doUnitTest as Integer if (15.9 MOD 6.4 <> 4) Then Exit Function if (2147483647.4 MOD 4 <> 3) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_month_method.vb b/basic/qa/basic_coverage/test_month_method.vb index 38d8ae4062a2..876015598e6e 100644 --- a/basic/qa/basic_coverage/test_month_method.vb +++ b/basic/qa/basic_coverage/test_month_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' MONTH If ( DatePart( "m", aDate ) <> Month( aDate ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_nowtimevalue_methods.vb b/basic/qa/basic_coverage/test_nowtimevalue_methods.vb index 42dce2fc66fb..e01c697165a6 100644 --- a/basic/qa/basic_coverage/test_nowtimevalue_methods.vb +++ b/basic/qa/basic_coverage/test_nowtimevalue_methods.vb @@ -6,15 +6,15 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date dim aTime as Date aDate = Date() aTime = Time() ' NOW TIMEVALUE If ( Now() < aDate + TimeValue(aTime) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_numeric_constant_parameter.vb b/basic/qa/basic_coverage/test_numeric_constant_parameter.vb index 96a7e8f9c4fd..f183936de09d 100644 --- a/basic/qa/basic_coverage/test_numeric_constant_parameter.vb +++ b/basic/qa/basic_coverage/test_numeric_constant_parameter.vb @@ -18,17 +18,17 @@ Function assignLong( numericConstant ) As String assignLong = TypeName( numericConstant )
End Function
-Function doUnitTest() As Integer +Function doUnitTest() As String ' tdf#133913 - check if numeric constants are converted correctly to
' their respective types, if they are passed as arguments to a function
' with variant parameter types.
On Error GoTo errorHandler
If (assignInteger( 1 ) = "Integer" And assignLong( 1 ) = "Long") Then
- doUnitTest = 1
+ doUnitTest = "OK"
Else
- doUnitTest = 0
+ doUnitTest = "FAIL"
End If
Exit Function
errorHandler:
- doUnitTest = 0 -End Function
\ No newline at end of file + doUnitTest = "FAIL" +End Function diff --git a/basic/qa/basic_coverage/test_oct_method.vb b/basic/qa/basic_coverage/test_oct_method.vb index 4c610539de3e..d6d69d7edc5d 100644 --- a/basic/qa/basic_coverage/test_oct_method.vb +++ b/basic/qa/basic_coverage/test_oct_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' OCT If ( Oct(100) <> "144" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_option_base.vb b/basic/qa/basic_coverage/test_option_base.vb index fff5858a4ee6..3195908ca18a 100644 --- a/basic/qa/basic_coverage/test_option_base.vb +++ b/basic/qa/basic_coverage/test_option_base.vb @@ -1,60 +1,42 @@ Option Base 1 -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Function doUnitTest() As String - result = verify_optionBase() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_optionBase + doUnitTest = TestUtil.GetResult() End Function -Function verify_optionBase() As String - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) +Sub verify_optionBase() As String + On Error GoTo errorHandler ' tdf#54912 - with option base arrays should start at index 1. ' Without option compatible the upper bound is changed as well (#109275). Dim strArray(2) As String - TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray) - TestLog_ASSERT UBound(strArray), 3, "Upper bound of a string array (before assignment): " & UBound(strArray) + TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray)) + TestUtil.AssertEqual(UBound(strArray), 3, "Upper bound of a string array (before assignment): " & UBound(strArray)) strArray = Array("a", "b") - TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray) - TestLog_ASSERT UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray) + TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray)) + TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray)) Dim intArray(2) As Integer - TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray) - TestLog_ASSERT UBound(intArray), 3, "Upper bound of an integer array (before assignment): " & UBound(intArray) + TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray)) + TestUtil.AssertEqual(UBound(intArray), 3, "Upper bound of an integer array (before assignment): " & UBound(intArray)) intArray = Array(1, 2) - TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray) - TestLog_ASSERT UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray) + TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray)) + TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray)) Dim byteArray(2) As Byte - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 3, "Upper bound of a byte array (before assignment): " & UBound(byteArray) + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 3, "Upper bound of a byte array (before assignment): " & UBound(byteArray)) byteArray = StrConv("ab", 128) - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray) + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray)) ReDim byteArray(3) - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 4, "Upper bound of a byte array (ReDim): " & UBound(byteArray) - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_optionBase = result -End Function + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 4, "Upper bound of a byte array (ReDim): " & UBound(byteArray)) -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & "Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_optionBase", Err, Error$, Erl) End Sub diff --git a/basic/qa/basic_coverage/test_option_base_compatible.vb b/basic/qa/basic_coverage/test_option_base_compatible.vb index 37644e59faa4..8105dd100265 100644 --- a/basic/qa/basic_coverage/test_option_base_compatible.vb +++ b/basic/qa/basic_coverage/test_option_base_compatible.vb @@ -1,61 +1,44 @@ Option Base 1 Option Compatible -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Function doUnitTest() As String - result = verify_optionBase() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_optionBase + doUnitTest = TestUtil.GetResult() End Function -Function verify_optionBase() As String - passCount = 0 - failCount = 0 +Sub verify_optionBase() - result = "Test Results" & Chr$(10) & "============" & Chr$(10) + On Error GoTo errorHandler ' tdf#54912 - with option base arrays should start at index 1. ' With option compatible the upper bound is not changed (#109275). Dim strArray(2) As String - TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray) - TestLog_ASSERT UBound(strArray), 2, "Upper bound of a string array (before assignment): " & UBound(strArray) + TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray)) + TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (before assignment): " & UBound(strArray)) strArray = Array("a", "b") - TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray) - TestLog_ASSERT UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray) + TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray)) + TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray)) Dim intArray(2) As Integer - TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray) - TestLog_ASSERT UBound(intArray), 2, "Upper bound of an integer array (before assignment): " & UBound(intArray) + TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray)) + TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (before assignment): " & UBound(intArray)) intArray = Array(1, 2) - TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray) - TestLog_ASSERT UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray) + TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray)) + TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray)) Dim byteArray(2) As Byte - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 2, "Upper bound of a byte array (before assignment): " & UBound(byteArray) + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (before assignment): " & UBound(byteArray)) byteArray = StrConv("ab", 128) - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray) + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray)) ReDim byteArray(3) - TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray) - TestLog_ASSERT UBound(byteArray), 3, "Upper bound of a byte array (ReDim): " & UBound(byteArray) - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_optionBase = result -End Function + TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray)) + TestUtil.AssertEqual(UBound(byteArray), 3, "Upper bound of a byte array (ReDim): " & UBound(byteArray)) -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & "Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_optionBase", Err, Error$, Erl) End Sub diff --git a/basic/qa/basic_coverage/test_optional_paramter_type.vb b/basic/qa/basic_coverage/test_optional_paramter_type.vb index 37198ea38244..a5d0b7b2b863 100644 --- a/basic/qa/basic_coverage/test_optional_paramter_type.vb +++ b/basic/qa/basic_coverage/test_optional_paramter_type.vb @@ -1,8 +1,8 @@ REM ***** BASIC *****
Option Compatible
-Function doUnitTest() As Integer
- doUnitTest = 0
+Function doUnitTest() As String
+ doUnitTest = "FAIL"
If CheckType1(32) = 0 Then
Exit Function
End If
@@ -12,7 +12,7 @@ Function doUnitTest() As Integer If CheckType2() = 0 Then
Exit Function
End If
- doUnitTest = 1
+ doUnitTest = "OK"
End Function
Function CheckType1(x As Integer) As Integer
diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.vb b/basic/qa/basic_coverage/test_optional_paramters_basic.vb index 92a81a861d71..6657ef753d5a 100644 --- a/basic/qa/basic_coverage/test_optional_paramters_basic.vb +++ b/basic/qa/basic_coverage/test_optional_paramters_basic.vb @@ -1,76 +1,63 @@ -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Function doUnitTest() As String - result = verify_testOptionalsBasic() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_testOptionalsBasic + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test optionals with different datatypes. In LO Basic, optional ' parameters are allowed, but without any default values. Missing optional ' parameters will not be initialized to their respective default values of ' its datatype, either. -Function verify_testOptionalsBasic() As String - - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - testName = "Test optionals (Basic)" +Sub verify_testOptionalsBasic() On Error GoTo errorHandler ' optionals with variant datatypes - TestLog_ASSERT TestOptVariant(), 0, "TestOptVariant()" - TestLog_ASSERT TestOptVariant(123), 123, "TestOptVariant(123)" - TestLog_ASSERT TestOptVariant(, 456), 456, "TestOptVariant(, 456)" - TestLog_ASSERT TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)" + TestUtil.AssertEqual(TestOptVariant(), 0, "TestOptVariant()") + TestUtil.AssertEqual(TestOptVariant(123), 123, "TestOptVariant(123)") + TestUtil.AssertEqual(TestOptVariant(, 456), 456, "TestOptVariant(, 456)") + TestUtil.AssertEqual(TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)") ' optionals with variant datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptVariantByRefByVal(), 0, "TestOptVariantByRefByVal()" - TestLog_ASSERT TestOptVariantByRefByVal(123), 123, "TestOptVariantByRefByVal(123)" - TestLog_ASSERT TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)" - TestLog_ASSERT TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptVariantByRefByVal(), 0, "TestOptVariantByRefByVal()") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123), 123, "TestOptVariantByRefByVal(123)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)") ' optionals with double datatypes - TestLog_ASSERT TestOptDouble(), 0, "TestOptDouble()" - TestLog_ASSERT TestOptDouble(123.4), 123.4, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)" - TestLog_ASSERT CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 691.2, "TestOptDouble(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDouble(), 0, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDouble(123.4), 123.4, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)") + TestUtil.AssertEqual(CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 691.2, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptDoubleByRefByVal(), 0, "TestOptDouble()" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4), 123.4, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)" - TestLog_ASSERT CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0")), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDoubleByRefByVal(), 0, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), 123.4, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)") + TestUtil.AssertEqual(CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0")), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestLog_ASSERT TestOptInteger(), 0, "TestOptInteger()" - TestLog_ASSERT TestOptInteger(123), 123, "TestOptInteger(123)" - TestLog_ASSERT TestOptInteger(, 456), 456, "TestOptInteger(, 456)" - TestLog_ASSERT TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)" + TestUtil.AssertEqual(TestOptInteger(), 0, "TestOptInteger()") + TestUtil.AssertEqual(TestOptInteger(123), 123, "TestOptInteger(123)") + TestUtil.AssertEqual(TestOptInteger(, 456), 456, "TestOptInteger(, 456)") + TestUtil.AssertEqual(TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)") ' optionals with integer datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptIntegerByRefByVal(), 0, "TestOptIntegerByRefByVal()" - TestLog_ASSERT TestOptIntegerByRefByVal(123), 123, "TestOptIntegerByRefByVal(123)" - TestLog_ASSERT TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)" - TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptIntegerByRefByVal(), 0, "TestOptIntegerByRefByVal()") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), 123, "TestOptIntegerByRefByVal(123)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)") ' optionals with string datatypes - TestLog_ASSERT TestOptString(), "", "TestOptString()" - TestLog_ASSERT TestOptString("123"), "123", "TestOptString(""123"")" - TestLog_ASSERT TestOptString(, "456"), "456", "TestOptString(, ""456"")" - TestLog_ASSERT TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")" + TestUtil.AssertEqual(TestOptString(), "", "TestOptString()") + TestUtil.AssertEqual(TestOptString("123"), "123", "TestOptString(""123"")") + TestUtil.AssertEqual(TestOptString(, "456"), "456", "TestOptString(, ""456"")") + TestUtil.AssertEqual(TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")") ' optionals with string datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptStringByRefByVal(), "", "TestOptStringByRefByVal()" - TestLog_ASSERT TestOptStringByRefByVal("123"), "123", "TestOptStringByRefByVal(""123"")" - TestLog_ASSERT TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")" - TestLog_ASSERT TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")" + TestUtil.AssertEqual(TestOptStringByRefByVal(), "", "TestOptStringByRefByVal()") + TestUtil.AssertEqual(TestOptStringByRefByVal("123"), "123", "TestOptStringByRefByVal(""123"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")") ' optionals with object datatypes Dim cA As New Collection @@ -79,16 +66,16 @@ Function verify_testOptionalsBasic() As String Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestLog_ASSERT TestOptObject(), 0, "TestOptObject()" - TestLog_ASSERT TestOptObject(cA), 579, "TestOptObject(A)" - TestLog_ASSERT CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, "TestOptObject(, B)" - TestLog_ASSERT CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, "TestOptObject(A, B)" + TestUtil.AssertEqual(TestOptObject(), 0, "TestOptObject()") + TestUtil.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, "TestOptObject(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, "TestOptObject(A, B)") ' optionals with object datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()" - TestLog_ASSERT TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)" - TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)" - TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)") ' optionals with array datatypes Dim aA(0 To 1) As Integer @@ -97,24 +84,21 @@ Function verify_testOptionalsBasic() As String Dim aB(0 To 1) As Variant aB(0) = 123.4 aB(1) = 567.8 - TestLog_ASSERT TestOptArray(), 0, "TestOptArray()" - TestLog_ASSERT TestOptArray(aA), 579, "TestOptArray(A)" - TestLog_ASSERT CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)" - TestLog_ASSERT CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)" + TestUtil.AssertEqual(TestOptArray(), 0, "TestOptArray()") + TestUtil.AssertEqual(TestOptArray(aA), 579, "TestOptArray(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)") ' optionals with array datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()" - TestLog_ASSERT TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)" - TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)" - TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)") - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_testOptionalsBasic = result - - Exit Function + Exit Sub errorHandler: - TestLog_ASSERT False, True, Err.Description -End Function + TestUtil.ReportErrorHandler("verify_testOptionalsBasic", Err, Error$, Erl) +End Sub Function TestOptVariant(Optional A, Optional B As Variant) TestOptVariant = OptNumberSum(IsMissing(A), A, IsMissing(B), B) @@ -197,12 +181,3 @@ Function ArraySum(is_missingC As Boolean, C) Next idx End If End Function - -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If -End Sub
\ No newline at end of file diff --git a/basic/qa/basic_coverage/test_optional_paramters_compatible.vb b/basic/qa/basic_coverage/test_optional_paramters_compatible.vb index 9ea47550820d..5e88b5d7e05a 100644 --- a/basic/qa/basic_coverage/test_optional_paramters_compatible.vb +++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.vb @@ -1,78 +1,66 @@ Option Compatible -Dim passCount As Integer -Dim failCount As Integer -Dim result As String - Function doUnitTest() As String - result = verify_testOptionalsCompatible() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_testOptionalsCompatible + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test optionals with different datatypes. In LO Basic ' with option Compatible, optional parameters are allowed with default values. ' Missing optional parameters that don't have explicit default values will ' not be initialized to their default values of its datatype. -Function verify_testOptionalsCompatible() As String +Sub verify_testOptionalsCompatible() - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - testName = "Test optionals (Compatible)" On Error GoTo errorHandler ' optionals with variant datatypes - TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()" - TestLog_ASSERT TestOptVariant(123), 246, "TestOptVariant(123)" - TestLog_ASSERT TestOptVariant(, 456), 456, "TestOptVariant(, 456)" - TestLog_ASSERT TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)" + TestUtil.AssertEqual(TestOptVariant(), 123, "TestOptVariant()") + TestUtil.AssertEqual(TestOptVariant(123), 246, "TestOptVariant(123)") + TestUtil.AssertEqual(TestOptVariant(, 456), 456, "TestOptVariant(, 456)") + TestUtil.AssertEqual(TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)") ' optionals with variant datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()" - TestLog_ASSERT TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)" - TestLog_ASSERT TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)" - TestLog_ASSERT TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)") ' optionals with double datatypes - TestLog_ASSERT TestOptDouble(), 123.4, "TestOptDouble()" - TestLog_ASSERT TestOptDouble(123.4), 246.8, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)" - TestLog_ASSERT CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 691.2, "TestOptDouble(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDouble(), 123.4, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDouble(123.4), 246.8, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)") + TestUtil.AssertEqual(CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 691.2, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptDoubleByRefByVal(), 123.4, "TestOptDouble()" - TestLog_ASSERT TestOptDoubleByRefByVal(123.4), 246.8, "TestOptDouble(123.4)" - TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)" - TestLog_ASSERT CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0")), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)" + TestUtil.AssertEqual(TestOptDoubleByRefByVal(), 123.4, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), 246.8, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)") + TestUtil.AssertEqual(CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0")), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestLog_ASSERT TestOptInteger(), 123, "TestOptInteger()" - TestLog_ASSERT TestOptInteger(123), 246, "TestOptInteger(123)" - TestLog_ASSERT TestOptInteger(, 456), 456, "TestOptInteger(, 456)" - TestLog_ASSERT TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)" + TestUtil.AssertEqual(TestOptInteger(), 123, "TestOptInteger()") + TestUtil.AssertEqual(TestOptInteger(123), 246, "TestOptInteger(123)") + TestUtil.AssertEqual(TestOptInteger(, 456), 456, "TestOptInteger(, 456)") + TestUtil.AssertEqual(TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)") ' optionals with integer datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()" - TestLog_ASSERT TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)" - TestLog_ASSERT TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)" - TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)" + TestUtil.AssertEqual(TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)") ' optionals with string datatypes - TestLog_ASSERT TestOptString(), "123", "TestOptString()" - TestLog_ASSERT TestOptString("123"), "123123", "TestOptString(""123"")" - TestLog_ASSERT TestOptString(, "456"), "456", "TestOptString(, ""456"")" - TestLog_ASSERT TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")" + TestUtil.AssertEqual(TestOptString(), "123", "TestOptString()") + TestUtil.AssertEqual(TestOptString("123"), "123123", "TestOptString(""123"")") + TestUtil.AssertEqual(TestOptString(, "456"), "456", "TestOptString(, ""456"")") + TestUtil.AssertEqual(TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")") ' optionals with string datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()" - TestLog_ASSERT TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")" - TestLog_ASSERT TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")" - TestLog_ASSERT TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")" + TestUtil.AssertEqual(TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()") + TestUtil.AssertEqual(TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")") ' optionals with object datatypes Dim cA As New Collection @@ -81,16 +69,16 @@ Function verify_testOptionalsCompatible() As String Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestLog_ASSERT TestOptObject(), 0, "TestOptObject()" - TestLog_ASSERT TestOptObject(cA), 579, "TestOptObject(A)" - TestLog_ASSERT CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, "TestOptObject(, B)" - TestLog_ASSERT CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, "TestOptObject(A, B)" + TestUtil.AssertEqual(TestOptObject(), 0, "TestOptObject()") + TestUtil.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, "TestOptObject(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, "TestOptObject(A, B)") ' optionals with object datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()" - TestLog_ASSERT TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)" - TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)" - TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)" + TestUtil.AssertEqual(TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()") + TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)") ' optionals with array datatypes Dim aA(0 To 1) As Integer @@ -99,24 +87,21 @@ Function verify_testOptionalsCompatible() As String Dim aB(0 To 1) As Variant aB(0) = 123.4 aB(1) = 567.8 - TestLog_ASSERT TestOptArray(), 0, "TestOptArray()" - TestLog_ASSERT TestOptArray(aA), 579, "TestOptArray(A)" - TestLog_ASSERT CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)" - TestLog_ASSERT CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)" + TestUtil.AssertEqual(TestOptArray(), 0, "TestOptArray()") + TestUtil.AssertEqual(TestOptArray(aA), 579, "TestOptArray(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)") ' optionals with array datatypes (ByRef and ByVal) - TestLog_ASSERT TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()" - TestLog_ASSERT TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)" - TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)" - TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)" - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_testOptionalsCompatible = result + TestUtil.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()") + TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)") + TestUtil.AssertEqual(CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)") + TestUtil.AssertEqual(CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)") - Exit Function + Exit Sub errorHandler: - TestLog_ASSERT False, True, Err.Description -End Function + TestUtil.ReportErrorHandler("verify_testOptionalsCompatible", Err, Error$, Erl) +End Sub Function TestOptVariant(Optional A, Optional B As Variant = 123) TestOptVariant = OptNumberSum(IsMissing(A), A, IsMissing(B), B) @@ -199,12 +184,3 @@ Function ArraySum(is_missingC As Boolean, C) Next idx End If End Function - -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If -End Sub
\ No newline at end of file diff --git a/basic/qa/basic_coverage/test_qbcolor_method.vb b/basic/qa/basic_coverage/test_qbcolor_method.vb index 8051a80b64a7..2fe4b01cff2d 100644 --- a/basic/qa/basic_coverage/test_qbcolor_method.vb +++ b/basic/qa/basic_coverage/test_qbcolor_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' QBCOLOR If ( QBColor(7) <> 12632256 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_random_methods.vb b/basic/qa/basic_coverage/test_random_methods.vb index ea5d1c9797e1..138050bdd769 100644 --- a/basic/qa/basic_coverage/test_random_methods.vb +++ b/basic/qa/basic_coverage/test_random_methods.vb @@ -5,12 +5,12 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String Randomize 42 ' RND If ( Rnd >= 1 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_redim_objects.vb b/basic/qa/basic_coverage/test_redim_objects.vb index 053ba1aa2521..29f7b2caa82b 100644 --- a/basic/qa/basic_coverage/test_redim_objects.vb +++ b/basic/qa/basic_coverage/test_redim_objects.vb @@ -12,9 +12,9 @@ Type testType oColor As Object End Type -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" ' tdf#136755 - ReDim did not work on an array of objects Dim aPropertyValues(1) As New com.sun.star.beans.PropertyValue @@ -28,6 +28,6 @@ Function doUnitTest as Integer ReDim aType(5) As testType If (UBound(aType) <> 5) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_resolvepath_method.vb b/basic/qa/basic_coverage/test_resolvepath_method.vb index 888a29dfbc13..88c7ef0c3445 100644 --- a/basic/qa/basic_coverage/test_resolvepath_method.vb +++ b/basic/qa/basic_coverage/test_resolvepath_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' RESOLVEPATH If ( ResolvePath( "" ) <> "" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_rgb_method.vb b/basic/qa/basic_coverage/test_rgb_method.vb index 7bdaf9660138..d15fac6c27d4 100644 --- a/basic/qa/basic_coverage/test_rgb_method.vb +++ b/basic/qa/basic_coverage/test_rgb_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' RGB If ( RGB( 128, 50, 200 ) <> 8401608 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_rtrim_method.vb b/basic/qa/basic_coverage/test_rtrim_method.vb index 79a8093fe20d..ee0aefefd37b 100644 --- a/basic/qa/basic_coverage/test_rtrim_method.vb +++ b/basic/qa/basic_coverage/test_rtrim_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' RTRIM If ( RTrim( "Hello " ) <> aString ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_second_method.vb b/basic/qa/basic_coverage/test_second_method.vb index 77311e9d3ccf..66ed058bc0ab 100644 --- a/basic/qa/basic_coverage/test_second_method.vb +++ b/basic/qa/basic_coverage/test_second_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' SECOND If ( Second(TimeSerial(12,30,41)) <> 41 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_sgn_method.vb b/basic/qa/basic_coverage/test_sgn_method.vb index da2cf6757ba2..5473cc583581 100644 --- a/basic/qa/basic_coverage/test_sgn_method.vb +++ b/basic/qa/basic_coverage/test_sgn_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' SGN If ( Sgn(-3.14) <> -1 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_space_method.vb b/basic/qa/basic_coverage/test_space_method.vb index 8b35b108b504..9a9e3363182a 100644 --- a/basic/qa/basic_coverage/test_space_method.vb +++ b/basic/qa/basic_coverage/test_space_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' SPACE If ( Space(3) <> " " ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_spc_method.vb b/basic/qa/basic_coverage/test_spc_method.vb index 7ed291e13e71..6041fb19616b 100644 --- a/basic/qa/basic_coverage/test_spc_method.vb +++ b/basic/qa/basic_coverage/test_spc_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' SPC If ( Spc(3) <> " " ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_split_method.vb b/basic/qa/basic_coverage/test_split_method.vb index 8f3701e3d987..b5cfe398ed30 100644 --- a/basic/qa/basic_coverage/test_split_method.vb +++ b/basic/qa/basic_coverage/test_split_method.vb @@ -5,9 +5,9 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String - doUnitTest = 0 + doUnitTest = "FAIL" ' SPLIT If ( Split( "Hello world" )(1) <> "world" ) Then Exit Function @@ -27,6 +27,6 @@ Function doUnitTest as Integer ReDim Preserve arr(1) If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_sqr_method.vb b/basic/qa/basic_coverage/test_sqr_method.vb index 55db95403030..9e9777247a79 100644 --- a/basic/qa/basic_coverage/test_sqr_method.vb +++ b/basic/qa/basic_coverage/test_sqr_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' SQR If ( Sqr( 4 ) <> 2 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_strcomp_method.vb b/basic/qa/basic_coverage/test_strcomp_method.vb index aeb146e572d3..52c8b71071b3 100644 --- a/basic/qa/basic_coverage/test_strcomp_method.vb +++ b/basic/qa/basic_coverage/test_strcomp_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' STRCOMP If ( StrComp( aString, "Hello" ) <> 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_string_literal_comparison.vb b/basic/qa/basic_coverage/test_string_literal_comparison.vb index af63ede517dc..c3a8413fcdc2 100644 --- a/basic/qa/basic_coverage/test_string_literal_comparison.vb +++ b/basic/qa/basic_coverage/test_string_literal_comparison.vb @@ -5,15 +5,15 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' tdf#142180 - Invalid text comparison result in Basic - doUnitTest = 0 + doUnitTest = "FAIL" If ( "Z" < "A" ) Then Exit Function If ( "A" > "Z" ) Then Exit Function If ( "A" < "A" ) Then Exit Function If ( "A" > "A" ) Then Exit Function If ( "Z" <= "A" ) Then Exit Function If ( "A" >= "Z" ) Then Exit Function - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_string_method.vb b/basic/qa/basic_coverage/test_string_method.vb index 8664ac0111f9..638051c763d8 100644 --- a/basic/qa/basic_coverage/test_string_method.vb +++ b/basic/qa/basic_coverage/test_string_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' STRING If ( String( 3, "H" ) <> "HHH" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_string_overflow_safe.vb b/basic/qa/basic_coverage/test_string_overflow_safe.vb index 148cc910c7f5..f245e14abc4e 100644 --- a/basic/qa/basic_coverage/test_string_overflow_safe.vb +++ b/basic/qa/basic_coverage/test_string_overflow_safe.vb @@ -1,6 +1,6 @@ Option Explicit -Function doUnitTest As Integer +Function doUnitTest As String ' Trying to create too long string should generate proper BASIC overflow error. ' Longest possible string is 2147483638 wchar_t (2G - 10). ' This tries to create string with 2G wchar_t. If it does not overflow, test fails. @@ -11,12 +11,12 @@ Function doUnitTest As Integer For i=1 To 31 s = s & s Next i - doUnitTest = 0 + doUnitTest = "FAIL" Exit Function errorHandler: If ( Err <> 6 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" Endif End Function diff --git a/basic/qa/basic_coverage/test_string_replace.vb b/basic/qa/basic_coverage/test_string_replace.vb index e2e9ce35962b..a2a5f541b3ff 100644 --- a/basic/qa/basic_coverage/test_string_replace.vb +++ b/basic/qa/basic_coverage/test_string_replace.vb @@ -1,43 +1,26 @@ -Dim passCount As Integer -Dim failCount As Integer -Dim result As String +Option VBASupport 0 Function doUnitTest() As String - result = verify_stringReplace() - If failCount <> 0 Or passCount = 0 Then - doUnitTest = 0 - Else - doUnitTest = 1 - End If + TestUtil.TestInit + verify_stringReplace + doUnitTest = TestUtil.GetResult() End Function -Function verify_stringReplace() As String - passCount = 0 - failCount = 0 - - result = "Test Results" & Chr$(10) & "============" & Chr$(10) - +Sub verify_stringReplace() + On Error GoTo errorHandler ' tdf#132389 - case-insensitive operation for non-ASCII characters retStr = Replace("ABCabc", "b", "*") - TestLog_ASSERT retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr + TestUtil.AssertEqual(retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr) retStr = Replace("АБВабв", "б", "*") - TestLog_ASSERT retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr + TestUtil.AssertEqual(retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr) ' tdf#141045 - different length of search and replace string. It is important ' that the search string starts with the original string in order to test the error. ' Without the fix in place, the string index calculations result in a crash. retStr = Replace("a", "abc", "ab") - TestLog_ASSERT retStr, "a", "different length of search and replace string: " & retStr - - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) - verify_stringReplace = result -End Function + TestUtil.AssertEqual(retStr, "a", "different length of search and replace string: " & retStr) -Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String) - If expected = actual Then - passCount = passCount + 1 - Else - result = result & Chr$(10) & "Failed: " & testName & " returned " & actual & ", expected " & expected - failCount = failCount + 1 - End If + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl) End Sub diff --git a/basic/qa/basic_coverage/test_strtrim_methods.vb b/basic/qa/basic_coverage/test_strtrim_methods.vb index b9da11d7fa1d..8ace76dc369c 100644 --- a/basic/qa/basic_coverage/test_strtrim_methods.vb +++ b/basic/qa/basic_coverage/test_strtrim_methods.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' STR TRIM If ( Trim( Str( 4 ) ) <> "4" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_switch_method.vb b/basic/qa/basic_coverage/test_switch_method.vb index 9dc00fa525e8..2af52923aadb 100644 --- a/basic/qa/basic_coverage/test_switch_method.vb +++ b/basic/qa/basic_coverage/test_switch_method.vb @@ -6,15 +6,15 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aVariant as Object ' SWITCH If ( Switch( False, 10,_ True, 11,_ False, 12,_ True, 13 ) <> 11 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_tab_method.vb b/basic/qa/basic_coverage/test_tab_method.vb index a5e4e9815197..beb8f554167f 100644 --- a/basic/qa/basic_coverage/test_tab_method.vb +++ b/basic/qa/basic_coverage/test_tab_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TAB If ( "Hello" & Tab(0) & "World" <> "HelloWorld" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_tan_method.vb b/basic/qa/basic_coverage/test_tan_method.vb index 117d2824bcd6..3666647efe6f 100644 --- a/basic/qa/basic_coverage/test_tan_method.vb +++ b/basic/qa/basic_coverage/test_tan_method.vb @@ -5,11 +5,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TAN If ( Abs( Tan(PI/4) - 1 ) > 1E-6 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_timer_method.vb b/basic/qa/basic_coverage/test_timer_method.vb index 3ccb120f6284..769568d8e6be 100644 --- a/basic/qa/basic_coverage/test_timer_method.vb +++ b/basic/qa/basic_coverage/test_timer_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TIMER max value = 24*3600 If ( Timer() > 86400 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_timeserialtimevalue_methods.vb b/basic/qa/basic_coverage/test_timeserialtimevalue_methods.vb index 6e84329d041b..494a8e50407e 100644 --- a/basic/qa/basic_coverage/test_timeserialtimevalue_methods.vb +++ b/basic/qa/basic_coverage/test_timeserialtimevalue_methods.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TIMESERIAL TIMEVALUE If ( TimeSerial(13,54,48) <> TimeValue("13:54:48") ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_twipsperpixelx_method.vb b/basic/qa/basic_coverage/test_twipsperpixelx_method.vb index 2b8890ad715c..fb4cca698b03 100644 --- a/basic/qa/basic_coverage/test_twipsperpixelx_method.vb +++ b/basic/qa/basic_coverage/test_twipsperpixelx_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TWIPSPERPIXELX If ( TwipsPerPixelX < 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_twipsperpixely_method.vb b/basic/qa/basic_coverage/test_twipsperpixely_method.vb index efc41e1ffc81..4001495f2abf 100644 --- a/basic/qa/basic_coverage/test_twipsperpixely_method.vb +++ b/basic/qa/basic_coverage/test_twipsperpixely_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' TWIPSPERPIXELY If ( TwipsPerPixelY < 0 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_typelen_method.vb b/basic/qa/basic_coverage/test_typelen_method.vb index a9ebb01446bb..dc8935237fcc 100644 --- a/basic/qa/basic_coverage/test_typelen_method.vb +++ b/basic/qa/basic_coverage/test_typelen_method.vb @@ -39,7 +39,7 @@ Function doUnitTest doUnitTest = "test_typelen_method.vb fails" + messages Exit Function EndIf - doUnitTest = 1 ' All checks passed + doUnitTest = "OK" ' All checks passed End Function Sub DEV_TEST diff --git a/basic/qa/basic_coverage/test_typename_method.vb b/basic/qa/basic_coverage/test_typename_method.vb index ec9dbb408ac5..c246b652e246 100644 --- a/basic/qa/basic_coverage/test_typename_method.vb +++ b/basic/qa/basic_coverage/test_typename_method.vb @@ -60,7 +60,7 @@ Function doUnitTest ' TypeName() doUnitTest = "test_typename_method.vb failed" + messages Exit Function EndIf - doUnitTest = 1 ' All checks passed + doUnitTest = "OK" ' All checks passed End Function Sub DEV_TEST : Print doUnitTest : End Sub diff --git a/basic/qa/basic_coverage/test_types_conversion.vb b/basic/qa/basic_coverage/test_types_conversion.vb index 0868f4d3e50a..1b923ad8c197 100644 --- a/basic/qa/basic_coverage/test_types_conversion.vb +++ b/basic/qa/basic_coverage/test_types_conversion.vb @@ -12,7 +12,7 @@ Dim nPassCount As Integer Dim nFailCount As Integer ' For the following tests the en-US (English - United States) locale is required -Function doUnitTest() As Integer +Function doUnitTest() As String nTotalCount = 0 nPassCount = 0 nFailCount = 0 @@ -45,9 +45,9 @@ Function doUnitTest() As Integer AssertTest(nVal = -123456) If ((nFailCount > 0) Or (nPassCount <> nTotalCount)) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_ucase_method.vb b/basic/qa/basic_coverage/test_ucase_method.vb index 940c0897b0cd..3b281f7f2ff9 100644 --- a/basic/qa/basic_coverage/test_ucase_method.vb +++ b/basic/qa/basic_coverage/test_ucase_method.vb @@ -5,13 +5,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aString as Variant aString = "Hello" ' UCASE If ( UCase( aString ) <> "HELLO" ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_val_method.vb b/basic/qa/basic_coverage/test_val_method.vb index c25610cebd92..bbce97697c71 100644 --- a/basic/qa/basic_coverage/test_val_method.vb +++ b/basic/qa/basic_coverage/test_val_method.vb @@ -6,11 +6,11 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' VAL If ( Val("4") <> 4 ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_vartype_method.vb b/basic/qa/basic_coverage/test_vartype_method.vb index 9c15d8520a93..9fc60acbc377 100644 --- a/basic/qa/basic_coverage/test_vartype_method.vb +++ b/basic/qa/basic_coverage/test_vartype_method.vb @@ -24,74 +24,67 @@ Dim intArray() As Integer, lngArray(5) As Long, sngArray!() As Single, dblArra ' Constants that candidate for public exposure Private Const V_ARRAY=8192, V_OBJECT=9, V_ERROR=10, V_BOOLEAN=11, V_VARIANT=12, V_BYTE=17 -Function doUnitTest - ' VarType() - - assert( V_EMPTY = 0 , "V_EMPTY is not 0") - assert( V_NULL = 1 , "V_NULL is not 1") - assert( V_INTEGER = 2 , "V_INTEGER is not 2") - assert( V_LONG = 3 , "V_LONG is not 3") - assert( V_SINGLE = 4 , "V_SINGLE is not 4") - assert( V_DOUBLE = 5 , "V_DOUBLE is not 5") - assert( V_CURRENCY = 6, "V_CURRENCY is not 6") - assert( V_DATE = 7 , "V_DATE is not 7") - assert( V_STRING = 8 , "V_STRING is not 8") +Function doUnitTest() As String + TestUtil.TestInit + verify_testvartype + doUnitTest = TestUtil.GetResult() +End Function - assert( VarType(Empty) = V_EMPTY , "Vartype(Empty) is not V_EMPTY") - assert( VarType(Null) = V_NULL , "Vartype(Empty) is not V_NULL") - assert( VarType(Nothing) = V_OBJECT, "Vartype(Empty) is not V_OBJECT") +Sub verify_testvartype() + On Error GoTo errorHandler - myErr = CVErr("errMsg") - assert( VarType(int16) = V_INTEGER , "VarType(int16) is not V_INTEGER") - assert( VarType(int32) = V_LONG , "VarType(int32) is not V_LONG") - assert( VarType(flt32) = V_SINGLE , "VarType(flt32) is not V_SINGLE" ) - assert( VarType(flt64) = V_DOUBLE , "VarType(flt64) is not V_DOUBLE" ) - assert( VarType(curr) = V_CURRENCY, "VarType(curr) is not V_CURRENCY" ) - assert( VarType(dat) = V_DATE , "VarType(dat) is not V_DATE" ) - assert( VarType(str) = V_STRING , "VarType(str) is not V_STRING" ) - assert( VarType(obj) = V_OBJECT , "VarType(obj) is not V_OBJECT" ) - assert( VarType(myUDF) = V_OBJECT , "VarType(myUDF) is not V_OBJECT" ) - assert( VarType(myErr) = V_ERROR , "VarType(myErr) is not V_ERROR" ) - assert( VarType(bool) = V_BOOLEAN , "VarType(bool) is not V_BOOLEAN" ) - assert( VarType(var) = V_EMPTY , "VarType(var) is not V_EMPTY" ) - assert( VarType(byt3) = V_BYTE , "VarType(byt3) is not V_BYTE" ) + ' VarType() - assert( VarType(int_) = V_INTEGER , "VarType(int_) is not V_INTEGER" ) - assert( VarType(long_) = V_LONG , "VarType(long_) is not V_LONG" ) - assert( VarType(single_) = V_SINGLE , "VarType(single_) is not V_SINGLE" ) - assert( VarType(double_) = V_DOUBLE , "VarType(double_) is not V_CURRENCY" ) - assert( VarType(currency_) = V_CURRENCY, "VarType(currency_) is not V_CURRENCY" ) - assert( VarType(string_) = V_STRING , "VarType(string_) is not V_STRING" ) + TestUtil.AssertEqual( V_EMPTY, 0 , "V_EMPTY is not 0") + TestUtil.AssertEqual( V_NULL, 1 , "V_NULL is not 1") + TestUtil.AssertEqual( V_INTEGER, 2 , "V_INTEGER is not 2") + TestUtil.AssertEqual( V_LONG, 3 , "V_LONG is not 3") + TestUtil.AssertEqual( V_SINGLE, 4 , "V_SINGLE is not 4") + TestUtil.AssertEqual( V_DOUBLE, 5 , "V_DOUBLE is not 5") + TestUtil.AssertEqual( V_CURRENCY, 6, "V_CURRENCY is not 6") + TestUtil.AssertEqual( V_DATE, 7 , "V_DATE is not 7") + TestUtil.AssertEqual( V_STRING, 8 , "V_STRING is not 8") - assert( VarType(intArray) = V_ARRAY+V_INTEGER , "VarType(intArray) is not V_ARRAY+V_INTEGER" ) - assert( VarType(lngArray) = V_ARRAY+V_LONG , "VarType(lngArray) is not V_ARRAY+V_LONG" ) - assert( VarType(sngArray) = V_ARRAY+V_SINGLE , "VarType(sngArray) is not V_ARRAY+V_SINGLE" ) - assert( VarType(dblArray) = V_ARRAY+V_DOUBLE , "VarType(dblArray) is not V_ARRAY+V_DOUBLE" ) - assert( VarType(curArray) = V_ARRAY+V_CURRENCY, "VarType(curArray) is not V_ARRAY+V_CURRENCY" ) - assert( VarType(datArray) = V_ARRAY+V_DATE , "VarType(datArray) is not V_ARRAY+V_DATE" ) - assert( VarType(strArray) = V_ARRAY+V_STRING , "VarType(strArray) is not V_ARRAY+V_STRING" ) - assert( VarType(objArray) = V_ARRAY+V_OBJECT , "VarType(objArray) is not V_ARRAY+V_OBJECT" ) - 'assert( VarType(***Array) = V_ARRAY+V_ERROR , "VarType(***Array) is not V_ARRAY+V_ERROR" ) - assert( VarType(boolArray) = V_ARRAY+V_BOOLEAN , "VarType(boolArray) is not V_ARRAY+V_BOOLEAN" ) - assert( VarType(varArray) = V_ARRAY+V_VARIANT , "VarType(varArray) is not V_ARRAY+V_VARIANT" ) - assert( VarType(byteArray) = V_ARRAY+V_BYTE , "VarType(byteArray) is not V_ARRAY+V_BYTE" ) + TestUtil.AssertEqual( VarType(Empty) , V_EMPTY , "Vartype(Empty) is not V_EMPTY") + TestUtil.AssertEqual( VarType(Null) , V_NULL , "Vartype(Empty) is not V_NULL") + TestUtil.AssertEqual( VarType(Nothing), V_OBJECT, "Vartype(Empty) is not V_OBJECT") - If failedAssertion Then - doUnitTest = "test_vartype_method.vb fails" + messages - Exit Function - EndIf - doUnitTest = 1 ' All checks passed -End Function + myErr = CVErr("errMsg") + TestUtil.AssertEqual( VarType(int16), V_INTEGER , "VarType(int16) is not V_INTEGER") + TestUtil.AssertEqual( VarType(int32), V_LONG , "VarType(int32) is not V_LONG") + TestUtil.AssertEqual( VarType(flt32), V_SINGLE , "VarType(flt32) is not V_SINGLE" ) + TestUtil.AssertEqual( VarType(flt64), V_DOUBLE , "VarType(flt64) is not V_DOUBLE" ) + TestUtil.AssertEqual( VarType(curr) , V_CURRENCY, "VarType(curr) is not V_CURRENCY" ) + TestUtil.AssertEqual( VarType(dat) , V_DATE , "VarType(dat) is not V_DATE" ) + TestUtil.AssertEqual( VarType(str) , V_STRING , "VarType(str) is not V_STRING" ) + TestUtil.AssertEqual( VarType(obj) , V_OBJECT , "VarType(obj) is not V_OBJECT" ) + TestUtil.AssertEqual( VarType(myUDF), V_OBJECT , "VarType(myUDF) is not V_OBJECT" ) + TestUtil.AssertEqual( VarType(myErr), V_ERROR , "VarType(myErr) is not V_ERROR" ) + TestUtil.AssertEqual( VarType(bool) , V_BOOLEAN , "VarType(bool) is not V_BOOLEAN" ) + TestUtil.AssertEqual( VarType(var) , V_EMPTY , "VarType(var) is not V_EMPTY" ) + TestUtil.AssertEqual( VarType(byt3) , V_BYTE , "VarType(byt3) is not V_BYTE" ) -Sub DEV_TEST - MsgBox doUnitTest -End Sub + TestUtil.AssertEqual( VarType(int_) , V_INTEGER , "VarType(int_) is not V_INTEGER" ) + TestUtil.AssertEqual( VarType(long_) , V_LONG , "VarType(long_) is not V_LONG" ) + TestUtil.AssertEqual( VarType(single_) , V_SINGLE , "VarType(single_) is not V_SINGLE" ) + TestUtil.AssertEqual( VarType(double_) , V_DOUBLE , "VarType(double_) is not V_CURRENCY" ) + TestUtil.AssertEqual( VarType(currency_), V_CURRENCY, "VarType(currency_) is not V_CURRENCY" ) + TestUtil.AssertEqual( VarType(string_) , V_STRING , "VarType(string_) is not V_STRING" ) -Dim failedAssertion As Boolean, messages As String + TestUtil.AssertEqual( VarType(intArray) , V_ARRAY+V_INTEGER , "VarType(intArray) is not V_ARRAY+V_INTEGER" ) + TestUtil.AssertEqual( VarType(lngArray) , V_ARRAY+V_LONG , "VarType(lngArray) is not V_ARRAY+V_LONG" ) + TestUtil.AssertEqual( VarType(sngArray) , V_ARRAY+V_SINGLE , "VarType(sngArray) is not V_ARRAY+V_SINGLE" ) + TestUtil.AssertEqual( VarType(dblArray) , V_ARRAY+V_DOUBLE , "VarType(dblArray) is not V_ARRAY+V_DOUBLE" ) + TestUtil.AssertEqual( VarType(curArray) , V_ARRAY+V_CURRENCY, "VarType(curArray) is not V_ARRAY+V_CURRENCY" ) + TestUtil.AssertEqual( VarType(datArray) , V_ARRAY+V_DATE , "VarType(datArray) is not V_ARRAY+V_DATE" ) + TestUtil.AssertEqual( VarType(strArray) , V_ARRAY+V_STRING , "VarType(strArray) is not V_ARRAY+V_STRING" ) + TestUtil.AssertEqual( VarType(objArray) , V_ARRAY+V_OBJECT , "VarType(objArray) is not V_ARRAY+V_OBJECT" ) + 'TestUtil.AssertEqual( VarType(***Array) , V_ARRAY+V_ERROR , "VarType(***Array) is not V_ARRAY+V_ERROR" ) + TestUtil.AssertEqual( VarType(boolArray), V_ARRAY+V_BOOLEAN , "VarType(boolArray) is not V_ARRAY+V_BOOLEAN" ) + TestUtil.AssertEqual( VarType(varArray) , V_ARRAY+V_VARIANT , "VarType(varArray) is not V_ARRAY+V_VARIANT" ) + TestUtil.AssertEqual( VarType(byteArray), V_ARRAY+V_BYTE , "VarType(byteArray) is not V_ARRAY+V_BYTE" ) -Sub assert(expression As Boolean, errMessage As String) - If ( Not expression ) Then - messages = messages + Chr(10) + ErrMessage - failedAssertion = True - EndIf + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testvartype", Err, Error$, Erl) End Sub diff --git a/basic/qa/basic_coverage/test_wait_method.vb b/basic/qa/basic_coverage/test_wait_method.vb index 776a2efadffa..8df9ab4b9263 100644 --- a/basic/qa/basic_coverage/test_wait_method.vb +++ b/basic/qa/basic_coverage/test_wait_method.vb @@ -5,8 +5,8 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String ' WAIT Wait(0) - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/basic_coverage/test_weekday_method.vb b/basic/qa/basic_coverage/test_weekday_method.vb index 48279434dd78..c37d3a8b6fad 100644 --- a/basic/qa/basic_coverage/test_weekday_method.vb +++ b/basic/qa/basic_coverage/test_weekday_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' WEEKDAY If ( Weekday( aDate ) <> WeekDay( aDate ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/test_year_method.vb b/basic/qa/basic_coverage/test_year_method.vb index 0863e11b35fe..1aebe07028b8 100644 --- a/basic/qa/basic_coverage/test_year_method.vb +++ b/basic/qa/basic_coverage/test_year_method.vb @@ -6,13 +6,13 @@ ' file, You can obtain one at http://mozilla.org/MPL/2.0/. ' -Function doUnitTest as Integer +Function doUnitTest as String dim aDate as Date aDate = Date() ' YEAR If ( DatePart( "yyyy", aDate ) <> Year( aDate ) ) Then - doUnitTest = 0 + doUnitTest = "FAIL" Else - doUnitTest = 1 + doUnitTest = "OK" End If End Function diff --git a/basic/qa/basic_coverage/uno_struct_assign.vb b/basic/qa/basic_coverage/uno_struct_assign.vb index 23812de2cd6a..15e94e0ac257 100644 --- a/basic/qa/basic_coverage/uno_struct_assign.vb +++ b/basic/qa/basic_coverage/uno_struct_assign.vb @@ -7,9 +7,9 @@ ' -Function doUnitTest as Integer +Function doUnitTest as String Dim oNamedValue as new com.sun.star.beans.NamedValue Dim oCellAddress as new com.sun.star.table.CellAddress oNamedValue.Value = oCellAddress ' fdo#60065 - this would throw an error - doUnitTest = 1 + doUnitTest = "OK" End Function diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx index 856736b293be..584add2cdc9a 100644 --- a/basic/qa/cppunit/basic_coverage.cxx +++ b/basic/qa/cppunit/basic_coverage.cxx @@ -18,17 +18,11 @@ namespace class Coverage : public test::BootstrapFixture { private: - int m_nb_tests_ok; - OUString m_sCurrentTest; void process_directory(const OUString& sDirName); - void run_test(const OUString& sFileName); - void test_failed(); - void test_success(); std::vector< OUString > get_subdirnames( const OUString& sDirName ); public: Coverage(); - virtual ~Coverage() override; void Coverage_Iterator(); @@ -44,52 +38,9 @@ public: Coverage::Coverage() : BootstrapFixture(true, false) - , m_nb_tests_ok(0) { } -Coverage::~Coverage() -{ - fprintf(stderr,"basic coverage Summary : pass:%d\n", m_nb_tests_ok ); -} - -void Coverage::test_failed() -{ - CPPUNIT_FAIL( - OUStringToOString(m_sCurrentTest, RTL_TEXTENCODING_UTF8).getStr()); -} - -void Coverage::test_success() -{ - m_nb_tests_ok += 1; - fprintf(stderr,"%s,PASS\n", OUStringToOString( m_sCurrentTest, RTL_TEXTENCODING_UTF8 ).getStr() ); -} - -void Coverage::run_test(const OUString& sFileURL) -{ - m_sCurrentTest = sFileURL; - bool bResult = false; - MacroSnippet testMacro; - testMacro.LoadSourceFromFile("TestModule", sFileURL); - testMacro.Compile(); - if( !testMacro.HasError() ) - { - SbxVariableRef pResult = testMacro.Run(); - if( pResult.is() && pResult->GetInteger() == 1 ) - { - bResult = true; - } - } - if(bResult) - { - test_success(); - } - else - { - test_failed(); - } -} - std::vector< OUString > Coverage::get_subdirnames( const OUString& sDirName ) { std::vector< OUString > sSubDirNames; @@ -113,6 +64,7 @@ void Coverage::process_directory(const OUString& sDirName) osl::Directory aDir(sDirName); osl::DirectoryItem aItem; osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); + OUString sMacroUtilsURL = m_directories.getURLFromSrc(u"basic/qa/basic_coverage/") + "_test_asserts.vb"; if(aDir.open() == osl::FileBase::E_None) { @@ -121,7 +73,20 @@ void Coverage::process_directory(const OUString& sDirName) aItem.getFileStatus(aFileStatus); if(aFileStatus.isRegular()) { - run_test(aFileStatus.getFileURL()); + OUString sFileURL = aFileStatus.getFileURL(); + if(sFileURL.endsWith(".vb") && sFileURL != sMacroUtilsURL) + { + MacroSnippet testMacro; + testMacro.LoadSourceFromFile("TestUtil", sMacroUtilsURL); + testMacro.LoadSourceFromFile("TestModule", sFileURL); + SbxVariableRef pReturn = testMacro.Run(); + CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is()); + fprintf(stderr, "macro result for %s\n", OUStringToOString(sFileURL,RTL_TEXTENCODING_UTF8).getStr()); + fprintf(stderr, "macro returned:\n%s\n", + OUStringToOString(pReturn->GetOUString(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"), + pReturn->GetOUString()); + } } } } @@ -130,7 +95,7 @@ void Coverage::process_directory(const OUString& sDirName) void Coverage::Coverage_Iterator() { - OUString sDirName = m_directories.getURLFromSrc(u"/basic/qa/basic_coverage/"); + OUString sDirName = m_directories.getURLFromSrc(u"basic/qa/basic_coverage"); CPPUNIT_ASSERT(!sDirName.isEmpty()); process_directory(sDirName); // any files in the root test dir are run in test harness default locale ( en-US ) |