diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-12-21 09:00:03 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-12-22 06:18:50 +0100 |
commit | 66b135fa80452144baf57e91a6814b172f8174e2 (patch) | |
tree | d69170bf4a81c7736ea5a57c00dca55c5a7fb834 /basic/qa | |
parent | 8beaafcaa27a66841a9d959eba125ec410d0392d (diff) |
Related: tdf#84098 Unify tests
Shorten the tools module name; use TestUtil.AssertEqual where applicable;
remove unnecessary variables that only made noise and masked what was
actually asserted; add missing licence headers.
Change-Id: If891ed8ceb38fed18335aad061b2b09d341264f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108118
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/qa')
93 files changed, 1772 insertions, 2989 deletions
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx index bbc0b97d98d7..3f0818424a70 100644 --- a/basic/qa/cppunit/test_vba.cxx +++ b/basic/qa/cppunit/test_vba.cxx @@ -158,7 +158,7 @@ void VBATest::testMiscVBAFunctions() + OUString::createFromAscii( macroSource[ i ] ); MacroSnippet myMacro; - myMacro.LoadSourceFromFile("TestUtilModule", sMacroUtilsURL); + myMacro.LoadSourceFromFile("TestUtil", sMacroUtilsURL); myMacro.LoadSourceFromFile("TestModule", sMacroURL); SbxVariableRef pReturn = myMacro.Run(); CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is()); diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb index e04d2cfd5916..914906c342c0 100644 --- a/basic/qa/vba_tests/Err.Raise.vb +++ b/basic/qa/vba_tests/Err.Raise.vb @@ -14,15 +14,14 @@ Function doUnitTest() Const MIN_ERR = &hFFFFFFFF : Const MAX_ERR = 2^31-1 ''' Raise one-to-many User-Defined Errors as signed Int32 ''' - TestUtilModule.TestInit() + TestUtil.TestInit() ' test_Description | Err # | Err_Source | Err_Description Call TestErrRaise("MAXimum error value", MAX_ERR, "doUnitTest.vb", "Custom Error Maximum value") Call TestErrRaise("Positive custom error", 1789, "" , "User-Defined Error Number") Call TestErrRaise("Negative custom error", -1793, "doUnitTest.vb", "Negative User-Defined Error Number") Call TestErrRaise("MINimum error value", MIN_ERR, "" , "Custom Error Minimum value") - TestUtilModule.TestEnd() - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function Sub TestErrRaise(TestName As String, CurErrNo As Long, CurErrSource As String, CurErrDescription As String) @@ -32,23 +31,23 @@ try: On Error Goto catch Dim errorHandled As Integer Err.Raise(CurErrNo, CurErrSource, CurErrDescription, "", "") - TestUtilModule.AssertTrue(errorHandled = 1, TestName, "error handler did not execute!") - TestUtilModule.AssertTrue(Erl = 0, TestName, "Erl = " & Erl) - TestUtilModule.AssertTrue(Err = 0, TestName, "Err = " & Err) - TestUtilModule.AssertTrue(Error = "", TestName, "Error = " & Error) - TestUtilModule.AssertTrue(Err.Description = "", "Err.Description reset", "Err.Description = "& Err.Description) - TestUtilModule.AssertTrue(Err.Number = 0, "Err.Number reset", "Err.Number = " & Err.Number) - TestUtilModule.AssertTrue(Err.Source = "", "Err.Source reset", "Err.Source = " & Err.Source) + TestUtil.Assert(errorHandled = 1, TestName, "error handler did not execute!") + TestUtil.Assert(Erl = 0, TestName, "Erl = " & Erl) + TestUtil.Assert(Err = 0, TestName, "Err = " & Err) + TestUtil.Assert(Error = "", TestName, "Error = " & Error) + TestUtil.Assert(Err.Description = "", "Err.Description reset", "Err.Description = "& Err.Description) + TestUtil.Assert(Err.Number = 0, "Err.Number reset", "Err.Number = " & Err.Number) + TestUtil.Assert(Err.Source = "", "Err.Source reset", "Err.Source = " & Err.Source) Exit Sub catch: - TestUtilModule.AssertTrue(Err.Number = CurErrNo, "Err.Number failure", "Err.Number = " & Err.Number) - TestUtilModule.AssertTrue(Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source) - TestUtilModule.AssertTrue(Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description) + TestUtil.Assert(Err.Number = CurErrNo, "Err.Number failure", "Err.Number = " & Err.Number) + TestUtil.Assert(Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source) + TestUtil.Assert(Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description) - TestUtilModule.AssertTrue(Erl = 33, "line# failure", "Erl = " & Erl ' WATCH OUT for HARDCODED LINE # HERE !) - TestUtilModule.AssertTrue(Err = CurErrNo, "Err# failure", "Err = " & Err) - TestUtilModule.AssertTrue(Error = CurErrDescription, "Error description failure", "Error$ = " & Error$) + TestUtil.Assert(Erl = 32, "line# failure", "Erl = " & Erl ' WATCH OUT for HARDCODED LINE # HERE !) + TestUtil.Assert(Err = CurErrNo, "Err# failure", "Err = " & Err) + TestUtil.Assert(Error = CurErrDescription, "Error description failure", "Error$ = " & Error$) errorHandled = 1 Resume Next ' Err object properties reset from here … diff --git a/basic/qa/vba_tests/_test_asserts.vb b/basic/qa/vba_tests/_test_asserts.vb index 395aafb6f2f7..0f1d0d88610f 100644 --- a/basic/qa/vba_tests/_test_asserts.vb +++ b/basic/qa/vba_tests/_test_asserts.vb @@ -1,4 +1,13 @@ +' +' 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 VBASupport 1 +Option Explicit Dim passCount As Integer Dim failCount As Integer @@ -8,7 +17,7 @@ Function GetResult() If passCount <> 0 and failCount = 0 Then GetResult = "OK" Else - GetResult = result + GetResult = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) End If End Function @@ -18,27 +27,21 @@ Sub TestInit() result = result & "Test Results" & Chr$(10) & "============" & Chr$(10) End Sub -Sub TestEnd() - result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10) -End Sub - -Sub AssertTrue(assertion As Boolean, Optional testId As String, Optional testComment As String) - - If assertion = True Then +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 = testMsg + " : " + testId + testMsg = " " + testId End If If Not IsMissing(testComment) And Not (testComment = "") Then testMsg = testMsg + " (" + testComment + ")" End If - result = result & Chr$(10) & " Failed: " & testMsg + result = result & Chr$(10) & " Failed:" & testMsg failCount = failCount + 1 End If - End Sub Sub AssertEqual(actual As Variant, expected As Variant, testName As String) @@ -49,3 +52,16 @@ Sub AssertEqual(actual As Variant, expected As Variant, testName As String) failCount = failCount + 1 End If End Sub + +Sub AssertEqualApprox(actual, expected, epsilon, testName As String) + If Abs(expected - actual) <= epsilon Then + passCount = passCount + 1 + Else + result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected & ", epsilon " & epsilon + 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/vba_tests/abs.vb b/basic/qa/vba_tests/abs.vb index f38baf149e60..c6f1b8fff901 100644 --- a/basic/qa/vba_tests/abs.vb +++ b/basic/qa/vba_tests/abs.vb @@ -1,38 +1,29 @@ +' +' 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/. +' + Rem Attribute VBA_ModuleType=VBAModule Option VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testABS -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testABS + doUnitTest = TestUtil.GetResult() End Function Sub verify_testABS() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Double - - testName = "Test ABS function" On Error GoTo errorHandler - nr2 = 5 - nr1 = Abs(-5) - TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1) - - nr2 = 5 - nr1 = Abs(5) - TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1) - - nr2 = 21.7 - nr1 = Abs(-21.7) - TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Abs(-5), 5, "Abs(-5)") + TestUtil.AssertEqual(Abs(5), 5, "Abs(5)") + TestUtil.AssertEqual(Abs(-21.7), 21.7, "Abs(-21.7)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testABS", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/array.vb b/basic/qa/vba_tests/array.vb index 0390e77c37ec..608974462b2c 100644 --- a/basic/qa/vba_tests/array.vb +++ b/basic/qa/vba_tests/array.vb @@ -1,3 +1,11 @@ +' +' 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/. +' + Rem Attribute VBA_ModuleType=VBAModule Option VBASupport 1 Option Explicit @@ -8,59 +16,33 @@ Type MyType End Type Function doUnitTest() As String -verify_testARRAY -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testARRAY + doUnitTest = TestUtil.GetResult() End Function Sub verify_testARRAY() - - TestUtilModule.TestInit - - Dim testName As String - Dim a, b, C As Variant - a = Array(10, 20, 30) - testName = "Test ARRAY function" On Error GoTo errorHandler - b = 10 - C = a(0) - TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C) - - b = 20 - C = a(1) - TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C) - - b = 30 - C = a(2) - TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C) + Dim a + a = Array(10, 20, 30) + TestUtil.AssertEqual(a(0), 10, "a(0)") + TestUtil.AssertEqual(a(1), 20, "a(1)") + TestUtil.AssertEqual(a(2), 30, "a(2)") - Dim MyWeek, MyDay + Dim MyWeek MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") + TestUtil.AssertEqual(MyWeek(1), "Tue", "MyWeek(1)") + TestUtil.AssertEqual(MyWeek(3), "Thu", "MyWeek(3)") - b = "Tue" - MyDay = MyWeek(1) ' MyDay contains "Tue". - TestUtilModule.AssertTrue(b = MyDay, "the return ARRAY is: " & MyDay) - - b = "Thu" - MyDay = MyWeek(3) ' MyDay contains "Thu". - TestUtilModule.AssertTrue(b = MyDay, "the return ARRAY is: " & MyDay) - -Dim mt As MyType + Dim mt As MyType mt.ax(0) = 42 mt.ax(1) = 43 mt.bx = 3.14 - b = 43 - C = mt.ax(1) - TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C) - - b = 3.14 - C = mt.bx - TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(mt.ax(1), 43, "mt.ax(1)") + TestUtil.AssertEqual(mt.bx, 3.14, "mt.bx") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testARRAY", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/asc.vb b/basic/qa/vba_tests/asc.vb index 3ac2ec69987e..8da24e349ecd 100644 --- a/basic/qa/vba_tests/asc.vb +++ b/basic/qa/vba_tests/asc.vb @@ -1,38 +1,29 @@ +' +' 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/. +' + Rem Attribute VBA_ModuleType=VBAModule Option VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testASC -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testASC + doUnitTest = TestUtil.GetResult() End Function Sub verify_testASC() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Double - - testName = "Test ASC function" On Error GoTo errorHandler - nr2 = 65 - nr1 = Asc("A") - TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1) - - nr2 = 97 - nr1 = Asc("a") - TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1) - - nr2 = 65 - nr1 = Asc("Apple") - TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Asc("A"), 65, "Asc(""A"")") + TestUtil.AssertEqual(Asc("a"), 97, "Asc(""a"")") + TestUtil.AssertEqual(Asc("Apple"), 65, "Asc(""Apple"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testASC", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/atn.vb b/basic/qa/vba_tests/atn.vb index 46d49c3e12e3..826165e296a5 100644 --- a/basic/qa/vba_tests/atn.vb +++ b/basic/qa/vba_tests/atn.vb @@ -1,44 +1,30 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testATN -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testATN + doUnitTest = TestUtil.GetResult() End Function Sub verify_testATN() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Double - testName = "Test ATN function" On Error GoTo errorHandler - nr2 = 1.10714871779409 - nr1 = Atn(2) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1) - - nr2 = 1.19166451926354 - nr1 = Atn(2.51) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1) - - nr2 = -1.27229739520872 - nr1 = Atn(-3.25) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1) - - nr2 = 1.56603445802574 - nr1 = Atn(210) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1) - - nr2 = 0 - nr1 = Atn(0) - TestUtilModule.AssertTrue(nr1 = nr2, "the return ATN is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Atn(2), 1.10714871779409, 1E-14, "Atn(2)") + TestUtil.AssertEqualApprox(Atn(2.51), 1.19166451926354, 1E-14, "Atn(2.51)") + TestUtil.AssertEqualApprox(Atn(-3.25), -1.27229739520872, 1E-14, "Atn(-3.25)") + TestUtil.AssertEqualApprox(Atn(210), 1.56603445802574, 1E-14, "Atn(210)") + TestUtil.AssertEqual (Atn(0), 0, "Atn(0)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testATN", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/bytearraystring.vb b/basic/qa/vba_tests/bytearraystring.vb index 2a1bc4da63d5..6218716936f2 100644 --- a/basic/qa/vba_tests/bytearraystring.vb +++ b/basic/qa/vba_tests/bytearraystring.vb @@ -1,36 +1,36 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String + TestUtil.TestInit verify_ByteArrayString - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function Sub verify_ByteArrayString() - Dim testName As String Dim MyString As String Dim x() As Byte - Dim count As Integer - testName = "Test the conversion between bytearray and string" On Error GoTo errorHandler MyString = "abc" x = MyString ' string -> byte array - TestUtilModule.TestInit - - count = UBound(x) ' 6 byte - ' test bytes in string - TestUtilModule.AssertEqual((count), 5, "test1 numbytes ") + TestUtil.AssertEqual(UBound(x), 5, "UBound(x)") MyString = x 'byte array -> string - TestUtilModule.AssertEqual(MyString, "abc", "test assign byte array to string") + TestUtil.AssertEqual(MyString, "abc", "MyString") - TestUtilModule.TestEnd Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$) - TestUtilModule.TestEnd + TestUtil.ReportErrorHandler("verify_ByteArrayString", Err, Error$, Erl) End Sub diff --git a/basic/qa/vba_tests/cbool.vb b/basic/qa/vba_tests/cbool.vb index 842c494e742e..54334a23ebd6 100644 --- a/basic/qa/vba_tests/cbool.vb +++ b/basic/qa/vba_tests/cbool.vb @@ -1,72 +1,40 @@ +' +' 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 VBASupport 1 -Rem Option VBASupport 1 'unREM in .vb file Option Explicit Function doUnitTest() As String -verify_testCBool -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCBool + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCBool() - - TestUtilModule.TestInit - - Dim testName As String - Dim res2, res1 As Boolean - Dim a1, a2 As Integer - testName = "Test CBool function" On Error GoTo errorHandler - res2 = True - res1 = CBool(1) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = False - res1 = CBool(1 = 2) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = False - res1 = CBool(0) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = True - res1 = CBool(21) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = True - res1 = CBool("true") - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) + TestUtil.AssertEqual(CBool(1), True, "CBool(1)") + TestUtil.AssertEqual(CBool(1 = 2), False, "CBool(1 = 2)") + TestUtil.AssertEqual(CBool(0), False, "CBool(0)") + TestUtil.AssertEqual(CBool(21), True, "CBool(21)") + TestUtil.AssertEqual(CBool("true"), True, "CBool(""true"")") + TestUtil.AssertEqual(CBool("false"), False, "CBool(""false"")") + TestUtil.AssertEqual(CBool("1"), True, "CBool(""1"")") + TestUtil.AssertEqual(CBool("-1"), True, "CBool(""-1"")") + TestUtil.AssertEqual(CBool("0"), False, "CBool(""0"")") - res2 = False - res1 = CBool("false") - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = True - res1 = CBool("1") - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = True - res1 = CBool("-1") - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = False - res1 = CBool("0") - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = False + Dim a1, a2 As Integer a1 = 1: a2 = 10 - res1 = CBool(a1 = a2) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - res2 = True + TestUtil.AssertEqual(CBool(a1 = a2), False, "CBool(a1 = a2)") a1 = 10: a2 = 10 - res1 = CBool(a1 = a2) - TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CBool(a1 = a2), True, "CBool(a1 = a2)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCBool", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cdate.vb b/basic/qa/vba_tests/cdate.vb index 657094acfdfc..227c29d0f74a 100644 --- a/basic/qa/vba_tests/cdate.vb +++ b/basic/qa/vba_tests/cdate.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCDate -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCDate + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCDate() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Date 'variables for test - testName = "Test CDate function" On Error GoTo errorHandler - date2 = 25246 - date1 = CDate("12/02/1969") '02/12/1969 - TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1) - - date2 = 28313 - date1 = CDate("07/07/1977") - TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1) - - date2 = 28313 - date1 = CDate(#7/7/1977#) - TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CDate("12/02/1969"), 25246, "CDate(""12/02/1969"")") + TestUtil.AssertEqual(CDate("07/07/1977"), 28313, "CDate(""07/07/1977"")") + TestUtil.AssertEqual(CDate(#7/7/1977#), 28313, "CDate(#7/7/1977#)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCDate", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cdbl.vb b/basic/qa/vba_tests/cdbl.vb index ec98219cee63..f29271f082d6 100644 --- a/basic/qa/vba_tests/cdbl.vb +++ b/basic/qa/vba_tests/cdbl.vb @@ -1,40 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCdbl -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCdbl + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCdbl() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Double 'variables for test - testName = "Test Cdbl function" On Error GoTo errorHandler - nr2 = 0 - nr1 = CDbl(0) - TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1) - - nr2 = 10.1234567890123 - nr1 = CDbl(10.1234567890123) - TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1) - - nr2 = 0.00005 - nr1 = CDbl(0.005 * 0.01) - TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1) - - nr2 = 20 - nr1 = CDbl("20") - TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CDbl(0), 0, "CDbl(0)") + TestUtil.AssertEqual(CDbl(10.1234567890123), 10.1234567890123, "CDbl(10.1234567890123)") + TestUtil.AssertEqual(CDbl(0.005 * 0.01), 0.00005, "CDbl(0.005 * 0.01)") + TestUtil.AssertEqual(CDbl("20"), 20, "CDbl(""20"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCdbl", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cdec.vb b/basic/qa/vba_tests/cdec.vb index 887d22b2445e..043625683557 100644 --- a/basic/qa/vba_tests/cdec.vb +++ b/basic/qa/vba_tests/cdec.vb @@ -1,58 +1,41 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCDec -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCDec + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCDec() - - TestUtilModule.TestInit - - Dim testName As String - Dim ret As Double - testName = "Test CDec function" On Error GoTo errorHandler - ret = CDec("") - TestUtilModule.AssertTrue(ret = 0, "Empty string test:" & ret) - - ret = CDec("1234") - TestUtilModule.AssertTrue(ret = 1234, "Simple number:" & ret) - - ret = CDec(" 1234 ") - TestUtilModule.AssertTrue(ret = 1234, "Simple number with whitespaces:" & ret) - - ret = CDec("-1234") - TestUtilModule.AssertTrue(ret = -1234, "Simple negative number:" & ret) - - ret = CDec(" - 1234 ") - TestUtilModule.AssertTrue(ret = -1234, "Simple negative number with whitespaces:" & ret) + TestUtil.AssertEqual(CDec(""), 0, "CDec("""")") + TestUtil.AssertEqual(CDec("1234"), 1234, "CDec(""1234"")") + TestUtil.AssertEqual(CDec(" 1234 "), 1234, "CDec("" 1234 "")") + TestUtil.AssertEqual(CDec("-1234"), -1234, "CDec(""-1234"")") + TestUtil.AssertEqual(CDec(" - 1234 "), -1234, "CDec("" - 1234 "")") ''''''''''''''' ' Those are erroneous, see i#64348 - ret = CDec("1234-") - TestUtilModule.AssertTrue(ret = -1234, "Wrong negative number1:" & ret) - - ret = CDec(" 1234 -") - TestUtilModule.AssertTrue(ret = -1234, "Wrong negative number2:" & ret) - - 'ret = CDec("79228162514264300000000000001") - 'TestUtilModule.AssertTrue(ret = 79228162514264300000000000001, "Very long number1:" & ret) - 'ret = ret+1 - 'TestUtilModule.AssertTrue(ret = 79228162514264300000000000002, "Very long number2:" & ret) + TestUtil.AssertEqual(CDec("1234-"), -1234, "CDec(""1234-"")") + TestUtil.AssertEqual(CDec(" 1234 -"), -1234, "CDec("" 1234 -"")") - ret = CDec("79228162514264400000000000000") - TestUtilModule.AssertTrue(ret = 62406456049664, "Very long number3:" & ret) + 'TestUtil.AssertEqual(CDec("79228162514264300000000000001"), 79228162514264300000000000001, "CDec(""79228162514264300000000000001"")") + 'TestUtil.AssertEqual(CDec("79228162514264300000000000001") + 1, 79228162514264300000000000002, "CDec(""79228162514264300000000000001"") + 1") - ret = CDec("79228162514264340000000000000") ' gives zero - TestUtilModule.AssertTrue(ret = 0, "Very long number4:" & ret) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CDec("79228162514264400000000000000"), 62406456049664, "CDec(""79228162514264400000000000000"")") + TestUtil.AssertEqual(CDec("79228162514264340000000000000"), 0, "CDec(""79228162514264340000000000000"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCDec", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/choose.vb b/basic/qa/vba_tests/choose.vb index d63fe1331094..b258af984d69 100644 --- a/basic/qa/vba_tests/choose.vb +++ b/basic/qa/vba_tests/choose.vb @@ -1,46 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testChoose -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testChoose + doUnitTest = TestUtil.GetResult() End Function Sub verify_testChoose() - - TestUtilModule.TestInit - - Dim testName As String - Dim var1, var2 - testName = "Test Choose function" - On Error GoTo errorHandler - var2 = "Libre" - var1 = Choose(1, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1) - - var2 = "Office" - var1 = Choose(2, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1) - - var2 = "Suite" - var1 = Choose(3, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1) - - var1 = Choose(4, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null4 " ) - - var1 = Choose(0, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null0 " ) - - var1 = Choose(-1, "Libre", "Office", "Suite") - TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null-1") - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Choose(1, "Libre", "Office", "Suite"), "Libre", "Choose(1, ""Libre"", ""Office"", ""Suite"")") + TestUtil.AssertEqual(Choose(2, "Libre", "Office", "Suite"), "Office", "Choose(2, ""Libre"", ""Office"", ""Suite"")") + TestUtil.AssertEqual(Choose(3, "Libre", "Office", "Suite"), "Suite", "Choose(3, ""Libre"", ""Office"", ""Suite"")") + TestUtil.Assert(IsNull(Choose(4, "Libre", "Office", "Suite")), "IsNull(Choose(4, ""Libre"", ""Office"", ""Suite""))") + TestUtil.Assert(IsNull(Choose(0, "Libre", "Office", "Suite")), "IsNull(Choose(0, ""Libre"", ""Office"", ""Suite""))") + TestUtil.Assert(IsNull(Choose(-1, "Libre", "Office", "Suite")), "IsNull(Choose(-1, ""Libre"", ""Office"", ""Suite""))") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testChoose", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb index 73590ea661ed..a561d7cd6545 100644 --- a/basic/qa/vba_tests/chr.vb +++ b/basic/qa/vba_tests/chr.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCHR -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCHR + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCHR() - - TestUtilModule.TestInit - - Dim testName As String - Dim str1, str2 As String - testName = "Test CHR function" On Error GoTo errorHandler - str2 = "W" - str1 = Chr(87) - TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1) - - str2 = "i" - str1 = Chr(105) - TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1) - - str2 = "#" - str1 = Chr(35) - TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Chr(87), "W", "Chr(87)") + TestUtil.AssertEqual(Chr(105), "i", "Chr(105)") + TestUtil.AssertEqual(Chr(35), "#", "Chr(35)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCHR", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cint.vb b/basic/qa/vba_tests/cint.vb index 70387503c789..42e41e53568f 100644 --- a/basic/qa/vba_tests/cint.vb +++ b/basic/qa/vba_tests/cint.vb @@ -1,73 +1,42 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCInt -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCInt + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCInt() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Integer 'variables for test - testName = "Test CInt function" - On Error GoTo errorHandler - nr2 = -1 - nr1 = CInt(-1.1) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = -1 - nr1 = CInt(-1.1) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = -2 - nr1 = CInt(-1.9) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = 0 - nr1 = CInt(0.2) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) + TestUtil.AssertEqual(CInt(-1.1), -1, "CInt(-1.1)") + TestUtil.AssertEqual(CInt(-1.1), -1, "CInt(-1.1)") + TestUtil.AssertEqual(CInt(-1.9), -2, "CInt(-1.9)") + TestUtil.AssertEqual(CInt(0.2), 0, "CInt(0.2)") REM In excel: REM If the fraction is less than or equal to .5, the result will round down. REM If the fraction is greater than .5, the result will round up. -REM nr2 = 0 -REM nr1 = CInt(0.5) -REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) +REM TestUtil.AssertEqual(CInt(0.5), 0, "CInt(0.5)") +REM TestUtil.AssertEqual(CInt(1.5), 2, "CInt(1.5)") +REM TestUtil.AssertEqual(CInt(2.5), 2, "CInt(2.5)") -REM nr2 = 2 -REM nr1 = CInt(1.5) -REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - -REM nr2 = 2 -REM nr1 = CInt(2.5) -REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = 11 - nr1 = CInt(10.51) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = 30207 - nr1 = CInt("&H75FF") - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = 1876 - nr1 = CInt("&H754") - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1) - - nr2 = 21 - nr1 = CInt("+21") - TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is:" & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CInt(10.51), 11, "CInt(10.51)") + TestUtil.AssertEqual(CInt("&H75FF"), 30207, "CInt(""&H75FF"")") + TestUtil.AssertEqual(CInt("&H754"), 1876, "CInt(""&H754"")") + TestUtil.AssertEqual(CInt("+21"), 21, "CInt(""+21"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCInt", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/clng.vb b/basic/qa/vba_tests/clng.vb index 868553233d78..ae9421686d34 100644 --- a/basic/qa/vba_tests/clng.vb +++ b/basic/qa/vba_tests/clng.vb @@ -1,60 +1,37 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCLng -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCLng + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCLng() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Long 'variables for test - testName = "Test CLng function" - On Error GoTo errorHandler - nr2 = -1 - nr1 = CLng(-1.1) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - - nr2 = -1 - nr1 = CLng(-1.1) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - - nr2 = -2 - nr1 = CLng(-1.9) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) + TestUtil.AssertEqual(CLng(-1.1), -1, "CLng(-1.1)") + TestUtil.AssertEqual(CLng(-1.9), -2, "CLng(-1.9)") + TestUtil.AssertEqual(CLng(0.2), 0, "CLng(0.2)") - nr2 = 0 - nr1 = CLng(0.2) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - -REM nr2 = 0 -REM nr1 = CLng(0.5) -REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) +REM TestUtil.AssertEqual(CLng(0.5), 0, "CLng(0.5)") REM If the fraction is less than or equal to .5, the result will round down. REM If the fraction is greater than .5, the result will round up. - nr2 = 11 - nr1 = CLng(10.51) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - - nr2 = 30207 - nr1 = CLng("&H75FF") - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - - nr2 = 1876 - nr1 = CLng("&H754") - TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CLng(10.51), 11, "CLng(10.51)") + TestUtil.AssertEqual(CLng("&H75FF"), 30207, "CLng(""&H75FF"")") + TestUtil.AssertEqual(CLng("&H754"), 1876, "CLng(""&H754"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCLng", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb index 445e6f85f87b..d03fdda95afe 100644 --- a/basic/qa/vba_tests/constants.vb +++ b/basic/qa/vba_tests/constants.vb @@ -1,29 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testConstants -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testConstants + doUnitTest = TestUtil.GetResult() End Function Sub verify_testConstants() - - TestUtilModule.TestInit - - Dim testName As String - testName = "Test Constants" On Error GoTo errorHandler + ' vbNewLine is the same as vbCrLf on Windows, and the same as vbLf on other OSes If GetGuiType() = 1 Then - TestUtilModule.AssertTrue(vbNewline = vbCrLf, "vbNewLine is the same as vbCrLf on Windows") + TestUtil.AssertEqual(vbNewline, vbCrLf, "vbNewline") Else - TestUtilModule.AssertTrue(vbNewLine = vbLf, "vbNewLine is the same as vbLf on others than Windows") + TestUtil.AssertEqual(vbNewLine, vbLf, "vbNewline") End If - TestUtilModule.TestEnd - Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testConstants", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cos.vb b/basic/qa/vba_tests/cos.vb index 965767e89551..2dc88df31ecb 100644 --- a/basic/qa/vba_tests/cos.vb +++ b/basic/qa/vba_tests/cos.vb @@ -1,37 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCOS -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCOS + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCOS() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Double 'variables for test - testName = "Test COS function" - On Error GoTo errorHandler - nr2 = -0.532833020333398 - nr1 = Cos(23) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1) - - nr2 = 0.980066577841242 - nr1 = Cos(0.2) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1) - - nr2 = 0.487187675007006 - nr1 = Cos(200) - TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Cos(23), -0.532833020333398, 1E-14, "Cos(23)") + TestUtil.AssertEqualApprox(Cos(0.2), 0.980066577841242, 1E-14, "Cos(0.2)") + TestUtil.AssertEqualApprox(Cos(200), 0.487187675007006, 1E-14, "Cos(200)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCOS", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/csng.vb b/basic/qa/vba_tests/csng.vb index 95ab5853c741..3e18d0282b81 100644 --- a/basic/qa/vba_tests/csng.vb +++ b/basic/qa/vba_tests/csng.vb @@ -1,39 +1,36 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCSng -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCSng + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCSng() - - TestUtilModule.TestInit - - Dim testName As String - Dim nr1, nr2 As Single 'variables for test - Dim nr3 As Double - - testName = "Test CSng function" + Dim nr1 As Single 'variables for test + Dim nr2 As Double On Error GoTo errorHandler - nr2 = 8.534535408 - nr1 = CSng(8.534535408) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1) + nr1 = 8.534535408 + TestUtil.AssertEqual(CSng(8.534535408), nr1, "CSng(8.534535408)") - nr3 = 100.1234 nr2 = 100.1234 - nr1 = CSng(nr3) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1) - - nr2 = 0 - nr1 = CSng(0) - TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1) + nr1 = 100.1234 + TestUtil.AssertEqual(CSng(nr2), nr1, "CSng(nr2)") - TestUtilModule.TestEnd + nr1 = 0 + TestUtil.AssertEqual(CSng(0), nr1, "CSng(0)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCSng", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cstr.vb b/basic/qa/vba_tests/cstr.vb index d72a5d6d5cc5..55e1ab049fab 100644 --- a/basic/qa/vba_tests/cstr.vb +++ b/basic/qa/vba_tests/cstr.vb @@ -1,34 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCStr -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCStr + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCStr() - - TestUtilModule.TestInit - - Dim testName As String - Dim str2, str3 - Dim str1 As String 'variables for test - testName = "Test CStr function" On Error GoTo errorHandler - str3 = 437.324 - str2 = "437.324" - str1 = CStr(str3) - TestUtilModule.AssertTrue(str1 = str2, "the return CStr is: " & str1) - - str2 = "500" - str1 = CStr(500) - TestUtilModule.AssertTrue(str1 = str2, "the return CStr is: " & str1) - - TestUtilModule.TestEnd + Dim n + n = 437.324 + TestUtil.AssertEqual(CStr(n), "437.324", "CStr(n)") + TestUtil.AssertEqual(CStr(500), "500", "CStr(500)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCStr", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/cvdate.vb b/basic/qa/vba_tests/cvdate.vb index e9c1285df5d9..0b71d7fe997c 100644 --- a/basic/qa/vba_tests/cvdate.vb +++ b/basic/qa/vba_tests/cvdate.vb @@ -1,36 +1,30 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCVDate -' SKIPPED test due to CVDate not being available -'doUnitTest = TestUtilModule.GetResult() -doUnitTest = "OK" + TestUtil.TestInit + verify_testCVDate + ' SKIPPED test due to CVDate not being available + 'doUnitTest = TestUtil.GetResult() + doUnitTest = "OK" End Function Sub verify_testCVDate() - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Date 'variables for test - testName = "Test CVDate function" On Error GoTo errorHandler - date2 = 25246 - date1 = CVDate("12.2.1969") '2/12/1969 - TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1) - - date2 = 28313 - date1 = CVDate("07/07/1977") - TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1) - - date2 = 28313 - date1 = CVDate(#7/7/1977#) - TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(CVDate("12.2.1969"), 25246, "CVDate(""12.2.1969"")") + TestUtil.AssertEqual(CVDate("07/07/1977"), 28313, "CVDate(""07/07/1977"")") + TestUtil.AssertEqual(CVDate(#7/7/1977#), 28313, "CVDate(#7/7/1977#)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$) + TestUtil.ReportErrorHandler("verify_testCVDate", Err, Error$, Erl) End Sub diff --git a/basic/qa/vba_tests/cverr.vb b/basic/qa/vba_tests/cverr.vb index 0191c2018963..3a314de7617e 100644 --- a/basic/qa/vba_tests/cverr.vb +++ b/basic/qa/vba_tests/cverr.vb @@ -1,62 +1,40 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testCVErr -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testCVErr + doUnitTest = TestUtil.GetResult() End Function Sub verify_testCVErr() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test CVErr function" On Error GoTo errorHandler - date2 = "Error 3001" - date1 = CStr(CVErr(3001)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2007" - date1 = CStr(CVErr(xlErrDiv0)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2042" - date1 = CStr(CVErr(xlErrNA)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2029" - date1 = CStr(CVErr(xlErrName)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2000" - date1 = CStr(CVErr(xlErrNull)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2036" - date1 = CStr(CVErr(xlErrNum)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2023" - date1 = CStr(CVErr(xlErrRef)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) - - date2 = "Error 2015" - date1 = CStr(CVErr(xlErrValue)) - TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1) + TestUtil.AssertEqual(CStr(CVErr(3001)), "Error 3001", "CStr(CVErr(3001))") + TestUtil.AssertEqual(CStr(CVErr(xlErrDiv0)), "Error 2007", "CStr(CVErr(xlErrDiv0))") + TestUtil.AssertEqual(CStr(CVErr(xlErrNA)), "Error 2042", "CStr(CVErr(xlErrNA))") + TestUtil.AssertEqual(CStr(CVErr(xlErrName)), "Error 2029", "CStr(CVErr(xlErrName))") + TestUtil.AssertEqual(CStr(CVErr(xlErrNull)), "Error 2000", "CStr(CVErr(xlErrNull))") + TestUtil.AssertEqual(CStr(CVErr(xlErrNum)), "Error 2036", "CStr(CVErr(xlErrNum))") + TestUtil.AssertEqual(CStr(CVErr(xlErrRef)), "Error 2023", "CStr(CVErr(xlErrRef))") + TestUtil.AssertEqual(CStr(CVErr(xlErrValue)), "Error 2015", "CStr(CVErr(xlErrValue))") ' tdf#79426 - passing an error object to a function - TestUtilModule.AssertTrue(TestCVErr( CVErr( 2 ) ) = 2) + TestUtil.AssertEqual(TestCVErr(CVErr(2)), 2, "TestCVErr(CVErr(2))") ' tdf#79426 - test with Error-Code 448 ( ERRCODE_BASIC_NAMED_NOT_FOUND ) - TestUtilModule.AssertTrue(TestCVErr( CVErr( 448 ) ) = 448) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(TestCVErr(CVErr(448)), 448, "TestCVErr(CVErr(448))") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testCVErr", Err, Error$, Erl) End Sub Function TestCVErr(vErr As Variant) @@ -64,4 +42,3 @@ Function TestCVErr(vErr As Variant) nValue = vErr TestCVErr = nValue End Function - diff --git a/basic/qa/vba_tests/dateadd.vb b/basic/qa/vba_tests/dateadd.vb index 1326f9f614a2..8b0e6312e985 100644 --- a/basic/qa/vba_tests/dateadd.vb +++ b/basic/qa/vba_tests/dateadd.vb @@ -1,82 +1,40 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testDateAdd -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testDateAdd + doUnitTest = TestUtil.GetResult() End Function Sub verify_testDateAdd() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Date 'variables for test - testName = "Test DateAdd function" On Error GoTo errorHandler - date2 = CDate("1995-02-28") - date1 = DateAdd("m", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-02-28") - date1 = DateAdd("m", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-02-28") - date1 = DateAdd("m", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1996-01-31") - date1 = DateAdd("yyyy", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-04-30") - date1 = DateAdd("q", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-02-01") - date1 = DateAdd("y", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) + TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("yyyy", 1, "1995-01-31"), CDate("1996-01-31"), "DateAdd(""yyyy"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("q", 1, "1995-01-31"), CDate("1995-04-30"), "DateAdd(""q"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("y", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""y"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("d", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""d"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("w", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""w"", 1, ""1995-01-31"")") + TestUtil.AssertEqual(DateAdd("ww", 1, "1995-01-31"), CDate("1995-02-07"), "DateAdd(""ww"", 1, ""1995-01-31"")") - date2 = CDate("1995-02-01") - date1 = DateAdd("d", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) +Rem This fails when directly comparing using AssertEqual, probably due to rounding. + TestUtil.AssertEqualApprox(DateAdd("h", 1, "1995-01-01 21:48:29"), CDate("1995-01-01 22:48:29"), 1E-10, "DateAdd(""h"", 1, ""1995-01-01 21:48:29"")") - date2 = CDate("1995-02-01") - date1 = DateAdd("w", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-02-07") - date1 = DateAdd("ww", 1, "1995-01-31") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - -Rem This fails when directly comparing date1=date2, probably due to rounding. -Rem Workaround convert to string which does the rounding. - Dim date1s, date2s As String - date2 = CDate("1995-01-01 22:48:29") - date1 = DateAdd("h", 1, "1995-01-01 21:48:29") - date1s = "" & date1 - date2s = "" & date2 - TestUtilModule.AssertTrue(date1s = date2s, "the return DateAdd is: " & date1) - - date2 = CDate("1995-01-31 21:49:29") - date1 = DateAdd("n", 1, "1995-01-31 21:48:29") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - - date2 = CDate("1995-01-31 21:48:30") - date1 = DateAdd("s", 1, "1995-01-31 21:48:29") - TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1) - -exitFunc: - TestUtilModule.TestEnd + TestUtil.AssertEqual(DateAdd("n", 1, "1995-01-31 21:48:29"), CDate("1995-01-31 21:49:29"), "DateAdd(""n"", 1, ""1995-01-31 21:48:29"")") + TestUtil.AssertEqual(DateAdd("s", 1, "1995-01-31 21:48:29"), CDate("1995-01-31 21:48:30"), "DateAdd(""s"", 1, ""1995-01-31 21:48:29"")") Exit Sub - errorHandler: - On Error GoTo 0 - TestUtilModule.AssertTrue(False, testName & ": hit error handler") - GoTo exitFunc - + TestUtil.ReportErrorHandler("verify_testDateAdd", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/datediff.vb b/basic/qa/vba_tests/datediff.vb index 189339e04730..01b798a33a71 100644 --- a/basic/qa/vba_tests/datediff.vb +++ b/basic/qa/vba_tests/datediff.vb @@ -1,105 +1,45 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testDateDiff -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testDateDiff + doUnitTest = TestUtil.GetResult() End Function Sub verify_testDateDiff() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1 - Dim date2 - testName = "Test DateDiff function" On Error GoTo errorHandler - date2 = 10 - date1 = DateDiff("yyyy", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 40 - date1 = DateDiff("q", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 120 - date1 = DateDiff("m", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("y", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 521 - date1 = DateDiff("w", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 522 - date1 = DateDiff("ww", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 87672 - date1 = DateDiff("h", "22/11/2003", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 525600 - date1 = DateDiff("n", "22/11/2012", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 2678400 - date1 = DateDiff("s", "22/10/2013", "22/11/2013") - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbFriday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3623 - date1 = DateDiff("d", "22/12/2003", "22/11/2013", vbSaturday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3684 - date1 = DateDiff("d", "22/10/2003", "22/11/2013", vbSunday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbThursday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbTuesday) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbFriday, vbFirstJan1) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbThursday, vbFirstFourDays) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbSunday, vbFirstFullWeek) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - date2 = 3653 - date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbSaturday, vbFirstFullWeek) - TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(DateDiff("yyyy", "22/11/2003", "22/11/2013"), 10, "DateDiff(""yyyy"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("q", "22/11/2003", "22/11/2013"), 40, "DateDiff(""q"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("m", "22/11/2003", "22/11/2013"), 120, "DateDiff(""m"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("y", "22/11/2003", "22/11/2013"), 3653, "DateDiff(""y"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013"), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("w", "22/11/2003", "22/11/2013"), 521, "DateDiff(""w"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("ww", "22/11/2003", "22/11/2013"), 522, "DateDiff(""ww"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("h", "22/11/2003", "22/11/2013"), 87672, "DateDiff(""h"", ""22/11/2003"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("n", "22/11/2012", "22/11/2013"), 525600, "DateDiff(""n"", ""22/11/2012"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("s", "22/10/2013", "22/11/2013"), 2678400, "DateDiff(""s"", ""22/10/2013"", ""22/11/2013"")") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbFriday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbFriday)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbMonday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbMonday)") + TestUtil.AssertEqual(DateDiff("d", "22/12/2003", "22/11/2013", vbSaturday), 3623, "DateDiff(""d"", ""22/12/2003"", ""22/11/2013"", vbSaturday)") + TestUtil.AssertEqual(DateDiff("d", "22/10/2003", "22/11/2013", vbSunday), 3684, "DateDiff(""d"", ""22/10/2003"", ""22/11/2013"", vbSunday)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbThursday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbThursday)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbTuesday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbTuesday)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbFriday, vbFirstJan1), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbFriday, vbFirstJan1)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbThursday, vbFirstFourDays), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbThursday, vbFirstFourDays)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbSunday, vbFirstFullWeek), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbSunday, vbFirstFullWeek)") + TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbSaturday, vbFirstFullWeek), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbSaturday, vbFirstFullWeek)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testDateDiff", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/datepart.vb b/basic/qa/vba_tests/datepart.vb index 4872487640da..28989c27abbc 100644 --- a/basic/qa/vba_tests/datepart.vb +++ b/basic/qa/vba_tests/datepart.vb @@ -1,61 +1,34 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testDatePart -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testDatePart + doUnitTest = TestUtil.GetResult() End Function Sub verify_testDatePart() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1 'variables for test - Dim date2 - testName = "Test DatePart function" On Error GoTo errorHandler - date2 = 1969 - date1 = DatePart("yyyy", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 1 - date1 = DatePart("q", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 43 - date1 = DatePart("y", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 12 - date1 = DatePart("d", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 4 - date1 = DatePart("w", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 7 - date1 = DatePart("ww", "1969-02-12") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 16 - date1 = DatePart("h", "1969-02-12 16:32:00") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 32 - date1 = DatePart("n", "1969-02-12 16:32:00") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - date2 = 0 - date1 = DatePart("s", "1969-02-12 16:32:00") - TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(DatePart("yyyy", "1969-02-12"), 1969, "DatePart(""yyyy"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("q", "1969-02-12"), 1, "DatePart(""q"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("y", "1969-02-12"), 43, "DatePart(""y"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("d", "1969-02-12"), 12, "DatePart(""d"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("w", "1969-02-12"), 4, "DatePart(""w"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("ww", "1969-02-12"), 7, "DatePart(""ww"", ""1969-02-12"")") + TestUtil.AssertEqual(DatePart("h", "1969-02-12 16:32:00"), 16, "DatePart(""h"", ""1969-02-12 16:32:00"")") + TestUtil.AssertEqual(DatePart("n", "1969-02-12 16:32:00"), 32, "DatePart(""n"", ""1969-02-12 16:32:00"")") + TestUtil.AssertEqual(DatePart("s", "1969-02-12 16:32:00"), 0, "DatePart(""s"", ""1969-02-12 16:32:00"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testDatePart", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/dateserial.vb b/basic/qa/vba_tests/dateserial.vb index 53eeeb2327a6..8e961aefbb14 100644 --- a/basic/qa/vba_tests/dateserial.vb +++ b/basic/qa/vba_tests/dateserial.vb @@ -1,32 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testDateSerial -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testDateSerial + doUnitTest = TestUtil.GetResult() End Function Sub verify_testDateSerial() - Dim testName As String - Dim date1, date2 As Date - - TestUtilModule.TestInit - - testName = "Test DateSerial function" - date2 = 36326 - On Error GoTo errorHandler - date1 = DateSerial(1999, 6, 15) '6/15/1999 - TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1) - date1 = DateSerial(2000, 1 - 7, 15) '6/15/1999 - TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1) - date1 = DateSerial(1999, 1, 166) '6/15/1999 - TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1) - TestUtilModule.TestEnd + TestUtil.AssertEqual(DateSerial(1999, 6, 15), 36326, "DateSerial(1999, 6, 15)") + TestUtil.AssertEqual(DateSerial(2000, 1 - 7, 15), 36326, "DateSerial(2000, 1 - 7, 15)") + TestUtil.AssertEqual(DateSerial(1999, 1, 166), 36326, "DateSerial(1999, 1, 166)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testDateSerial", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/datevalue.vb b/basic/qa/vba_tests/datevalue.vb index 116b3e5c7c69..e433eba46149 100644 --- a/basic/qa/vba_tests/datevalue.vb +++ b/basic/qa/vba_tests/datevalue.vb @@ -1,33 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testDateValue -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testDateValue + doUnitTest = TestUtil.GetResult() End Function Function verify_testDateValue() as String - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Date - testName = "Test DateValue function" - date2 = 25246 - On Error GoTo errorHandler - date1 = DateValue("February 12, 1969") '2/12/1969 - TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1) - - date2 = 39468 - date1 = DateValue("21/01/2008") '1/21/2008 - TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1) - TestUtilModule.TestEnd + TestUtil.AssertEqual(DateValue("February 12, 1969"), 25246, "DateValue(""February 12, 1969"")") + TestUtil.AssertEqual(DateValue("21/01/2008"), 39468, "DateValue(""21/01/2008"")") Exit Function errorHandler: - TestUtilModule.AssertTrue(False, "ERROR", "#" & Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$) - TestUtilModule.TestEnd + TestUtil.ReportErrorHandler("verify_testFix", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/day.vb b/basic/qa/vba_tests/day.vb index ec01f6af883d..525ad455c338 100644 --- a/basic/qa/vba_tests/day.vb +++ b/basic/qa/vba_tests/day.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testday -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testday + doUnitTest = TestUtil.GetResult() End Function Sub verify_testday() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 'variables for test - testName = "Test day function" On Error GoTo errorHandler - date2 = 12 - date1 = Day("1969-02-12") '2/12/1969 - TestUtilModule.AssertTrue(date1 = date2, "the return day is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Day("1969-02-12"), 12, "Day(""1969-02-12"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testday", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/enum.vb b/basic/qa/vba_tests/enum.vb index 5c5cb184b89d..72f0c4fb8fe2 100644 --- a/basic/qa/vba_tests/enum.vb +++ b/basic/qa/vba_tests/enum.vb @@ -20,34 +20,33 @@ End Enum ' CountDown Function doUnitTest() ''' test_vba.cxx main entry point ''' + TestUtil.TestInit Call ENUM_TestCases - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function Sub ENUM_TestCases() - TestUtilModule.TestInit try: On Error Goto catch With CountDown -a: TestUtilModule.AssertTrue(.ONE = 3, "case a", "CountDown.ONE equals " & Str(.ONE)) +a: TestUtil.AssertEqual(.ONE, 3, ".ONE") -b: TestUtilModule.AssertTrue(.TWO = -3, "case b", "CountDown.TWO equals " & Str(.TWO)) +b: TestUtil.AssertEqual(.TWO, -3, ".TWO") -c: TestUtilModule.AssertTrue(TypeName(.FOUR) = "Long", "case c", "CountDown.FOUR type is: " & TypeName(.FOUR)) +c: TestUtil.AssertEqual(TypeName(.FOUR), "Long", "TypeName(.FOUR)") d: Dim sum As Double sum = .FIVE + .FOUR + .THREE + .TWO + .ONE + .LIFT_OFF - TestUtilModule.AssertTrue(sum = 12, "case d", "SUM of CountDown values is: " & Str(sum)) + TestUtil.AssertEqual(sum, 12, "sum") End With finally: - TestUtilModule.TestEnd Exit Sub catch: - TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" in 'ENUM_TestCases' at line"& Str(Erl) &" - "& Error$) + TestUtil.ReportErrorHandler("ENUM_TestCases", Err, Error$, Erl) Resume Next End Sub diff --git a/basic/qa/vba_tests/error.vb b/basic/qa/vba_tests/error.vb index 95725b7fabaf..9b10ff8ffe98 100644 --- a/basic/qa/vba_tests/error.vb +++ b/basic/qa/vba_tests/error.vb @@ -1,28 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testError -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testError + doUnitTest = TestUtil.GetResult() End Function Sub verify_testError() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Error function" On Error GoTo errorHandler - date2 = Error(11) 'https://help.libreoffice.org/Basic/Error_Sub_Runtime - date1 = "Division by zero." - TestUtilModule.AssertTrue(date1 = date2, "the return Error is: " & date2) - - TestUtilModule.TestEnd + ' https://help.libreoffice.org/Basic/Error_Sub_Runtime + TestUtil.AssertEqual(Error(11), "Division by zero.", "Error(11)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testError", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/exp.vb b/basic/qa/vba_tests/exp.vb index 5899763a05bb..7c2a7a861a16 100644 --- a/basic/qa/vba_tests/exp.vb +++ b/basic/qa/vba_tests/exp.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testExp -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testExp + doUnitTest = TestUtil.GetResult() End Function Sub verify_testExp() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Exp function" On Error GoTo errorHandler - date2 = 2.7183 - date1 = Exp(1) - TestUtilModule.AssertTrue(Round(date1, 4) = Round(date2, 4), "the return Exp is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Exp(1), 2.71828182845904, 1E-14, "Exp(1)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testExp", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/fix.vb b/basic/qa/vba_tests/fix.vb index 50bab78d8d13..9f2af40088d1 100644 --- a/basic/qa/vba_tests/fix.vb +++ b/basic/qa/vba_tests/fix.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testFix -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testFix + doUnitTest = TestUtil.GetResult() End Function Sub verify_testFix() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Fix function" On Error GoTo errorHandler - date2 = 12 - date1 = Fix(12.34) - TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1) - - date2 = 12 - date1 = Fix(12.99) - TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1) - - date2 = -8 - date1 = Fix(-8.4) - TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Fix(12.34), 12, "Fix(12.34)") + TestUtil.AssertEqual(Fix(12.99), 12, "Fix(12.99)") + TestUtil.AssertEqual(Fix(-8.4), -8, "Fix(-8.4)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testFix", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/format.vb b/basic/qa/vba_tests/format.vb index 5ea7f903a03f..0e997ca824db 100644 --- a/basic/qa/vba_tests/format.vb +++ b/basic/qa/vba_tests/format.vb @@ -1,411 +1,186 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_format -doUnitTest = TestUtilModule.GetResult() -End Function - -Function verify_format() as String - - TestUtilModule.TestInit + TestUtil.TestInit 'Predefined_Datetime_Format_Sample Predefined_Number_Format_Sample 'Custom_Datetime_Format_Sample Custom_Number_Format_Sample Custom_Text_Format_Sample - TestUtilModule.TestEnd -End Sub + testFormat + + doUnitTest = TestUtil.GetResult() +End Function Sub Predefined_Datetime_Format_Sample() - Dim testName As String - Dim myDate, MyTime, TestStr As String - myDate = "01/06/98" - MyTime = "17:08:06" - testName = "Test Predefined_Datetime_Format_Sample function" + Dim TestStr As String + const myDate = "01/06/98" + const MyTime = "17:08:06" On Error GoTo errorHandler + ' These tests only apply to en_US locale + ' The date/time format have a little different between ms office and OOo due to different locale and system... TestStr = Format(myDate, "General Date") ' 1/6/98 - - TestUtilModule.AssertTrue(IsDate(TestStr), "General Date: " & TestStr & " (Test only applies to en_US locale)") - 'TestUtilModule.AssertTrue(TestStr = "1/6/98", "General Date: " & TestStr) + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "General Date") + 'TestUtil.AssertEqual(TestStr, "1/6/98", "General Date") TestStr = Format(myDate, "Long Date") ' Tuesday, January 06, 1998 - TestUtilModule.AssertTrue(TestStr = "Tuesday, January 06, 1998", "Long Date: " & TestStr & " (Test only applies to en_US locale)") - 'TestUtilModule.AssertTrue(IsDate(TestStr), "Long Date: " & TestStr) + TestUtil.AssertEqual(TestStr, "Tuesday, January 06, 1998", "Long Date") + 'TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Long Date") TestStr = Format(myDate, "Medium Date") ' 06-Jan-98 - 'TestUtilModule.AssertTrue(TestStr = "06-Jan-98", "Medium Date: " & TestStr) - TestUtilModule.AssertTrue(IsDate(TestStr), "Medium Date: " & TestStr & " (Test only applies to en_US locale)") + 'TestUtil.AssertEqual(TestStr, "06-Jan-98", "Medium Date") + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Medium Date") TestStr = Format(myDate, "Short Date") ' 1/6/98 - 'TestUtilModule.AssertTrue(TestStr = "1/6/98", "Short Date: " & TestStr) - TestUtilModule.AssertTrue(IsDate(TestStr), "Short Date: " & TestStr & " (Test only applies to en_US locale)") + 'TestUtil.AssertEqual(TestStr, "1/6/98", "Short Date") + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Short Date") TestStr = Format(MyTime, "Long Time") ' 5:08:06 PM - 'TestUtilModule.AssertTrue(TestStr = "5:08:06 PM", "Long Time: " & TestStr) - TestUtilModule.AssertTrue(IsDate(TestStr), "Long Time: " & TestStr & " (Test only applies to en_US locale)") + 'TestUtil.AssertEqual(TestStr, "5:08:06 PM", "Long Time") + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Long Time") TestStr = Format(MyTime, "Medium Time") ' 05:08 PM - 'TestUtilModule.AssertTrue(TestStr = "05:08 PM", "Medium Time: " & TestStr) - TestUtilModule.AssertTrue(IsDate(TestStr), "Medium Time: " & TestStr & " (Test only applies to en_US locale)") + 'TestUtil.AssertEqual(TestStr, "05:08 PM", "Medium Time") + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Medium Time") TestStr = Format(MyTime, "Short Time") ' 17:08 - 'TestUtilModule.AssertTrue(TestStr = "17:08", "Short Time: " & TestStr) - TestUtilModule.AssertTrue(IsDate(TestStr), "Short Time: " & TestStr & " (Test only applies to en_US locale)") + 'TestUtil.AssertEqual(TestStr, "17:08", "Short Time") + TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Short Time") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("Predefined_Datetime_Format_Sample", Err, Error$, Erl) End Sub Sub Predefined_Number_Format_Sample() - Dim myNumber, TestStr As String - Dim testName As String - testName = "Test Predefined_Number_Format_Sample function" - myNumber = 562486.2356 - - On Error GoTo errorHandler - - TestStr = Format(myNumber, "General Number") '562486.2356 - TestUtilModule.AssertTrue(TestStr = "562486.2356", "General Number: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0.2, "Fixed") '0.20 - TestUtilModule.AssertTrue(TestStr = "0.20", "Fixed: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(myNumber, "Standard") '562,486.24 - TestUtilModule.AssertTrue(TestStr = "562,486.24", "Standard: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0.7521, "Percent") '75.21% - TestUtilModule.AssertTrue(TestStr = "75.21%", "Percent: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(myNumber, "Scientific") '5.62E+05 - TestUtilModule.AssertTrue(TestStr = "5.62E+05", "Scientific: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(-3456.789, "Scientific") '-3.46E+03 - TestUtilModule.AssertTrue(TestStr = "-3.46E+03", "Scientific: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0, "Yes/No") 'No - TestUtilModule.AssertTrue(TestStr = "No", "Yes/No: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(23, "Yes/No") 'Yes - TestUtilModule.AssertTrue(TestStr = "Yes", "Yes/No: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0, "True/False") 'False - TestUtilModule.AssertTrue(TestStr = "False", "True/False: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(23, "True/False") 'True - TestUtilModule.AssertTrue(TestStr = "True", "True/False: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0, "On/Off") 'Off - TestUtilModule.AssertTrue(TestStr = "Off", "On/Off: " & TestStr) - 'MsgBox TestStr + On Error GoTo errorHandler - TestStr = Format(23, "On/Off") 'On - TestUtilModule.AssertTrue(TestStr = "On", "On/Off: " & TestStr) - 'MsgBox TestStr + TestUtil.AssertEqual(Format(562486.2356, "General Number"), "562486.2356", "Format(562486.2356, ""General Number"")") + TestUtil.AssertEqual(Format(0.2, "Fixed"), "0.20", "Format(0.2, ""Fixed"")") + TestUtil.AssertEqual(Format(562486.2356, "Standard"), "562,486.24", "Format(562486.2356, ""Standard"")") + TestUtil.AssertEqual(Format(0.7521, "Percent"), "75.21%", "Format(0.7521, ""Percent"")") + TestUtil.AssertEqual(Format(562486.2356, "Scientific"), "5.62E+05", "Format(562486.2356, ""Scientific"")") + TestUtil.AssertEqual(Format(-3456.789, "Scientific"), "-3.46E+03", "Format(-3456.789, ""Scientific"")") + TestUtil.AssertEqual(Format(0, "Yes/No"), "No", "Format(0, ""Yes/No"")") + TestUtil.AssertEqual(Format(23, "Yes/No"), "Yes", "Format(23, ""Yes/No"")") + TestUtil.AssertEqual(Format(0, "True/False"), "False", "Format(0, ""True/False"")") + TestUtil.AssertEqual(Format(23, "True/False"), "True", "Format(23, ""True/False"")") + TestUtil.AssertEqual(Format(0, "On/Off"), "Off", "Format(0, ""On/Off"")") + TestUtil.AssertEqual(Format(23, "On/Off"), "On", "Format(23, ""On/Off"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") - + TestUtil.ReportErrorHandler("Predefined_Number_Format_Sample", Err, Error$, Erl) End Sub Sub Custom_Datetime_Format_Sample() - Dim myDate, MyTime, TestStr As String - Dim testName As String - - myDate = "01/06/98" - MyTime = "05:08:06" - - testName = "Test Custom_Datetime_Format_Sample function" - On Error GoTo errorHandler - - TestStr = Format("01/06/98 17:08:06", "c") ' 1/6/98 5:08:06 PM - TestUtilModule.AssertTrue(TestStr = "1/6/98 5:08:06 PM", "c: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "dddddd") ' (Long Date), Tuesday, January 06, 1998 - TestUtilModule.AssertTrue(TestStr = "Tuesday, January 06, 1998", "dddddd: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "mm-dd-yyyy") ' 01-06-19s98 - TestUtilModule.AssertTrue(TestStr = "01-06-1998", "mm-dd-yyyy: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "d") ' 6 - TestUtilModule.AssertTrue(TestStr = "6", "d: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "dd") ' 06 - TestUtilModule.AssertTrue(TestStr = "06", "dd: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "ddd") ' Tue - TestUtilModule.AssertTrue(TestStr = "Tue", "ddd: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "dddd") ' Tuesday - TestUtilModule.AssertTrue(TestStr = "Tuesday", "dddd: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "h") ' 5 - TestUtilModule.AssertTrue(TestStr = "5", "h: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "hh") ' 05 - TestUtilModule.AssertTrue(TestStr = "05", "hh: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "n") ' 8 - TestUtilModule.AssertTrue(TestStr = "8", "n: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "nn") ' 08 - TestUtilModule.AssertTrue(TestStr = "08", "nn: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "m") ' 1 - TestUtilModule.AssertTrue(TestStr = "1", "m: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "mm") ' 01 - TestUtilModule.AssertTrue(TestStr = "01", "mm: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "mmm") ' Jan - TestUtilModule.AssertTrue(TestStr = "Jan", "mmm: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "mmmm") ' January - TestUtilModule.AssertTrue(TestStr = "January", "mmmm: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "s") ' 6 - TestUtilModule.AssertTrue(TestStr = "6", "s: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(MyTime, "ss") ' 06 - TestUtilModule.AssertTrue(TestStr = "06", "ss: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - MyTime = "17:08:06" + const myDate = "01/06/98" + const MyTime = "05:08:06" + const MyTimePM = "17:08:06" - TestStr = Format(MyTime, "hh:mm:ss AM/PM") ' 05:08:06 PM - TestUtilModule.AssertTrue(TestStr = "05:08:06 PM", "hh:mm:ss AM/PM: " & TestStr & " (Test only applies to en_US locale)") - - TestStr = Format(MyTime, "hh:mm:ss") ' 17:08:06 - TestUtilModule.AssertTrue(TestStr = "17:08:06", "hh:mm:ss: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "ww") ' 2 - TestUtilModule.AssertTrue(TestStr = "2", "ww: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "w") ' 3 - TestUtilModule.AssertTrue(TestStr = "3", "w: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "y") ' 6 - TestUtilModule.AssertTrue(TestStr = "6", "y: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr - - TestStr = Format(myDate, "yy") ' 98 - TestUtilModule.AssertTrue(TestStr = "98", "yy: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr + On Error GoTo errorHandler - TestStr = Format(myDate, "yyyy") ' 1998 - TestUtilModule.AssertTrue(TestStr = "1998", "yyyy: " & TestStr & " (Test only applies to en_US locale)") - 'MsgBox TestStr + ' These tests only apply to en_US locale + TestUtil.AssertEqual(Format("01/06/98 17:08:06", "c"), "1/6/98 5:08:06 PM", "Format(""01/06/98 17:08:06"", ""c"")") + TestUtil.AssertEqual(Format(myDate, "dddddd"), "Tuesday, January 06, 1998", "Format(myDate, ""dddddd"")") + TestUtil.AssertEqual(Format(myDate, "mm-dd-yyyy"), "01-06-1998", "Format(myDate, ""mm-dd-yyyy"")") + TestUtil.AssertEqual(Format(myDate, "d"), "6", "Format(myDate, ""d"")") + TestUtil.AssertEqual(Format(myDate, "dd"), "06", "Format(myDate, ""dd"")") + TestUtil.AssertEqual(Format(myDate, "ddd"), "Tue", "Format(myDate, ""ddd"")") + TestUtil.AssertEqual(Format(myDate, "dddd"), "Tuesday", "Format(myDate, ""dddd"")") + TestUtil.AssertEqual(Format(MyTime, "h"), "5", "Format(MyTime, ""h"")") + TestUtil.AssertEqual(Format(MyTime, "hh"), "05", "Format(MyTime, ""hh"")") + TestUtil.AssertEqual(Format(MyTime, "n"), "8", "Format(MyTime, ""n"")") + TestUtil.AssertEqual(Format(MyTime, "nn"), "08", "Format(MyTime, ""nn"")") + TestUtil.AssertEqual(Format(myDate, "m"), "1", "Format(myDate, ""m"")") + TestUtil.AssertEqual(Format(myDate, "mm"), "01", "Format(myDate, ""mm"")") + TestUtil.AssertEqual(Format(myDate, "mmm"), "Jan", "Format(myDate, ""mmm"")") + TestUtil.AssertEqual(Format(myDate, "mmmm"), "January", "Format(myDate, ""mmmm"")") + TestUtil.AssertEqual(Format(MyTime, "s"), "6", "Format(MyTime, ""s"")") + TestUtil.AssertEqual(Format(MyTime, "ss"), "06", "Format(MyTime, ""ss"")") + TestUtil.AssertEqual(Format(MyTimePM, "hh:mm:ss AM/PM"), "05:08:06 PM", "Format(MyTimePM, ""hh:mm:ss AM/PM"")") + TestUtil.AssertEqual(Format(MyTimePM, "hh:mm:ss"), "17:08:06", "Format(MyTimePM, ""hh:mm:ss"")") + TestUtil.AssertEqual(Format(myDate, "ww"), "2", "Format(myDate, ""ww"")") + TestUtil.AssertEqual(Format(myDate, "w"), "3", "Format(myDate, ""w"")") + TestUtil.AssertEqual(Format(myDate, "y"), "6", "Format(myDate, ""y"")") + TestUtil.AssertEqual(Format(myDate, "yy"), "98", "Format(myDate, ""yy"")") + TestUtil.AssertEqual(Format(myDate, "yyyy"), "1998", "Format(myDate, ""yyyy"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("Custom_Datetime_Format_Sample", Err, Error$, Erl) End Sub Sub Custom_Number_Format_Sample() - Dim TestStr As String - Dim testName As String - - testName = "Test Custom_Number_Format_Sample function" - On Error GoTo errorHandler - - TestStr = Format(23.675, "00.0000") ' 23.6750 - TestUtilModule.AssertTrue(TestStr = "23.6750", "00.0000: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(23.675, "00.00") ' 23.68 - TestUtilModule.AssertTrue(TestStr = "23.68", "00.00: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(2658, "00000") ' 02658 - TestUtilModule.AssertTrue(TestStr = "02658", "00000: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(2658, "00.00") ' 2658.00 - TestUtilModule.AssertTrue(TestStr = "2658.00", "00.00: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(23.675, "##.####") ' 23.675 - TestUtilModule.AssertTrue(TestStr = "23.675", "##.####: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(23.675, "##.##") ' 23.68 - TestUtilModule.AssertTrue(TestStr = "23.68", "##.##: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(12345.25, "#,###.##") '12,345.25 - TestUtilModule.AssertTrue(TestStr = "12,345.25", "#,###.##: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0.25, "##.00%") '25.00% - TestUtilModule.AssertTrue(TestStr = "25.00%", "##.00%: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1000000, "#,###") '1,000,000 - TestUtilModule.AssertTrue(TestStr = "1,000,000", "#,###: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1.09837555, "#.#####E+###") '1.09838E+000 - TestUtilModule.AssertTrue(TestStr = "1.09838E+000", "#.#####E+###: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1.09837555, "###.####E#") '1.0984E0 with engineering notation - TestUtilModule.AssertTrue(TestStr = "1.0984E0", "###.####E#: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1098.37555, "###.####E#") '1.0984E3 with engineering notation - TestUtilModule.AssertTrue(TestStr = "1.0984E3", "###.####E#: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1098375.55, "###.####E#") '1.0984E6 with engineering notation - TestUtilModule.AssertTrue(TestStr = "1.0984E6", "###.####E#: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(1.09837555, "######E#") '1E0 with engineering notation - TestUtilModule.AssertTrue(TestStr = "1E0", "######E#: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(123456.789, "###E0") '123E3 with engineering notation - TestUtilModule.AssertTrue(TestStr = "123E3", "###E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(123567.89, "###E0") '124E3 with engineering notation - TestUtilModule.AssertTrue(TestStr = "124E3", "###E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(12, "###E0") '12E0 with engineering notation - TestUtilModule.AssertTrue(TestStr = "12E0", "###E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(12, "000E0") '012E0 with engineering notation - TestUtilModule.AssertTrue(TestStr = "012E0", "000E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0.12345, "###E0") '123E-3 with engineering notation - TestUtilModule.AssertTrue(TestStr = "123E-3", "###E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(123456, "####E0") '12E4 with interval-4 notation - TestUtilModule.AssertTrue(TestStr = "12E4", "####E0: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(2345.25, "$#,###.##") '$2.345.25 - TestUtilModule.AssertTrue(TestStr = "$2,345.25", "$#,###.##: " & TestStr) - 'MsgBox TestStr - - TestStr = Format(0.25, "##.###\%") '.25% - TestUtilModule.AssertTrue(TestStr = ".25%", "##.###\%: " & TestStr) - 'MsgBox TestStr + On Error GoTo errorHandler - TestStr = Format(12.25, "0.???") '12.25_ - TestUtilModule.AssertTrue(TestStr = "12.25 ", "0.???: " & TestStr) - 'MsgBox TestStr + TestUtil.AssertEqual(Format(23.675, "00.0000"), "23.6750", "Format(23.675, ""00.0000"")") + TestUtil.AssertEqual(Format(23.675, "00.00"), "23.68", "Format(23.675, ""00.00"")") + TestUtil.AssertEqual(Format(2658, "00000"), "02658", "Format(2658, ""00000"")") + TestUtil.AssertEqual(Format(2658, "00.00"), "2658.00", "Format(2658, ""00.00"")") + TestUtil.AssertEqual(Format(23.675, "##.####"), "23.675", "Format(23.675, ""##.####"")") + TestUtil.AssertEqual(Format(23.675, "##.##"), "23.68", "Format(23.675, ""##.##"")") + TestUtil.AssertEqual(Format(12345.25, "#,###.##"), "12,345.25", "Format(12345.25, ""#,###.##"")") + TestUtil.AssertEqual(Format(0.25, "##.00%"), "25.00%", "Format(0.25, ""##.00%"")") + TestUtil.AssertEqual(Format(1000000, "#,###"), "1,000,000", "Format(1000000, ""#,###"")") + TestUtil.AssertEqual(Format(1.09837555, "#.#####E+###"), "1.09838E+000", "Format(1.09837555, ""#.#####E+###"")") + TestUtil.AssertEqual(Format(1.09837555, "###.####E#"), "1.0984E0", "Format(1.09837555, ""###.####E#"")") + TestUtil.AssertEqual(Format(1098.37555, "###.####E#"), "1.0984E3", "Format(1098.37555, ""###.####E#"")") + TestUtil.AssertEqual(Format(1098375.55, "###.####E#"), "1.0984E6", "Format(1098375.55, ""###.####E#"")") + TestUtil.AssertEqual(Format(1.09837555, "######E#"), "1E0", "Format(1.09837555, ""######E#"")") + TestUtil.AssertEqual(Format(123456.789, "###E0"), "123E3", "Format(123456.789, ""###E0"")") + TestUtil.AssertEqual(Format(123567.89, "###E0"), "124E3", "Format(123567.89, ""###E0"")") + TestUtil.AssertEqual(Format(12, "###E0"), "12E0", "Format(12, ""###E0"")") + TestUtil.AssertEqual(Format(12, "000E0"), "012E0", "Format(12, ""000E0"")") + TestUtil.AssertEqual(Format(0.12345, "###E0"), "123E-3", "Format(0.12345, ""###E0"")") + TestUtil.AssertEqual(Format(123456, "####E0"), "12E4", "Format(123456, ""####E0"")") + TestUtil.AssertEqual(Format(2345.25, "$#,###.##"), "$2,345.25", "Format(2345.25, ""$#,###.##"")") + TestUtil.AssertEqual(Format(0.25, "##.###\%"), ".25%", "Format(0.25, ""##.###\%"")") + TestUtil.AssertEqual(Format(12.25, "0.???"), "12.25 ", "Format(12.25, ""0.???"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("Custom_Number_Format_Sample", Err, Error$, Erl) End Sub Sub Custom_Text_Format_Sample() - Dim myText, TestStr As String - myText = "VBA" - - Dim testName As String - - testName = "Test Custom_Text_Format_Sample function" - On Error GoTo errorHandler - - TestStr = Format(myText, "<") 'vba - TestUtilModule.AssertTrue(TestStr = "vba", "<: " & TestStr) - 'MsgBox TestStr + On Error GoTo errorHandler - TestStr = Format("vba", ">") 'VBA - TestUtilModule.AssertTrue(TestStr = "VBA", ">: " & TestStr) - 'MsgBox TestStr + TestUtil.AssertEqual(Format("VBA", "<"), "vba", "Format(""VBA"", ""<"")") + TestUtil.AssertEqual(Format("vba", ">"), "VBA", "Format(""vba"", "">"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & "hit error handler") + TestUtil.ReportErrorHandler("Custom_Text_Format_Sample", Err, Error$, Erl) End Sub Sub testFormat() - Dim testName As String - Dim TestDateTime As Date - Dim TestStr As String - testName = "Test Format function" - On Error GoTo errorHandler - TestDateTime = "1/27/2001 5:04:23 PM" - - ' Returns the value of TestDateTime in user-defined date/time formats. - ' Returns "17:4:23". - TestStr = Format(TestDateTime, "h:m:s") - TestUtilModule.AssertTrue(TestStr = "17:4:23", "the format of h:m:s: " & TestStr) - - ' Returns "05:04:23 PM". - TestStr = Format(TestDateTime, "ttttt") - TestUtilModule.AssertTrue(TestStr = "5:04:23 PM", "the format of ttttt: " & TestStr) + const TestDateTime = #2001-1-27T17:04:23# + TestUtil.AssertEqual(Format(TestDateTime, "h:m:s"), "17:4:23", "Format(TestDateTime, ""h:m:s"")") + TestUtil.AssertEqual(Format(TestDateTime, "ttttt"), "5:04:23 PM", "Format(TestDateTime, ""ttttt"")") + TestUtil.AssertEqual(Format(TestDateTime, "dddd, MMM d yyyy"), "Saturday, Jan 27 2001", "Format(TestDateTime, ""dddd, MMM d yyyy"")") + TestUtil.AssertEqual(Format(TestDateTime, "HH:mm:ss"), "17:04:23", "Format(TestDateTime, ""HH:mm:ss"")") - ' Returns "Saturday, Jan 27 2001". - TestStr = Format(TestDateTime, "dddd, MMM d yyyy") - TestUtilModule.AssertTrue(TestStr = "Saturday, Jan 27 2001", "the format of dddd, MMM d yyyy: " & TestStr) + TestUtil.AssertEqual(Format(23), "23", "Format(23)") + TestUtil.AssertEqual(Format(5459.4, "##,##0.00"), "5,459.40", "Format(5459.4, ""##,##0.00"")") + TestUtil.AssertEqual(Format(334.9, "###0.00"), "334.90", "Format(334.9, ""###0.00"")") + TestUtil.AssertEqual(Format(5, "0.00%"), "500.00%", "Format(5, ""0.00%"")") - ' Returns "17:04:23". - TestStr = Format(TestDateTime, "HH:mm:ss") - TestUtilModule.AssertTrue(TestStr = "17:04:23", "the format of HH:mm:ss: " & TestStr) - - ' Returns "23". - TestStr = Format(23) - TestUtilModule.AssertTrue(TestStr = "23", "no format:" & TestStr) - - ' User-defined numeric formats. - ' Returns "5,459.40". - TestStr = Format(5459.4, "##,##0.00") - TestUtilModule.AssertTrue(TestStr = "5,459.40", "the format of ##,##0.00: " & TestStr) - - ' Returns "334.90". - TestStr = Format(334.9, "###0.00") - TestUtilModule.AssertTrue(TestStr = "334.90", "the format of ###0.00: " & TestStr) - - ' Returns "500.00%". - TestStr = Format(5, "0.00%") - TestUtilModule.AssertTrue(TestStr = "500.00%", "the format of 0.00%: " & TestStr) Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("testFormat", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/formatnumber.vb b/basic/qa/vba_tests/formatnumber.vb index d26fc4ae2843..6ddcf95942f4 100644 --- a/basic/qa/vba_tests/formatnumber.vb +++ b/basic/qa/vba_tests/formatnumber.vb @@ -1,53 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testFormatNumber -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testFormatNumber + doUnitTest = TestUtil.GetResult() End Function Sub verify_testFormatNumber() - - TestUtilModule.TestInit - - Dim testName As String - Dim str1 As String, str2 As String On Error GoTo errorHandler - testName = "Test 1: positive, 2 decimals" - str2 = "12.20" - str1 = FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - testName = "Test 2: negative, 20 decimals, use leading zero" - str2 = "-0.20000000000000000000" - str1 = FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - testName = "Test 3: negative, 20 decimals, no leading zero" - str2 = "-.20000000000000000000" - str1 = FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - testName = "Test 4: negative, no leading zero, use parens" - str2 = "(.20)" - str1 = FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - testName = "Test 5: negative, default leading zero, use parens" - str2 = "(0.20)" - str1 = FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - testName = "Test 6: group digits" - str2 = "-12,345,678.00" - str1 = FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue) - TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse), "12.20", "FormatNumber(""12.2"", 2, vbFalse, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse), "-0.20000000000000000000", "FormatNumber(""-.2"", 20, vbTrue, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse), "-.20000000000000000000", "FormatNumber(""-0.2"", 20, vbFalse, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse), "(.20)", "FormatNumber(""-0.2"", -1, vbFalse, vbTrue, vbFalse)") + TestUtil.AssertEqual(FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse), "(0.20)", "FormatNumber(""-0.2"", -1, vbUseDefault, vbTrue, vbFalse)") + TestUtil.AssertEqual(FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue), "-12,345,678.00", "FormatNumber(""-12345678"", -1, vbUseDefault, vbUseDefault, vbTrue)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testFormatNumber", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/hex.vb b/basic/qa/vba_tests/hex.vb index 47ac7094d912..6c0cd145b664 100644 --- a/basic/qa/vba_tests/hex.vb +++ b/basic/qa/vba_tests/hex.vb @@ -1,52 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testHex -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testHex + doUnitTest = TestUtil.GetResult() End Function Sub verify_testHex() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Hex function" On Error GoTo errorHandler - date2 = "9" - date1 = Hex(9) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "9" - date1 = Hex(9) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "A" - date1 = Hex(10) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "10" - date1 = Hex(16) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "FF" - date1 = Hex(255) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "100" - date1 = Hex(256) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - date2 = "1CB" - date1 = Hex(459) - TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Hex(9), "9", "Hex(9)") + TestUtil.AssertEqual(Hex(10), "A", "Hex(10)") + TestUtil.AssertEqual(Hex(16), "10", "Hex(16)") + TestUtil.AssertEqual(Hex(255), "FF", "Hex(255)") + TestUtil.AssertEqual(Hex(256), "100", "Hex(256)") + TestUtil.AssertEqual(Hex(459), "1CB", "Hex(459)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testHex", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/hour.vb b/basic/qa/vba_tests/hour.vb index e0de888e8f2c..860096ccade6 100644 --- a/basic/qa/vba_tests/hour.vb +++ b/basic/qa/vba_tests/hour.vb @@ -1,39 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testHour -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testHour + doUnitTest = TestUtil.GetResult() End Function Sub verify_testHour() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2, myTime - testName = "Test Hour function" On Error GoTo errorHandler - myTime = "6:25:39 AM" - date2 = 6 - date1 = Hour(myTime) - TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1) - - myTime = "6:25:39 PM" - date2 = 18 - date1 = Hour(myTime) - TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1) - - myTime = "06:25:39 AM" - date2 = 6 - date1 = Hour(myTime) - TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Hour("6:25:39 AM"), 6, "Hour(""6:25:39 AM"")") + TestUtil.AssertEqual(Hour("6:25:39 PM"), 18, "Hour(""6:25:39 PM"")") + TestUtil.AssertEqual(Hour("06:25:39 AM"), 6, "Hour(""06:25:39 AM"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testHour", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/iif.vb b/basic/qa/vba_tests/iif.vb index ecb264b81640..8db7e48de05c 100644 --- a/basic/qa/vba_tests/iif.vb +++ b/basic/qa/vba_tests/iif.vb @@ -1,37 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIIf -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIIf + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIIf() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2, testnr - testName = "Test IIf function" On Error GoTo errorHandler - date2 = "it is true" - date1 = IIf(True, "it is true", "it is false") - TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1) - - date2 = "it is false" - date1 = IIf(False, "It is true", "it is false") - TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1) + TestUtil.AssertEqual(IIf(True, "it is true", "it is false"), "it is true", "IIf(True, ""it is true"", ""it is false"")") + TestUtil.AssertEqual(IIf(False, "It is true", "it is false"), "it is false", "IIf(False, ""It is true"", ""it is false"")") + Dim testnr testnr = 1001 - date2 = "Large" - date1 = IIf(testnr > 1000, "Large", "Small") - TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(IIf(testnr > 1000, "Large", "Small"), "Large", "IIf(testnr > 1000, ""Large"", ""Small"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIIf", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb index cefcd9359453..74f7e2f755d4 100644 --- a/basic/qa/vba_tests/instr.vb +++ b/basic/qa/vba_tests/instr.vb @@ -1,54 +1,36 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testInStr -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testInStr + doUnitTest = TestUtil.GetResult() End Function Sub verify_testInStr() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2, SearchString, SearchChar - testName = "Test InStr function" On Error GoTo errorHandler - date2 = 5 - date1 = InStr(1, "somemoretext", "more") - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - date2 = 5 - date1 = InStr("somemoretext", "more") - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - date2 = 1 - date1 = InStr("somemoretext", "somemoretext") - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - date2 = 0 - date1 = InStr("somemoretext", "nothing") - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) + TestUtil.AssertEqual(InStr(1, "somemoretext", "more"), 5, "InStr(1, ""somemoretext"", ""more"")") + TestUtil.AssertEqual(InStr("somemoretext", "more"), 5, "InStr(""somemoretext"", ""more"")") + TestUtil.AssertEqual(InStr("somemoretext", "somemoretext"), 1, "InStr(""somemoretext"", ""somemoretext"")") + TestUtil.AssertEqual(InStr("somemoretext", "nothing"), 0, "InStr(""somemoretext"", ""nothing"")") + Dim SearchString, SearchChar SearchString = "XXpXXpXXPXXP" ' String to search in. SearchChar = "P" ' Search for "P". - date2 = 6 - date1 = InStr(4, SearchString, SearchChar, 1) - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - date2 = 9 - date1 = InStr(1, SearchString, SearchChar, 0) - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - date2 = 0 - date1 = InStr(1, SearchString, "W") - TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(InStr(4, SearchString, SearchChar, 1), 6, "InStr(4, SearchString, SearchChar, 1)") + TestUtil.AssertEqual(InStr(1, SearchString, SearchChar, 0), 9, "InStr(1, SearchString, SearchChar, 0)") + TestUtil.AssertEqual(InStr(1, SearchString, "W"), 0, "InStr(1, SearchString, ""W"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testInStr", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/instrrev.vb b/basic/qa/vba_tests/instrrev.vb index b201594ffa40..506d40733cdb 100644 --- a/basic/qa/vba_tests/instrrev.vb +++ b/basic/qa/vba_tests/instrrev.vb @@ -1,54 +1,36 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testInStrRev -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testInStrRev + doUnitTest = TestUtil.GetResult() End Function Sub verify_testInStrRev() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2, SearchString, SearchChar - testName = "Test InStrRev function" On Error GoTo errorHandler - date2 = 5 - date1 = InStrRev("somemoretext", "more", -1) - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - date2 = 5 - date1 = InStrRev("somemoretext", "more") - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - date2 = 1 - date1 = InStrRev("somemoretext", "somemoretext") - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - date2 = 0 - date1 = InStrRev("somemoretext", "nothing") - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) + TestUtil.AssertEqual(InStrRev("somemoretext", "more", -1), 5, "InStrRev(""somemoretext"", ""more"", -1)") + TestUtil.AssertEqual(InStrRev("somemoretext", "more"), 5, "InStrRev(""somemoretext"", ""more"")") + TestUtil.AssertEqual(InStrRev("somemoretext", "somemoretext"), 1, "InStrRev(""somemoretext"", ""somemoretext"")") + TestUtil.AssertEqual(InStrRev("somemoretext", "nothing"), 0, "InStrRev(""somemoretext"", ""nothing"")") + Dim SearchString, SearchChar SearchString = "XXpXXpXXPXXP" ' String to search in. SearchChar = "P" ' Search for "P". - date2 = 3 - date1 = InStrRev(SearchString, SearchChar, 4, 1) - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - date2 = 12 - date1 = InStrRev(SearchString, SearchChar, -1, 0) - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - date2 = 0 - date1 = InStrRev(SearchString, "W", 1) - TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, 4, 1), 3, "InStrRev(SearchString, SearchChar, 4, 1)") + TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, -1, 0), 12, "InStrRev(SearchString, SearchChar, -1, 0)") + TestUtil.AssertEqual(InStrRev(SearchString, "W", 1), 0, "InStrRev(SearchString, ""W"", 1)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testInStrRev", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/int.vb b/basic/qa/vba_tests/int.vb index e809a0d975c1..632999d3454b 100644 --- a/basic/qa/vba_tests/int.vb +++ b/basic/qa/vba_tests/int.vb @@ -1,44 +1,30 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testInt -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testInt + doUnitTest = TestUtil.GetResult() End Function Sub verify_testInt() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Int function" On Error GoTo errorHandler - date2 = 99 - date1 = Int(99.8) - TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1) - - date2 = -100 - date1 = Int(-99.8) - TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1) - - date2 = -100 - date1 = Int(-99.2) - TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1) - - date2 = 0 - date1 = Int(0.2) - TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1) - - date2 = 0 - date1 = Int(0) - TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Int(99.8), 99, "Int(99.8)") + TestUtil.AssertEqual(Int(-99.8), -100, "Int(-99.8)") + TestUtil.AssertEqual(Int(-99.2), -100, "Int(-99.2)") + TestUtil.AssertEqual(Int(0.2), 0, "Int(0.2)") + TestUtil.AssertEqual(Int(0), 0, "Int(0)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testInt", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/isarray.vb b/basic/qa/vba_tests/isarray.vb index 1a76d8af3b37..b028d85244db 100644 --- a/basic/qa/vba_tests/isarray.vb +++ b/basic/qa/vba_tests/isarray.vb @@ -1,38 +1,32 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsArray -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsArray + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsArray() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - Dim MyArray(1 To 5) As Integer, YourArray ' Declare array variables. - testName = "Test IsArray function" On Error GoTo errorHandler + Dim MyArray(1 To 5) As Integer, YourArray ' Declare array variables. + Dim AVar YourArray = Array(1, 2, 3) ' Use Array function. + AVar = False - date2 = True - date1 = IsArray(MyArray) - TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1) - - date2 = True - date1 = IsArray(YourArray) - TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1) - - date2 = False - date1 = IsArray(date2) - TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsArray(MyArray), "IsArray(MyArray)") + TestUtil.Assert(IsArray(YourArray), "IsArray(YourArray)") + TestUtil.Assert(Not IsArray(AVar), "Not IsArray(AVar)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsArray", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/isdate.vb b/basic/qa/vba_tests/isdate.vb index c4993cbee876..5d66bf7d8456 100644 --- a/basic/qa/vba_tests/isdate.vb +++ b/basic/qa/vba_tests/isdate.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsDate -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsDate + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsDate() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test IsDate function" On Error GoTo errorHandler - date2 = True - date1 = IsDate(cdate("12/2/1969")) - TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1) - - date2 = True - date1 = IsDate("12:22:12") - TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1) - - date2 = False - date1 = IsDate("a12.2.1969") - TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsDate(cdate("12/2/1969")), "IsDate(cdate(""12/2/1969""))") + TestUtil.Assert(IsDate("12:22:12"), "IsDate(""12:22:12"")") + TestUtil.Assert(Not IsDate("a12.2.1969"), "Not IsDate(""a12.2.1969"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsDate", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/isempty.vb b/basic/qa/vba_tests/isempty.vb index d4066f0a7e3b..22a71804a6a4 100644 --- a/basic/qa/vba_tests/isempty.vb +++ b/basic/qa/vba_tests/isempty.vb @@ -1,38 +1,33 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsEmpty -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsEmpty + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsEmpty() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2, MyVar - testName = "Test IsEmpty function" On Error GoTo errorHandler - date2 = True - date1 = IsEmpty(MyVar) - TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1) + Dim MyVar + TestUtil.Assert(IsEmpty(MyVar), "IsEmpty(MyVar)") MyVar = Null ' Assign Null. - date2 = False - date1 = IsEmpty(MyVar) - TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1) + TestUtil.Assert(Not IsEmpty(MyVar), "Not IsEmpty(MyVar)") MyVar = Empty ' Assign Empty. - date2 = True - date1 = IsEmpty(MyVar) - TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsEmpty(MyVar), "IsEmpty(MyVar)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsEmpty", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/iserror.vb b/basic/qa/vba_tests/iserror.vb index 919c3c47656a..0250933caa7f 100644 --- a/basic/qa/vba_tests/iserror.vb +++ b/basic/qa/vba_tests/iserror.vb @@ -1,32 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsError -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsError + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsError() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test IsError function" On Error GoTo errorHandler - date2 = False - date1 = IsError("12.2.1969") - TestUtilModule.AssertTrue(date1 = date2, "the return IsError is: " & date1) - - date2 = True - date1 = IsError(CVErr(64)) - TestUtilModule.AssertTrue(date1 = date2, "the return IsError is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(Not IsError("12.2.1969"), "Not IsError(""12.2.1969"")") + TestUtil.Assert(IsError(CVErr(64)), "IsError(CVErr(64))") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsError", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/ismissing.vb b/basic/qa/vba_tests/ismissing.vb index 5e60915473ef..febe0339f68a 100644 --- a/basic/qa/vba_tests/ismissing.vb +++ b/basic/qa/vba_tests/ismissing.vb @@ -1,3 +1,11 @@ +' +' 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 VBASupport 1 Const IsMissingNone = -1 @@ -6,8 +14,9 @@ Const IsMissingB = 1 Const IsMissingAB = 2 Function doUnitTest() As String + TestUtil.TestInit verify_testIsMissingVba - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test isMissing function with different datatypes. In LO Basic @@ -17,57 +26,56 @@ End Function ' respective default value of its datatype. Sub verify_testIsMissingVba() - TestUtilModule.TestInit testName = "Test missing (VBA)" On Error GoTo errorHandler ' optionals with variant datatypes - TestUtilModule.AssertEqual(TestOptVariant(), IsMissingA, "TestOptVariant()") - TestUtilModule.AssertEqual(TestOptVariant(123), IsMissingNone, "TestOptVariant(123)") - TestUtilModule.AssertEqual(TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)") - TestUtilModule.AssertEqual(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) - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()") - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123),IsMissingNone, "TestOptVariantByRefByVal(123)") - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)") - TestUtilModule.AssertEqual(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 - TestUtilModule.AssertEqual(TestOptDouble(), IsMissingNone, "TestOptDouble()") - TestUtilModule.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)") - TestUtilModule.AssertEqual(TestOptDouble(, 567.8), IsMissingNone, "TestOptDouble(, 567.8)") - TestUtilModule.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)") + TestUtil.AssertEqual(TestOptDouble(), IsMissingNone, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingNone, "TestOptDouble(, 567.8)") + TestUtil.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(), IsMissingNone, "TestOptDouble()") - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)") - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(, 567.8)") - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(), IsMissingNone, "TestOptDouble()") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(, 567.8)") + TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestUtilModule.AssertEqual(TestOptInteger(), IsMissingNone, "TestOptInteger()") - TestUtilModule.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)") - TestUtilModule.AssertEqual(TestOptInteger(, 456), IsMissingNone, "TestOptInteger(, 456)") - TestUtilModule.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)") + TestUtil.AssertEqual(TestOptInteger(), IsMissingNone, "TestOptInteger()") + TestUtil.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)") + TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingNone, "TestOptInteger(, 456)") + TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)") ' optionals with integer datatypes (ByRef and ByVal) - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(), IsMissingNone, "TestOptIntegerByRefByVal()") - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)") - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingNone, "TestOptIntegerByRefByVal(, 456)") - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingNone, "TestOptIntegerByRefByVal()") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingNone, "TestOptIntegerByRefByVal(, 456)") + TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)") ' optionals with string datatypes - TestUtilModule.AssertEqual(TestOptString(), IsMissingNone, "TestOptString()") - TestUtilModule.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")") - TestUtilModule.AssertEqual(TestOptString(, "456"), IsMissingNone, "TestOptString(, ""456"")") - TestUtilModule.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")") + TestUtil.AssertEqual(TestOptString(), IsMissingNone, "TestOptString()") + TestUtil.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")") + TestUtil.AssertEqual(TestOptString(, "456"), IsMissingNone, "TestOptString(, ""456"")") + TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")") ' optionals with string datatypes (ByRef and ByVal) - TestUtilModule.AssertEqual(TestOptStringByRefByVal(), IsMissingNone, "TestOptStringByRefByVal()") - TestUtilModule.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")") - TestUtilModule.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingNone, "TestOptStringByRefByVal(, ""456"")") - TestUtilModule.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingNone, "TestOptStringByRefByVal()") + TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")") + TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingNone, "TestOptStringByRefByVal(, ""456"")") + TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")") ' optionals with object datatypes Dim cA As New Collection @@ -76,16 +84,16 @@ Sub verify_testIsMissingVba() Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestUtilModule.AssertEqual(TestOptObject(), IsMissingAB, "TestOptObject()") - TestUtilModule.AssertEqual(TestOptObject(cA), IsMissingB, "TestOptObject(A)") - TestUtilModule.AssertEqual(TestOptObject(, cB), IsMissingA, "TestOptObject(, B)") - TestUtilModule.AssertEqual(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) - TestUtilModule.AssertEqual(TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()") - TestUtilModule.AssertEqual(TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)") - TestUtilModule.AssertEqual(TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)") - TestUtilModule.AssertEqual(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 @@ -95,23 +103,21 @@ Sub verify_testIsMissingVba() aB(0) = 123.4 aB(1) = 567.8 ' TODO - New bug report? Scanner initializes variable not as an array - ' TestUtilModule.AssertEqual(TestOptArray(), IsMissingAB, "TestOptArray()") - ' TestUtilModule.AssertEqual(TestOptArray(aA), IsMissingB, "TestOptArray(A)") - ' TestUtilModule.AssertEqual(TestOptArray(, aB), IsMissingA, "TestOptArray(, B)") - TestUtilModule.AssertEqual(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) ' TODO - New bug report? Scanner initializes variable not as an array - ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()") - ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)") - ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)") - TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)") - - TestUtilModule.TestEnd + ' 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 Sub errorHandler: - TestUtilModule.AssertEqual(False, True, Err.Description) + TestUtil.ReportErrorHandler("verify_testIsMissingVba", Err, Error$, Erl) End Sub Function TestOptVariant(Optional A, Optional B As Variant = 123) @@ -173,4 +179,3 @@ Function WhatIsMissing(is_missingA, is_missingB) WhatIsMissing = IsMissingNone End If End Function - diff --git a/basic/qa/vba_tests/isnull.vb b/basic/qa/vba_tests/isnull.vb index 1819f3c72ef3..7550238895ff 100644 --- a/basic/qa/vba_tests/isnull.vb +++ b/basic/qa/vba_tests/isnull.vb @@ -1,32 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsNull -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsNull + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsNull() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test IsNull function" On Error GoTo errorHandler - date2 = True - date1 = IsNull(Null) - TestUtilModule.AssertTrue(date1 = date2, "the return IsNull is: " & date1) - - date2 = False - date1 = IsNull("") - TestUtilModule.AssertTrue(date1 = date2, "the return IsNull is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsNull(Null), "IsNull(Null)") + TestUtil.Assert(Not IsNull(""), "Not IsNull("""")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsNull", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb index d2b6e2715182..ead7e83e1494 100644 --- a/basic/qa/vba_tests/isnumeric.vb +++ b/basic/qa/vba_tests/isnumeric.vb @@ -1,52 +1,32 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsNumeric -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsNumeric + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsNumeric() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test IsNumeric function" On Error GoTo errorHandler - date2 = True - date1 = IsNumeric(123) - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - date2 = True - date1 = IsNumeric(-123) - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - date2 = True - date1 = IsNumeric(123.8) - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - date2 = False - date1 = IsNumeric("a") - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - -rem date2 = True -rem date1 = IsNumeric(True) -rem TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - date2 = True - date1 = IsNumeric("123") - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - date2 = True - date1 = IsNumeric("+123") - TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsNumeric(123), "IsNumeric(123)") + TestUtil.Assert(IsNumeric(-123), "IsNumeric(-123)") + TestUtil.Assert(IsNumeric(123.8), "IsNumeric(123.8)") + TestUtil.Assert(Not IsNumeric("a"), "Not IsNumeric(""a"")") +rem TestUtil.Assert(IsNumeric(True), "IsNumeric(True)") + TestUtil.Assert(IsNumeric("123"), "IsNumeric(""123"")") + TestUtil.Assert(IsNumeric("+123"), "IsNumeric(""+123"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsNumeric", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/isobject.vb b/basic/qa/vba_tests/isobject.vb index e6a73fd7fba1..beec43f790d8 100644 --- a/basic/qa/vba_tests/isobject.vb +++ b/basic/qa/vba_tests/isobject.vb @@ -1,35 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testIsObject -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testIsObject + doUnitTest = TestUtil.GetResult() End Function Sub verify_testIsObject() - - TestUtilModule.TestInit - - Dim testName As String + On Error GoTo errorHandler Dim TestStr As String Dim MyObject As Object - Dim date1, date2, YourObject - testName = "Test IsObject function" - On Error GoTo errorHandler + Dim YourObject Set YourObject = MyObject ' Assign an object reference. - date2 = True - date1 = IsObject(YourObject) - TestUtilModule.AssertTrue(date1 = date2, "the return IsObject is: " & date1) - - date2 = False - date1 = IsObject(TestStr) - TestUtilModule.AssertTrue(date1 = date2, "the return IsObject is: " & date1) - - TestUtilModule.TestEnd + TestUtil.Assert(IsObject(YourObject), "IsObject(YourObject)") + TestUtil.Assert(Not IsObject(TestStr), "Not IsObject(TestStr)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testIsObject", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/join.vb b/basic/qa/vba_tests/join.vb index 6e57f5b68132..c4f568f812e1 100644 --- a/basic/qa/vba_tests/join.vb +++ b/basic/qa/vba_tests/join.vb @@ -1,44 +1,33 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testJoin -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testJoin + doUnitTest = TestUtil.GetResult() End Function Sub verify_testJoin() - - TestUtilModule.TestInit - - Dim testName As String - Dim str1, str2 As String - Dim vaArray(2) As String - testName = "Test Join function" On Error GoTo errorHandler + Dim vaArray(2) As String vaArray(0) = "string1" vaArray(1) = "string2" vaArray(2) = "string3" - str2 = "string1 string2 string3" - str1 = Join(vaArray) - TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1) - - str2 = "string1 string2 string3" - str1 = Join(vaArray, " ") - TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1) - - str2 = "string1<>string2<>string3" - str1 = Join(vaArray, "<>") - TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1) - - str2 = "string1string2string3" - str1 = Join(vaArray, "") - TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Join(vaArray), "string1 string2 string3", "Join(vaArray)") + TestUtil.AssertEqual(Join(vaArray, " "), "string1 string2 string3", "Join(vaArray, "" "")") + TestUtil.AssertEqual(Join(vaArray, "<>"), "string1<>string2<>string3", "Join(vaArray, ""<>"")") + TestUtil.AssertEqual(Join(vaArray, ""), "string1string2string3", "Join(vaArray, """")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testJoin", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/lbound.vb b/basic/qa/vba_tests/lbound.vb index 20ff5eb3b3d0..5e40d709eed3 100644 --- a/basic/qa/vba_tests/lbound.vb +++ b/basic/qa/vba_tests/lbound.vb @@ -1,33 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLBound -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLBound + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLBound() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - Dim MyArray(1 To 10, 5 To 15, 10 To 20) ' Declare array variables. - testName = "Test LBound function" On Error GoTo errorHandler + Dim MyArray(1 To 10, 5 To 15, 10 To 20) ' Declare array variables. - date2 = 1 - date1 = LBound(MyArray, 1) - TestUtilModule.AssertTrue(date1 = date2, "the return LBound is: " & date1) - - date2 = 10 - date1 = LBound(MyArray, 3) - TestUtilModule.AssertTrue(date1 = date2, "the return LBound is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(LBound(MyArray, 1), 1, "LBound(MyArray, 1)") + TestUtil.AssertEqual(LBound(MyArray, 3), 10, "LBound(MyArray, 3)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLBound", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/lcase.vb b/basic/qa/vba_tests/lcase.vb index ed6610d105d3..0553f338b18e 100644 --- a/basic/qa/vba_tests/lcase.vb +++ b/basic/qa/vba_tests/lcase.vb @@ -1,40 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLCase -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLCase + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLCase() - - TestUtilModule.TestInit - - Dim testName As String - Dim str1, str2 As String 'variables for test - testName = "Test LCase function" On Error GoTo errorHandler - str2 = "lowercase" - str1 = LCase("LOWERCASE") - TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1) - - str2 = "lowercase" - str1 = LCase("LowerCase") - TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1) - - str2 = "lowercase" - str1 = LCase("lowercase") - TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1) - - str2 = "lower case" - str1 = LCase("LOWER CASE") - TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(LCase("LOWERCASE"), "lowercase", "LCase(""LOWERCASE"")") + TestUtil.AssertEqual(LCase("LowerCase"), "lowercase", "LCase(""LowerCase"")") + TestUtil.AssertEqual(LCase("lowercase"), "lowercase", "LCase(""lowercase"")") + TestUtil.AssertEqual(LCase("LOWER CASE"), "lower case", "LCase(""LOWER CASE"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLCase", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/left.vb b/basic/qa/vba_tests/left.vb index 609eee535b91..047497ef0333 100644 --- a/basic/qa/vba_tests/left.vb +++ b/basic/qa/vba_tests/left.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLeft -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLeft + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLeft() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Left function" On Error GoTo errorHandler - date2 = "some" - date1 = Left("sometext", 4) - TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1) - - date2 = "sometext" - date1 = Left("sometext", 48) - TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1) - - date2 = "" - date1 = Left("", 4) - TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Left("sometext", 4), "some", "Left(""sometext"", 4)") + TestUtil.AssertEqual(Left("sometext", 48), "sometext", "Left(""sometext"", 48)") + TestUtil.AssertEqual(Left("", 4), "", "Left("""", 4)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLeft", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/len.vb b/basic/qa/vba_tests/len.vb index 679ccc49cdbd..f91ebd04c95f 100644 --- a/basic/qa/vba_tests/len.vb +++ b/basic/qa/vba_tests/len.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLen -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLen + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLen() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Len function" On Error GoTo errorHandler - date2 = 8 - date1 = Len("sometext") - TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1) - - date2 = 9 - date1 = Len("some text") - TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1) - - date2 = 0 - date1 = Len("") - TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Len("sometext"), 8, "Len(""sometext"")") + TestUtil.AssertEqual(Len("some text"), 9, "Len(""some text"")") + TestUtil.AssertEqual(Len(""), 0, "Len("""")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLen", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/log.vb b/basic/qa/vba_tests/log.vb index 2f9fc5f871aa..431bea642da9 100644 --- a/basic/qa/vba_tests/log.vb +++ b/basic/qa/vba_tests/log.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLog -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLog + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLog() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Log function" On Error GoTo errorHandler - date2 = 4.454 - date1 = Log(86) - TestUtilModule.AssertTrue(Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1) - - date2 = 4 - date1 = Exp(Log(4)) - TestUtilModule.AssertTrue(date1 = date2, "the return Log is: " & date1) - - date2 = 1 - date1 = Log(2.7182818) - TestUtilModule.AssertTrue(Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Log(86), 4.45434729625351, 1E-14, "Log(86)") + TestUtil.AssertEqualApprox(Log(2.71828182845904), 1, 1E-14, "Log(2.71828182845904)") + TestUtil.AssertEqual(Exp(Log(4)), 4, "Exp(Log(4))") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLog", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/ltrim.vb b/basic/qa/vba_tests/ltrim.vb index 7e2b27e34de2..c265e684612c 100644 --- a/basic/qa/vba_tests/ltrim.vb +++ b/basic/qa/vba_tests/ltrim.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testLTrim -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testLTrim + doUnitTest = TestUtil.GetResult() End Function Sub verify_testLTrim() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test LTrim function" On Error GoTo errorHandler - date2 = "some text " - date1 = LTrim(" some text ") - TestUtilModule.AssertTrue(date1 = date2, "the return LTrim is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(LTrim(" some text "), "some text ", "LTrim("" some text "")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testLTrim", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/mid.vb b/basic/qa/vba_tests/mid.vb index 32b71b8f7d93..863e24784512 100644 --- a/basic/qa/vba_tests/mid.vb +++ b/basic/qa/vba_tests/mid.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testMid -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testMid + doUnitTest = TestUtil.GetResult() End Function Sub verify_testMid() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Mid function" On Error GoTo errorHandler - date2 = "Mid" - date1 = Mid("Mid Function Demo", 1, 3) - TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1) - - date2 = "Demo" - date1 = Mid("Mid Function Demo", 14, 4) - TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1) - - date2 = "Function Demo" - date1 = Mid("Mid Function Demo", 5) - TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Mid("Mid Function Demo", 1, 3), "Mid", "Mid(""Mid Function Demo"", 1, 3)") + TestUtil.AssertEqual(Mid("Mid Function Demo", 14, 4), "Demo", "Mid(""Mid Function Demo"", 14, 4)") + TestUtil.AssertEqual(Mid("Mid Function Demo", 5), "Function Demo", "Mid(""Mid Function Demo"", 5)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testMid", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/minute.vb b/basic/qa/vba_tests/minute.vb index 00ea54f5ac15..70deb125200c 100644 --- a/basic/qa/vba_tests/minute.vb +++ b/basic/qa/vba_tests/minute.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testMinute -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testMinute + doUnitTest = TestUtil.GetResult() End Function Sub verify_testMinute() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Minute function" On Error GoTo errorHandler - date2 = 34 - date1 = Minute("09:34:20") - TestUtilModule.AssertTrue(date1 = date2, "the return Minute is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Minute("09:34:20"), 34, "Minute(""09:34:20"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testMinute", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/month.vb b/basic/qa/vba_tests/month.vb index faa074560b3d..05222071f478 100644 --- a/basic/qa/vba_tests/month.vb +++ b/basic/qa/vba_tests/month.vb @@ -1,46 +1,32 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testMonth -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testMonth + doUnitTest = TestUtil.GetResult() End Function Sub verify_testMonth() + On Error GoTo errorHandler - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 Dim ldate As Date - testName = "Test Month function" - On Error GoTo errorHandler ldate = 32616 - - date2 = 4 - date1 = Month(ldate) - TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1) - - date2 = 2 - date1 = Month("01/02/2007") - TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1) - - date2 = 12 - date1 = Month(1) - TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1) - - date2 = 2 - date1 = Month(60) - TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1) - - date2 = 6 - date1 = Month(2000) - TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Month(ldate), 4, "Month(ldate)") + TestUtil.AssertEqual(Month("01/02/2007"), 2, "Month(""01/02/2007"")") + TestUtil.AssertEqual(Month(1), 12, "Month(1)") + TestUtil.AssertEqual(Month(60), 2, "Month(60)") + TestUtil.AssertEqual(Month(2000), 6, "Month(2000)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testMonth", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/monthname.vb b/basic/qa/vba_tests/monthname.vb index f173153c1c2b..6c01de51169b 100644 --- a/basic/qa/vba_tests/monthname.vb +++ b/basic/qa/vba_tests/monthname.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testMonthName -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testMonthName + doUnitTest = TestUtil.GetResult() End Function Sub verify_testMonthName() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test MonthName function" On Error GoTo errorHandler - date2 = "February" - date1 = MonthName(2) - TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1) - - date2 = "Feb" - date1 = MonthName(2, True) - TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1) - - date2 = "February" - date1 = MonthName(2, False) - TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(MonthName(2), "February", "MonthName(2)") + TestUtil.AssertEqual(MonthName(2, True), "Feb", "MonthName(2, True)") + TestUtil.AssertEqual(MonthName(2, False), "February", "MonthName(2, False)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testMonthName", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/oct.vb b/basic/qa/vba_tests/oct.vb index 8d08934b1942..d733bb763d8b 100644 --- a/basic/qa/vba_tests/oct.vb +++ b/basic/qa/vba_tests/oct.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testOct -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testOct + doUnitTest = TestUtil.GetResult() End Function Sub verify_testOct() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Oct function" On Error GoTo errorHandler - date2 = 4 - date1 = Oct(4) - TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1) - - date2 = 10 - date1 = Oct(8) - TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1) - - date2 = 713 - date1 = Oct(459) - TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Oct(4), "4", "Oct(4)") + TestUtil.AssertEqual(Oct(8), "10", "Oct(8)") + TestUtil.AssertEqual(Oct(459), "713", "Oct(459)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testOct", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/optional_paramters.vb b/basic/qa/vba_tests/optional_paramters.vb index 8fc647aa516d..e8f712bdeb35 100644 --- a/basic/qa/vba_tests/optional_paramters.vb +++ b/basic/qa/vba_tests/optional_paramters.vb @@ -1,8 +1,17 @@ +' +' 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 VBASupport 1 Function doUnitTest() As String + TestUtil.TestInit verify_testOptionalsVba - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function ' tdf#36737 - Test optionals with different datatypes. In LO Basic @@ -11,58 +20,55 @@ End Function ' which don't have explicit default values, will be initialized to their ' respective default value of its datatype Sub verify_testOptionalsVba() - - TestUtilModule.TestInit - testName = "Test optionals (VBA)" On Error GoTo errorHandler ' optionals with variant datatypes - TestUtilModule.AssertEqual(TestOptVariant(), 123, "TestOptVariant()") - TestUtilModule.AssertEqual(TestOptVariant(123), 246, "TestOptVariant(123)") - TestUtilModule.AssertEqual(TestOptVariant(, 456), 456, "TestOptVariant(, 456)") - TestUtilModule.AssertEqual(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) - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()") - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)") - TestUtilModule.AssertEqual(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)") - TestUtilModule.AssertEqual(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 - TestUtilModule.AssertEqual(TestOptDouble(), 123.4, "TestOptDouble()") - TestUtilModule.AssertEqual(TestOptDouble(123.4), 246.8, "TestOptDouble(123.4)") - TestUtilModule.AssertEqual(TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)") - TestUtilModule.AssertEqual(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(Format(TestOptDouble(123.4, 567.8), "0.0"), 691.2, "TestOptDouble(123.4, 567.8)") ' optionals with double datatypes (ByRef and ByVal) - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(), 123.4, "TestOptDouble()") - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4), 246.8, "TestOptDouble(123.4)") - TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)") - TestUtilModule.AssertEqual(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(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0"), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)") ' optionals with integer datatypes - TestUtilModule.AssertEqual(TestOptInteger(), 123, "TestOptInteger()") - TestUtilModule.AssertEqual(TestOptInteger(123), 246, "TestOptInteger(123)") - TestUtilModule.AssertEqual(TestOptInteger(, 456), 456, "TestOptInteger(, 456)") - TestUtilModule.AssertEqual(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) - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()") - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)") - TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)") - TestUtilModule.AssertEqual(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 - TestUtilModule.AssertEqual(TestOptString(), "123", "TestOptString()") - TestUtilModule.AssertEqual(TestOptString("123"), "123123", "TestOptString(""123"")") - TestUtilModule.AssertEqual(TestOptString(, "456"), "456", "TestOptString(, ""456"")") - TestUtilModule.AssertEqual(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) - TestUtilModule.AssertEqual(TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()") - TestUtilModule.AssertEqual(TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")") - TestUtilModule.AssertEqual(TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")") - TestUtilModule.AssertEqual(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 @@ -71,16 +77,16 @@ Sub verify_testOptionalsVba() Dim cB As New Collection cB.Add (123.4) cB.Add (567.8) - TestUtilModule.AssertEqual(TestOptObject(), 0, "TestOptObject()") - TestUtilModule.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)") - TestUtilModule.AssertEqual(Format(TestOptObject(, cB), "0.0"), 691.2, "TestOptObject(, B)") - TestUtilModule.AssertEqual(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(Format(TestOptObject(, cB), "0.0"), 691.2, "TestOptObject(, B)") + TestUtil.AssertEqual(Format(TestOptObject(cA, cB), "0.0"), 1270.2, "TestOptObject(A, B)") ' optionals with object datatypes (ByRef and ByVal) - TestUtilModule.AssertEqual(TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()") - TestUtilModule.AssertEqual(TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)") - TestUtilModule.AssertEqual(Format(TestOptObjectByRefByVal(, cB), "0.0"), 691.2, "TestOptObjectByRefByVal(, B)") - TestUtilModule.AssertEqual(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(Format(TestOptObjectByRefByVal(, cB), "0.0"), 691.2, "TestOptObjectByRefByVal(, B)") + TestUtil.AssertEqual(Format(TestOptObjectByRefByVal(cA, cB), "0.0"), 1270.2, "TestOptObjectByRefByVal(A, B)") ' optionals with array datatypes Dim aA(0 To 1) As Integer @@ -90,23 +96,21 @@ Sub verify_testOptionalsVba() aB(0) = 123.4 aB(1) = 567.8 ' TODO - New bug report? Scanner initializes variable not as an array - ' TestUtilModule.AssertEqual(TestOptArray(), 0, "TestOptArray()") - ' TestUtilModule.AssertEqual(TestOptArray(aA), 579, "TestOptArray(A)") - ' TestUtilModule.AssertEqual(Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)") - TestUtilModule.AssertEqual(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(Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)") + TestUtil.AssertEqual(Format(TestOptArray(aA, aB), "0.0"), 1270.2, "TestOptArray(A, B)") ' optionals with array datatypes (ByRef and ByVal) ' TODO - New bug report? Scanner initializes variable not as an array - ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()") - ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)") - ' TestUtilModule.AssertEqual(Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)") - TestUtilModule.AssertEqual(Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)") - - TestUtilModule.TestEnd + ' TestUtil.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()") + ' TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)") + ' TestUtil.AssertEqual(Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)") + TestUtil.AssertEqual(Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)") Exit Sub errorHandler: - TestUtilModule.AssertEqual(False, True, Err.Description) + TestUtil.ReportErrorHandler("verify_testOptionalsVba", Err, Error$, Erl) End Sub Function TestOptVariant(Optional A, Optional B As Variant = 123) @@ -192,4 +196,3 @@ Function ArraySum(is_missingC As Boolean, C) Next idx End If End Function - diff --git a/basic/qa/vba_tests/partition.vb b/basic/qa/vba_tests/partition.vb index a917f4dd64e2..a31b7a6c83f6 100644 --- a/basic/qa/vba_tests/partition.vb +++ b/basic/qa/vba_tests/partition.vb @@ -1,42 +1,30 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testPartition -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testPartition + doUnitTest = TestUtil.GetResult() End Function Sub verify_testPartition() - - TestUtilModule.TestInit - - Dim testName As String - Dim retStr As String - testName = "Test Partition function" On Error GoTo errorHandler - retStr = Partition(20, 0, 98, 5) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = "20:24", "the number 20 occurs in the range:" & retStr) - - retStr = Partition(20, 0, 99, 1) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = " 20: 20", "the number 20 occurs in the range:" & retStr) + TestUtil.AssertEqual(Partition(20, 0, 98, 5), "20:24", "Partition(20, 0, 98, 5)") + TestUtil.AssertEqual(Partition(20, 0, 99, 1), " 20: 20", "Partition(20, 0, 99, 1)") + TestUtil.AssertEqual(Partition(120, 0, 99, 5), "100: ", "Partition(120, 0, 99, 5)") + TestUtil.AssertEqual(Partition(-5, 0, 99, 5), " : -1", "Partition(-5, 0, 99, 5)") + TestUtil.AssertEqual(Partition(2, 0, 5, 2), " 2: 3", "Partition(2, 0, 5, 2)") - retStr = Partition(120, 0, 99, 5) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = "100: ", "the number 120 occurs in the range:" & retStr) - - retStr = Partition(-5, 0, 99, 5) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = " : -1", "the number -5 occurs in the range:" & retStr) - - retStr = Partition(2, 0, 5, 2) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = " 2: 3", "the number 2 occurs in the range:" & retStr) - TestUtilModule.TestEnd Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, "verify_testPartition failed, hit error handler") + TestUtil.ReportErrorHandler("verify_testPartition", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/qbcolor.vb b/basic/qa/vba_tests/qbcolor.vb index 92cea22d9b7f..64e213ad1a9a 100644 --- a/basic/qa/vba_tests/qbcolor.vb +++ b/basic/qa/vba_tests/qbcolor.vb @@ -1,60 +1,34 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testQBcolor -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testQBcolor + doUnitTest = TestUtil.GetResult() End Function Sub verify_testQBcolor() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Long - testName = "Test QBcolor function" On Error GoTo errorHandler - date2 = 0 - date1 = QBColor(0) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 8388608 - date1 = QBColor(1) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 32768 - date1 = QBColor(2) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 8421376 - date1 = QBColor(3) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 128 - date1 = QBColor(4) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 8388736 - date1 = QBColor(5) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 32896 - date1 = QBColor(6) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 12632256 - date1 = QBColor(7) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - date2 = 8421504 - date1 = QBColor(8) - TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(QBColor(0), 0, "QBColor(0)") + TestUtil.AssertEqual(QBColor(1), 8388608, "QBColor(1)") + TestUtil.AssertEqual(QBColor(2), 32768, "QBColor(2)") + TestUtil.AssertEqual(QBColor(3), 8421376, "QBColor(3)") + TestUtil.AssertEqual(QBColor(4), 128, "QBColor(4)") + TestUtil.AssertEqual(QBColor(5), 8388736, "QBColor(5)") + TestUtil.AssertEqual(QBColor(6), 32896, "QBColor(6)") + TestUtil.AssertEqual(QBColor(7), 12632256, "QBColor(7)") + TestUtil.AssertEqual(QBColor(8), 8421504, "QBColor(8)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testQBcolor", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/rate.vb b/basic/qa/vba_tests/rate.vb index 86da7e08a1d3..76f38cdb8da2 100644 --- a/basic/qa/vba_tests/rate.vb +++ b/basic/qa/vba_tests/rate.vb @@ -1,51 +1,31 @@ +' +' 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 VBASupport 1 -Rem Option VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testRATE -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testRATE + doUnitTest = TestUtil.GetResult() End Function Sub verify_testRATE() - - TestUtilModule.TestInit - - Dim testName As String - Dim TestDateTime As Date - Dim TestStr As String - Dim date1, date2 - testName = "Test RATE function" On Error GoTo errorHandler - date2 = 0.07 - date1 = Rate(3, -5, 0, 16) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - date2 = 0 - date1 = Rate(3, -5, 0, 15) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - date2 = 0.79 - date1 = Rate(3, -5, 0, 30) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - date2 = 1 - date1 = Rate(3, -5, 0, 35) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - date2 = 0.077 - date1 = Rate(4, -300, 1000, 0, 0) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - date2 = 0.14 - date1 = Rate(4, -300, 1000, 0, 1) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Rate(3, -5, 0, 16), 0.07, 1E-5, "Rate(3, -5, 0, 16)") + TestUtil.AssertEqualApprox(Rate(3, -5, 0, 15), 0, 1E-5, "Rate(3, -5, 0, 15)") + TestUtil.AssertEqualApprox(Rate(3, -5, 0, 30), 0.79, 1E-5, "Rate(3, -5, 0, 30)") + TestUtil.AssertEqualApprox(Rate(3, -5, 0, 35), 1, 1E-5, "Rate(3, -5, 0, 35)") + TestUtil.AssertEqualApprox(Rate(4, -300, 1000, 0, 0), 0.077, 1E-5, "Rate(4, -300, 1000, 0, 0)") + TestUtil.AssertEqualApprox(Rate(4, -300, 1000, 0, 1), 0.14, 1E-5, "Rate(4, -300, 1000, 0, 1)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testRATE", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/replace.vb b/basic/qa/vba_tests/replace.vb index f6b2fed2394a..ca1fde9c17ab 100644 --- a/basic/qa/vba_tests/replace.vb +++ b/basic/qa/vba_tests/replace.vb @@ -1,49 +1,37 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testReplace -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testReplace + doUnitTest = TestUtil.GetResult() End Function Sub verify_testReplace() - - TestUtilModule.TestInit - - Dim testName As String - Dim srcStr, destStr, repStr, start, count, retStr - testName = "Test Replace function" On Error GoTo errorHandler - srcStr = "abcbcdBc" - destStr = "bc" - repStr = "ef" - retStr = Replace(srcStr, destStr, repStr) - TestUtilModule.AssertTrue(retStr = "aefefdBc", "common string:" & retStr) - retStr = Replace("abcbcdbc", destStr, repStr) - TestUtilModule.AssertTrue(retStr = "aefefdef", "expression string:" & retStr) - retStr = Replace(srcStr, destStr, repStr, 1, -1, vbBinaryCompare) - TestUtilModule.AssertTrue(retStr = "aefefdBc", "binary compare:" & retStr) - retStr = Replace(srcStr, destStr, repStr, 1, -1, vbTextCompare) - TestUtilModule.AssertTrue(retStr = "aefefdef", "text compare:" & retStr) - retStr = Replace(srcStr, destStr, repStr, compare:=vbTextCompare) - TestUtilModule.AssertTrue(retStr = "aefefdef", "text compare:" & retStr) - retStr = Replace(srcStr, destStr, repStr, 3, -1, vbBinaryCompare) - TestUtilModule.AssertTrue(retStr = "cefdBc", "start = 3:" & retStr) - retStr = Replace(srcStr, destStr, repStr, 1, 2, vbBinaryCompare) - TestUtilModule.AssertTrue(retStr = "aefefdBc", "count = 2: " & retStr) - retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare) - TestUtilModule.AssertTrue(retStr = "abcbcdBc", "start = 1, count = 0, not support in Unix: " & retStr) - ' tdf#132389 - case-insensitive operation for non-ASCII characters - retStr = Replace("ABCabc", "b", "*", 1, 2, vbTextCompare) - TestUtilModule.AssertTrue(retStr = "A*Ca*c", "case-insensitive ASCII: " & retStr) - retStr = Replace("АБВабв", "б", "*", 1, 2, vbTextCompare) - TestUtilModule.AssertTrue(retStr = "А*Ва*в", "case-insensitive non-ASCII: " & retStr) + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef"), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"")") + TestUtil.AssertEqual(Replace("abcbcdbc", "bc", "ef"), "aefefdef", "Replace(""abcbcdbc"", ""bc"", ""ef"")") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbBinaryCompare), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbBinaryCompare)") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbTextCompare), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbTextCompare)") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", compare:=vbTextCompare), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", compare:=vbTextCompare)") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 3, -1, vbBinaryCompare), "cefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 3, -1, vbBinaryCompare)") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 2, vbBinaryCompare), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 2, vbBinaryCompare)") + TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 0, vbBinaryCompare), "abcbcdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 0, vbBinaryCompare)") ' not support in Unix - TestUtilModule.TestEnd + ' tdf#132389 - case-insensitive operation for non-ASCII characters + TestUtil.AssertEqual(Replace("ABCabc", "b", "*", 1, 2, vbTextCompare), "A*Ca*c", "Replace(""ABCabc"", ""b"", ""*"", 1, 2, vbTextCompare)") + TestUtil.AssertEqual(Replace("АБВабв", "б", "*", 1, 2, vbTextCompare), "А*Ва*в", "Replace(""АБВабв"", ""б"", ""*"", 1, 2, vbTextCompare)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testReplace", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/rgb.vb b/basic/qa/vba_tests/rgb.vb index 5ec9d590d123..448d19d064ae 100644 --- a/basic/qa/vba_tests/rgb.vb +++ b/basic/qa/vba_tests/rgb.vb @@ -1,39 +1,28 @@ +' +' 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 VBASupport 1 -Rem Option VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testRGB -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testRGB + doUnitTest = TestUtil.GetResult() End Function Sub verify_testRGB() - - TestUtilModule.TestInit - - Dim testName As String - Dim TestDateTime As Date - Dim TestStr As String - Dim date1, date2 - testName = "Test RGB function" On Error GoTo errorHandler - date2 = 255 - date1 = RGB(255, 0, 0) - TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1) - - date2 = 13339467 - date1 = RGB(75, 139, 203) - TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1) - - date2 = 16777215 - date1 = RGB(255, 255, 255) - TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(RGB(255, 0, 0), 255, "RGB(255, 0, 0)") + TestUtil.AssertEqual(RGB(75, 139, 203), 13339467, "RGB(75, 139, 203)") + TestUtil.AssertEqual(RGB(255, 255, 255), 16777215, "RGB(255, 255, 255)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testRGB", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/right.vb b/basic/qa/vba_tests/right.vb index 79bcaa2d4015..c7cb583724d1 100644 --- a/basic/qa/vba_tests/right.vb +++ b/basic/qa/vba_tests/right.vb @@ -1,36 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testRight -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testRight + doUnitTest = TestUtil.GetResult() End Function Sub verify_testRight() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Right function" On Error GoTo errorHandler - date2 = "text" - date1 = Right("sometext", 4) - TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1) - - date2 = "sometext" - date1 = Right("sometext", 48) - TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1) - - date2 = "" - date1 = Right("", 4) - TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Right("sometext", 4), "text", "Right(""sometext"", 4)") + TestUtil.AssertEqual(Right("sometext", 48), "sometext", "Right(""sometext"", 48)") + TestUtil.AssertEqual(Right("", 4), "", "Right("""", 4)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testRight", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/rtrim.vb b/basic/qa/vba_tests/rtrim.vb index 38185b4cb46e..1daf40e564b1 100644 --- a/basic/qa/vba_tests/rtrim.vb +++ b/basic/qa/vba_tests/rtrim.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testRTrim -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testRTrim + doUnitTest = TestUtil.GetResult() End Function Sub verify_testRTrim() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test RTrim function" On Error GoTo errorHandler - date2 = " some text" - date1 = RTrim(" some text ") - TestUtilModule.AssertTrue(date1 = date2, "the return RTrim is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(RTrim(" some text "), " some text", "RTrim("" some text "")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testRTrim", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/second.vb b/basic/qa/vba_tests/second.vb index ab7025a41f23..b192ef5d4165 100644 --- a/basic/qa/vba_tests/second.vb +++ b/basic/qa/vba_tests/second.vb @@ -1,32 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSecond -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSecond + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSecond() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Second function" On Error GoTo errorHandler - date2 = 0 - date1 = Second(37566.3) - TestUtilModule.AssertTrue(date1 = date2, "the return Second is: " & date1) - - date2 = 17 - date1 = Second("4:35:17") - TestUtilModule.AssertTrue(date1 = date2, "the return Second is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Second(37566.3), 0, "Second(37566.3)") + TestUtil.AssertEqual(Second("4:35:17"), 17, "Second(""4:35:17"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSecond", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/sgn.vb b/basic/qa/vba_tests/sgn.vb index e15962d502fe..e0475cb7f609 100644 --- a/basic/qa/vba_tests/sgn.vb +++ b/basic/qa/vba_tests/sgn.vb @@ -1,44 +1,30 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_SGN -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_SGN + doUnitTest = TestUtil.GetResult() End Function Sub verify_SGN() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test SGN function" On Error GoTo errorHandler - date2 = 0 - date1 = sgn(0) - TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1) - - date2 = -1 - date1 = sgn(-1) - TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1) - - date2 = 1 - date1 = sgn(1) - TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1) - - date2 = 1 - date1 = sgn(50) - TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1) - - date2 = -1 - date1 = sgn(-50) - TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(sgn(0), 0, "sgn(0)") + TestUtil.AssertEqual(sgn(-1), -1, "sgn(-1)") + TestUtil.AssertEqual(sgn(1), 1, "sgn(1)") + TestUtil.AssertEqual(sgn(50), 1, "sgn(50)") + TestUtil.AssertEqual(sgn(-50), -1, "sgn(-50)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_SGN", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/sin.vb b/basic/qa/vba_tests/sin.vb index 48bf6058e992..0f416a05c328 100644 --- a/basic/qa/vba_tests/sin.vb +++ b/basic/qa/vba_tests/sin.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSIN -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSIN + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSIN() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test SIN function" On Error GoTo errorHandler - date2 = 0.43 - date1 = Sin(0.45) - TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return SIN is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqualApprox(Sin(0.45), 0.43496553411123, 1E-14, "Sin(0.45)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSIN", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/space.vb b/basic/qa/vba_tests/space.vb index 9a655ee2afe5..70d09c3ea74e 100644 --- a/basic/qa/vba_tests/space.vb +++ b/basic/qa/vba_tests/space.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSpace -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSpace + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSpace() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Space function" On Error GoTo errorHandler - date2 = " " - date1 = Space(2) - TestUtilModule.AssertTrue(date1 = date2, "the return Space is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Space(2), " ", "Space(2)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSpace", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/sqr.vb b/basic/qa/vba_tests/sqr.vb index 9ab8aa3bc329..f7df49148b53 100644 --- a/basic/qa/vba_tests/sqr.vb +++ b/basic/qa/vba_tests/sqr.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSQR -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSQR + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSQR() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test SQR function" On Error GoTo errorHandler - date2 = 3 - date1 = Sqr(9) - TestUtilModule.AssertTrue(date1 = date2, "the return SQR is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Sqr(9), 3, "Sqr(9)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSQR", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/str.vb b/basic/qa/vba_tests/str.vb index 0cd013606730..1a336e9e3705 100644 --- a/basic/qa/vba_tests/str.vb +++ b/basic/qa/vba_tests/str.vb @@ -1,40 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSTR -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSTR + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSTR() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test STR function" On Error GoTo errorHandler - date2 = " 459" - date1 = Str(459) - TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1) - - date2 = "-459.65" - date1 = Str(-459.65) - TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1) - - date2 = " 459.001" - date1 = Str(459.001) - TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1) - - date2 = " .24" - date1 = Str(0.24) - TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Str(459), " 459", "Str(459)") + TestUtil.AssertEqual(Str(-459.65), "-459.65", "Str(-459.65)") + TestUtil.AssertEqual(Str(459.001), " 459.001", "Str(459.001)") + TestUtil.AssertEqual(Str(0.24), " .24", "Str(0.24)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSTR", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/strcomp.vb b/basic/qa/vba_tests/strcomp.vb index e6c2d32308af..0c77577c1921 100644 --- a/basic/qa/vba_tests/strcomp.vb +++ b/basic/qa/vba_tests/strcomp.vb @@ -1,63 +1,34 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSTRcomp -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSTRcomp + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSTRcomp() - - TestUtilModule.TestInit - - Dim testName As String - Dim TestStr, TestStr1, TestStr2 As String - Dim date1, date2 - testName = "Test STRcomp function" On Error GoTo errorHandler - TestStr1 = "ABCD" - TestStr2 = "abcd" - - date2 = 0 - date1 = StrComp(TestStr1, TestStr2, vbTextCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = -1 - date1 = StrComp(TestStr1, TestStr2, vbBinaryCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = -1 - date1 = StrComp(TestStr1, TestStr2) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = 0 - date1 = StrComp("text", "text", vbBinaryCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - date2 = 1 - date1 = StrComp("text ", "text", vbBinaryCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = -1 - date1 = StrComp("Text", "text", vbBinaryCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = 0 - date1 = StrComp("text", "text", vbTextCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = 1 - date1 = StrComp("text ", "text", vbTextCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - date2 = 0 - date1 = StrComp("Text", "text", vbTextCompare) - TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(StrComp("ABCD", "abcd", vbTextCompare), 0, "StrComp(""ABCD"", ""abcd"", vbTextCompare)") + TestUtil.AssertEqual(StrComp("ABCD", "abcd", vbBinaryCompare), -1, "StrComp(""ABCD"", ""abcd"", vbBinaryCompare)") + TestUtil.AssertEqual(StrComp("ABCD", "abcd"), -1, "StrComp(""ABCD"", ""abcd"")") + TestUtil.AssertEqual(StrComp("text", "text", vbBinaryCompare), 0, "StrComp(""text"", ""text"", vbBinaryCompare)") + TestUtil.AssertEqual(StrComp("text ", "text", vbBinaryCompare), 1, "StrComp(""text "", ""text"", vbBinaryCompare)") + TestUtil.AssertEqual(StrComp("Text", "text", vbBinaryCompare), -1, "StrComp(""Text"", ""text"", vbBinaryCompare)") + TestUtil.AssertEqual(StrComp("text", "text", vbTextCompare), 0, "StrComp(""text"", ""text"", vbTextCompare)") + TestUtil.AssertEqual(StrComp("text ", "text", vbTextCompare), 1, "StrComp(""text "", ""text"", vbTextCompare)") + TestUtil.AssertEqual(StrComp("Text", "text", vbTextCompare), 0, "StrComp(""Text"", ""text"", vbTextCompare)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSTRcomp", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb index 0a9e5628a966..9bb6f9649a1d 100644 --- a/basic/qa/vba_tests/strconv.vb +++ b/basic/qa/vba_tests/strconv.vb @@ -1,62 +1,45 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testStrConv -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testStrConv + doUnitTest = TestUtil.GetResult() End Function Sub verify_testStrConv() - - TestUtilModule.TestInit - - Dim testName As String - Dim srcStr, retStr As String - Dim x() As Byte - srcStr = "abc EFG hij" - testName = "Test StrConv function" On Error GoTo errorHandler - retStr = StrConv(srcStr, vbUpperCase) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = "ABC EFG HIJ", "Converts the string to uppercase characters:" & retStr) - - retStr = StrConv(srcStr, vbLowerCase) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = "abc efg hij", "Converts the string to lowercase characters:" & retStr) + TestUtil.AssertEqual(StrConv("abc EFG hij", vbUpperCase), "ABC EFG HIJ", "StrConv(""abc EFG hij"", vbUpperCase)") + TestUtil.AssertEqual(StrConv("abc EFG hij", vbLowerCase), "abc efg hij", "StrConv(""abc EFG hij"", vbLowerCase)") + TestUtil.AssertEqual(StrConv("abc EFG hij", vbProperCase), "Abc Efg Hij", "StrConv(""abc EFG hij"", vbProperCase)") - retStr = StrConv(srcStr, vbProperCase) - 'MsgBox retStr - TestUtilModule.AssertTrue(retStr = "Abc Efg Hij", "Converts the first letter of every word in string to uppercase:" & retStr) + ' Converts narrow (single-byte) characters in string to wide + 'TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥¥å©`", vbWide), "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", "StrConv(""ABCDEVB¥ì¥¹¥¥å©`"", vbWide)") - 'retStr = StrConv("ABCDEVB¥ì¥¹¥¥å©`", vbWide) - 'MsgBox retStr - 'TestUtilModule.AssertTrue(retStr = "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", "Converts narrow (single-byte) characters in string to wide") + ' Converts wide (double-byte) characters in string to narrow (single-byte) characters + 'TestUtil.AssertEqual(StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", vbNarrow), "ABCDEVB¥ì¥¹¥¥å©`", "StrConv(""£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`"", vbNarrow)") - 'retStr = StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", vbNarrow) - 'MsgBox retStr - 'TestUtilModule.AssertTrue(retStr = "ABCDEVB¥ì¥¹¥¥å©`", "Converts wide (double-byte) characters in string to narrow (single-byte) characters." & retStr) + ' Converts Hiragana characters in string to Katakana characters + 'TestUtil.AssertEqual(StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana), "¥Ï¥Ê¥Á¥ã¥ó", "StrConv(""¤Ï¤Ê¤Á¤ã¤ó"", vbKatakana)") - 'retStr = StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana) - 'MsgBox retStr - 'TestUtilModule.AssertTrue(retStr = "¥Ï¥Ê¥Á¥ã¥ó", "Converts Hiragana characters in string to Katakana characters.." & retStr) - - ' retStr = StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana) - 'MsgBox retStr - ' TestUtilModule.AssertTrue(retStr = "¤Ï¤Ê¤Á¤ã¤ó", "Converts Katakana characters in string to Hiragana characters.." & retStr) + ' Converts Katakana characters in string to Hiragana characters + 'TestUtil.AssertEqual(StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana), "¤Ï¤Ê¤Á¤ã¤ó", "StrConv(""¥Ï¥Ê¥Á¥ã¥ó"", vbHiragana)") + 'Dim x() As Byte 'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode) - 'MsgBox retStr - 'TestUtilModule.AssertTrue(UBound(x) = 8, "Converts the string from Unicode, the length is : " & UBound(x) + 1) - - ' retStr = StrConv(x, vbUnicode) - 'MsgBox retStr - ' TestUtilModule.AssertTrue(retStr = "ÉϺ£ÊÐABC", "Converts the string to Unicode: " & retStr) - - TestUtilModule.TestEnd + 'TestUtil.AssertEqual(UBound(x), 8, "UBound(x)") + 'TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, vbUnicode)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testStrConv", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/string.vb b/basic/qa/vba_tests/string.vb index f6e9d5376011..eca3fce3baec 100644 --- a/basic/qa/vba_tests/string.vb +++ b/basic/qa/vba_tests/string.vb @@ -1,37 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testString -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testString + doUnitTest = TestUtil.GetResult() End Function Sub verify_testString() - - TestUtilModule.TestInit - - Dim testName As String - Dim TestStr As String - Dim date1, date2 - testName = "Test String function" On Error GoTo errorHandler - date2 = "PPPPP" - date1 = String(5, "P") - TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1) - - date2 = "aaaaa" - date1 = String(5, "a") - TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1) - - date2 = "" - date1 = String(0, "P") - TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(String(5, "P"), "PPPPP", "String(5, ""P"")") + TestUtil.AssertEqual(String(5, "a"), "aaaaa", "String(5, ""a"")") + TestUtil.AssertEqual(String(0, "P"), "", "String(0, ""P"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testString", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/stringplusdouble.vb b/basic/qa/vba_tests/stringplusdouble.vb index bee43d1c5fc1..7c5045eadd42 100644 --- a/basic/qa/vba_tests/stringplusdouble.vb +++ b/basic/qa/vba_tests/stringplusdouble.vb @@ -1,253 +1,203 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_stringplusdouble -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + DSD ' double = string + double + SSD ' string = string + double + DSS ' double = string + string + doUnitTest = TestUtil.GetResult() End Function -Sub verify_stringplusdouble() - - TestUtilModule.TestInit - - DSD - SSD - DSS - TestUtilModule.TestEnd -End Sub - Sub DSD() - Dim testName As String - testName = "double = string + double" - Dim testCompute As String - Dim s As String Dim d As Double Dim r As Double On Error GoTo ErrorHandler - testCompute = "s = null, d = null, r = s + d" r = s + d - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d") - testCompute = "s = null, d = null, r = s & d" r = s & d - TestUtilModule.AssertTrue(r = 0, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 0, "s = null, d = null, r = s & d") - testCompute = "s = null, d = 20, r = s + d" d = 20 r = s + d - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = null, d = 20, r = s + d") - testCompute = "s = null, d = 20, r = s & d" d = 20 r = s & d - TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d") '''''''''''''' s = "10" Dim d2 As Double - testCompute = "s = '10', d = null, r = s + d" r = s + d2 - TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d") - testCompute = "s = '10', d = null, r = s & d" r = s & d2 - TestUtilModule.AssertTrue(r = 100, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 100, "s = '10', d = null, r = s & d") - testCompute = "s = '10', d = 20, r = s + d" d2 = 20 r = s + d2 - TestUtilModule.AssertTrue(r = 30, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 30, "s = '10', d = 20, r = s + d") - testCompute = "s = '10', d = 20, r = s & d" d2 = 20 r = s & d2 - TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d") '''''''''''''' s = "abc" Dim d3 As Double - testCompute = "s = 'abc', d = null, r = s + d" r = s + d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d") - testCompute = "s = 'abc', d = null, r = s & d" r = s & d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d") - testCompute = "s = 'abc', d = 20, r = s + d" d3 = 20 r = s + d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d") - testCompute = "s = 'abc', d = 20, r = s & d" d3 = 20 r = s & d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d") Exit Sub ErrorHandler: r = -1 -' TestLog_Comment "The next compute raises error: " & testCompute Resume Next End Sub Sub SSD() - Dim testName As String - testName = "string = string + double" - Dim testCompute As String - Dim s As String Dim d As Double Dim r As String On Error GoTo ErrorHandler - testCompute = "s = null, d = null, r = s + d" r = s + d - TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "-1", "s = null, d = null, r = s + d") - testCompute = "s = null, d = null, r = s & d" r = s & d - TestUtilModule.AssertTrue(r = "0", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "0", "s = null, d = null, r = s & d") - testCompute = "s = null, d = 20, r = s + d" d = 20 r = s + d - TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "-1", "s = null, d = 20, r = s + d") - testCompute = "s = null, d = 20, r = s & d" d = 20 r = s & d - TestUtilModule.AssertTrue(r = "20", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "20", "s = null, d = 20, r = s & d") '''''''''''''' s = "10" Dim d2 As Double - testCompute = "s = '10', d = null, r = s + d" r = s + d2 - TestUtilModule.AssertTrue(r = "10", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "10", "s = '10', d = null, r = s + d") - testCompute = "s = '10', d = null, r = s & d" r = s & d2 - TestUtilModule.AssertTrue(r = "100", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "100", "s = '10', d = null, r = s & d") - testCompute = "s = '10', d = 20, r = s + d" d2 = 20 r = s + d2 - TestUtilModule.AssertTrue(r = "30", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "30", "s = '10', d = 20, r = s + d") - testCompute = "s = '10', d = 20, r = s & d" d2 = 20 r = s & d2 - TestUtilModule.AssertTrue(r = "1020", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "1020", "s = '10', d = 20, r = s & d") '''''''''''''' s = "abc" Dim d3 As Double - testCompute = "s = 'abc', d = null, r = s + d" r = s + d3 - TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "-1", "s = 'abc', d = null, r = s + d") - testCompute = "s = 'abc', d = null, r = s & d" r = s & d3 - TestUtilModule.AssertTrue(r = "abc0", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "abc0", "s = 'abc', d = null, r = s & d") - testCompute = "s = 'abc', d = 20, r = s + d" d3 = 20 r = s + d3 - TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "-1", "s = 'abc', d = 20, r = s + d") - testCompute = "s = 'abc', d = 20, r = s & d" d3 = 20 r = s & d3 - TestUtilModule.AssertTrue(r = "abc20", testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, "abc20", "s = 'abc', d = 20, r = s & d") Exit Sub ErrorHandler: r = "-1" -' TestLog_Comment "The next compute raises error: " & testCompute Resume Next End Sub Sub DSS() - Dim testName As String - testName = "double = string + string" - Dim testCompute As String - Dim s As String Dim d As String Dim r As Double On Error GoTo ErrorHandler - testCompute = "s = null, d = null, r = s + d" r = s + d - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d") - testCompute = "s = null, d = null, r = s & d" r = s & d - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s & d") - testCompute = "s = null, d = 20, r = s + d" d = "20" r = s + d - TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s + d") - testCompute = "s = null, d = 20, r = s & d" d = "20" r = s & d - TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d") '''''''''''''' s = "10" Dim d2 As String - testCompute = "s = '10', d = null, r = s + d" r = s + d2 - TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d") - testCompute = "s = '10', d = null, r = s & d" r = s & d2 - TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s & d") - testCompute = "s = '10', d = 20, r = s + d" d2 = "20" r = s + d2 - TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s + d") - testCompute = "s = '10', d = 20, r = s & d" d2 = "20" r = s & d2 - TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d") '''''''''''''' s = "abc" Dim d3 As String - testCompute = "s = 'abc', d = null, r = s + d" r = s + d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d") - testCompute = "s = 'abc', d = null, r = s & d" r = s & d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d") - testCompute = "s = 'abc', d = 20, r = s + d" d3 = "20" r = s + d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d") - testCompute = "s = 'abc', d = 20, r = s & d" d3 = "20" r = s & d3 - TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r) + TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d") Exit Sub ErrorHandler: r = -1 -' TestLog_Comment "The next compute raises error: " & testCompute Resume Next End Sub @@ -291,4 +241,3 @@ Sub testCurrency() MsgBox d End Sub - diff --git a/basic/qa/vba_tests/strreverse.vb b/basic/qa/vba_tests/strreverse.vb index fb143facf9a9..ad78bdf8d44c 100644 --- a/basic/qa/vba_tests/strreverse.vb +++ b/basic/qa/vba_tests/strreverse.vb @@ -1,40 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testStrReverse -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testStrReverse + doUnitTest = TestUtil.GetResult() End Function Sub verify_testStrReverse() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test StrReverse function" On Error GoTo errorHandler - date2 = "dcba" - date1 = StrReverse("abcd") - TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1) - - date2 = "BABABA" - date1 = StrReverse("ABABAB") - TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1) - - date2 = "654321" - date1 = StrReverse("123456") - TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1) - - date2 = "6" - date1 = StrReverse(6) - TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(StrReverse("abcd"), "dcba", "StrReverse(""abcd"")") + TestUtil.AssertEqual(StrReverse("ABABAB"), "BABABA", "StrReverse(""ABABAB"")") + TestUtil.AssertEqual(StrReverse("123456"), "654321", "StrReverse(""123456"")") + TestUtil.AssertEqual(StrReverse(6), "6", "StrReverse(6)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testStrReverse", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/switch.vb b/basic/qa/vba_tests/switch.vb index 3add8cba7e52..45b1bc05acb5 100644 --- a/basic/qa/vba_tests/switch.vb +++ b/basic/qa/vba_tests/switch.vb @@ -1,33 +1,32 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testSwitch -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testSwitch + doUnitTest = TestUtil.GetResult() End Function Sub verify_testSwitch() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Switch function" On Error GoTo errorHandler - date2 = "French" - date1 = MatchUp("Paris") - TestUtilModule.AssertTrue(date1 = date2, "the return Switch is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(MatchUp("Paris"), "French", "MatchUp(""Paris"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testSwitch", Err, Error$, Erl) End Sub Function MatchUp(CityName As String) - MatchUp = Switch(CityName = "London", "English", CityName _ - = "Rome", "Italian", CityName = "Paris", "French") + MatchUp = Switch(CityName = "London", "English", _ + CityName = "Rome", "Italian", _ + CityName = "Paris", "French") End Function - diff --git a/basic/qa/vba_tests/timeserial.vb b/basic/qa/vba_tests/timeserial.vb index d0dafad7a70d..be2c9d2bc8cf 100644 --- a/basic/qa/vba_tests/timeserial.vb +++ b/basic/qa/vba_tests/timeserial.vb @@ -1,37 +1,35 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testTimeSerial -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testTimeSerial + doUnitTest = TestUtil.GetResult() End Function Sub verify_testTimeSerial() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 As Date - testName = "Test TimeSerial function" + Dim timeVal As Date On Error GoTo errorHandler rem bug 114229 -rem date2 = "5:45:00" -rem date1 = (TimeSerial(12 - 6, -15, 0)) -rem TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1) +rem timeVal = "5:45:00" +rem TestUtil.AssertEqual(TimeSerial(12 - 6, -15, 0), timeVal, "TimeSerial(12 - 6, -15, 0)") - date2 = "12:30:00" - date1 = TimeSerial(12, 30, 0) - TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1) + timeVal = "12:30:00" + TestUtil.AssertEqual(TimeSerial(12, 30, 0), timeVal, "TimeSerial(12, 30, 0)") -rem date2 = "11:30:00" -rem date1 = TimeSerial(10, 90, 0) -rem TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1) - - TestUtilModule.TestEnd +rem timeVal = "11:30:00" +rem TestUtil.AssertEqual(TimeSerial(10, 90, 0), timeVal, "TimeSerial(10, 90, 0)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testTimeSerial", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/timevalue.vb b/basic/qa/vba_tests/timevalue.vb index a44cdabd5c84..e53d55b27239 100644 --- a/basic/qa/vba_tests/timevalue.vb +++ b/basic/qa/vba_tests/timevalue.vb @@ -1,29 +1,28 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testTimeValue -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testTimeValue + doUnitTest = TestUtil.GetResult() End Function Sub verify_testTimeValue() - - TestUtilModule.TestInit - - Dim testName As String - - Dim date1, date2 As Date 'variables for test - testName = "Test TimeValue function" + Dim timeVal As Date On Error GoTo errorHandler - date2 = "16:35:17" - date1 = TimeValue("4:35:17 PM") - TestUtilModule.AssertTrue(date1 = date2, "the return TimeValue is: " & date1) - - TestUtilModule.TestEnd + timeVal = "16:35:17" + TestUtil.AssertEqual(TimeValue("4:35:17 PM"), timeVal, "TimeValue(""4:35:17 PM"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testTimeValue", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/trim.vb b/basic/qa/vba_tests/trim.vb index 4c11ab8cd4b7..d5f3a32ac9c5 100644 --- a/basic/qa/vba_tests/trim.vb +++ b/basic/qa/vba_tests/trim.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testTrim -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testTrim + doUnitTest = TestUtil.GetResult() End Function Sub verify_testTrim() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Trim function" On Error GoTo errorHandler - date2 = "some text" - date1 = Trim(" some text ") - TestUtilModule.AssertTrue(date1 = date2, "the return Trim is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Trim(" some text "), "some text", "Trim("" some text "")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testTrim", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb index 117d432ec423..c8fa5330a8e8 100644 --- a/basic/qa/vba_tests/typename.vb +++ b/basic/qa/vba_tests/typename.vb @@ -1,18 +1,21 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testTypeName -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testTypeName + doUnitTest = TestUtil.GetResult() End Function Sub verify_testTypeName() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test TypeName function" On Error GoTo errorHandler Dim b1 As Boolean Dim c1 As Byte @@ -20,45 +23,23 @@ Sub verify_testTypeName() Dim d2 As Double Dim i1 As Integer Dim l1 As Long + Dim s1 As String - date2 = "String" - date1 = TypeName(testName) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Boolean" - date1 = TypeName(b1) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Byte" - date1 = TypeName(c1) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Date" - date1 = TypeName(d1) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Double" - date1 = TypeName(d2) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Integer" - date1 = TypeName(i1) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) - - date2 = "Long" - date1 = TypeName(l1) - TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1) + TestUtil.AssertEqual(TypeName(s1), "String", "TypeName(s1)") + TestUtil.AssertEqual(TypeName(b1), "Boolean", "TypeName(b1)") + TestUtil.AssertEqual(TypeName(c1), "Byte", "TypeName(c1)") + TestUtil.AssertEqual(TypeName(d1), "Date", "TypeName(d1)") + TestUtil.AssertEqual(TypeName(d2), "Double", "TypeName(d2)") + TestUtil.AssertEqual(TypeName(i1), "Integer", "TypeName(i1)") + TestUtil.AssertEqual(TypeName(l1), "Long", "TypeName(l1)") ' tdf#129596 - Types of constant values - TestUtilModule.AssertTrue(TypeName(32767) = "Integer", "the return TypeName(32767) is: " & TypeName(32767)) - TestUtilModule.AssertTrue(TypeName(-32767) = "Integer", "the return TypeName(-32767) is: " & TypeName(-32767)) - TestUtilModule.AssertTrue(TypeName(1048575) = "Long", "the return TypeName(1048575) is: " & TypeName(1048575)) - TestUtilModule.AssertTrue(TypeName(-1048575) = "Long", "the return TypeName(-1048575) is: " & TypeName(-1048575)) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(TypeName(32767), "Integer", "TypeName(32767)") + TestUtil.AssertEqual(TypeName(-32767), "Integer", "TypeName(-32767)") + TestUtil.AssertEqual(TypeName(1048575), "Long", "TypeName(1048575)") + TestUtil.AssertEqual(TypeName(-1048575), "Long", "TypeName(-1048575)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testTypeName", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/ubound.vb b/basic/qa/vba_tests/ubound.vb index 9eb954b04bf9..587940699679 100644 --- a/basic/qa/vba_tests/ubound.vb +++ b/basic/qa/vba_tests/ubound.vb @@ -1,37 +1,29 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testUBound -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testUBound + doUnitTest = TestUtil.GetResult() End Function Sub verify_testUBound() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test UBound function" On Error GoTo errorHandler Dim A(1 To 100, 0 To 3, -3 To 4) - date2 = 100 - date1 = UBound(A, 1) - TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1) - - date2 = 3 - date1 = UBound(A, 2) - TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1) - - date2 = 4 - date1 = UBound(A, 3) - TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(UBound(A, 1), 100, "UBound(A, 1)") + TestUtil.AssertEqual(UBound(A, 2), 3, "UBound(A, 2)") + TestUtil.AssertEqual(UBound(A, 3), 4, "UBound(A, 3)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testUBound", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/ucase.vb b/basic/qa/vba_tests/ucase.vb index f8376258393d..7f898ea7efed 100644 --- a/basic/qa/vba_tests/ucase.vb +++ b/basic/qa/vba_tests/ucase.vb @@ -1,28 +1,26 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testUCase -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testUCase + doUnitTest = TestUtil.GetResult() End Function Sub verify_testUCase() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test UCase function" On Error GoTo errorHandler - date2 = "HELLO 12" - date1 = UCase("hello 12") '2/12/1969 - TestUtilModule.AssertTrue(date1 = date2, "the return UCase is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(UCase("hello 12"), "HELLO 12", "UCase(""hello 12"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testUCase", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/val.vb b/basic/qa/vba_tests/val.vb index b50b93b3334c..473f1612309d 100644 --- a/basic/qa/vba_tests/val.vb +++ b/basic/qa/vba_tests/val.vb @@ -1,60 +1,35 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testVal -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testVal + doUnitTest = TestUtil.GetResult() End Function Sub verify_testVal() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Val function" On Error GoTo errorHandler - date2 = 2 - date1 = Val("02/04/2010") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 1050 - date1 = Val("1050") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 130.75 - date1 = Val("130.75") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 50 - date1 = Val("50 Park Lane") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 1320 - date1 = Val("1320 then some text") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 0 - date1 = Val("L13.5") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - - date2 = 0 - date1 = Val("sometext") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - -REM date2 = 1 -REM date1 = Val("1, 2") -REM TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) -REM tdf#111999 - - date2 = -1 - date1 = Val("&HFFFF") - TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1) - TestUtilModule.TestEnd + TestUtil.AssertEqual(Val("02/04/2010"), 2, "Val(""02/04/2010"")") + TestUtil.AssertEqual(Val("1050"), 1050, "Val(""1050"")") + TestUtil.AssertEqual(Val("130.75"), 130.75, "Val(""130.75"")") + TestUtil.AssertEqual(Val("50 Park Lane"), 50, "Val(""50 Park Lane"")") + TestUtil.AssertEqual(Val("1320 then some text"), 1320, "Val(""1320 then some text"")") + TestUtil.AssertEqual(Val("L13.5"), 0, "Val(""L13.5"")") + TestUtil.AssertEqual(Val("sometext"), 0, "Val(""sometext"")") +REM tdf#111999 +REM TestUtil.AssertEqual(Val("1, 2"), 1, "Val(""1, 2"")") + TestUtil.AssertEqual(Val("&HFFFF"), -1, "Val(""&HFFFF"")") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testVal", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/vartype.vb b/basic/qa/vba_tests/vartype.vb index b012be3374c0..c392772ec27d 100644 --- a/basic/qa/vba_tests/vartype.vb +++ b/basic/qa/vba_tests/vartype.vb @@ -1,54 +1,37 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testVarType -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testVarType + doUnitTest = TestUtil.GetResult() End Function Sub verify_testVarType() - - TestUtilModule.TestInit - - Dim testName As String Dim TestDateTime As Date Dim TestStr As String Dim TestInt As Integer Dim TestLong As Long Dim TestDouble As Double Dim TestBoo As Boolean - Dim date1, date2 - testName = "Test VarType function" On Error GoTo errorHandler - date2 = 8 - date1 = VarType(testName) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - date2 = 11 - date1 = VarType(TestBoo) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - date2 = 5 - date1 = VarType(TestDouble) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - date2 = 3 - date1 = VarType(TestLong) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - date2 = 2 - date1 = VarType(TestInt) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - date2 = 7 - date1 = VarType(TestDateTime) - TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(VarType(TestStr), 8, "VarType(TestStr)") + TestUtil.AssertEqual(VarType(TestBoo), 11, "VarType(TestBoo)") + TestUtil.AssertEqual(VarType(TestDouble), 5, "VarType(TestDouble)") + TestUtil.AssertEqual(VarType(TestLong), 3, "VarType(TestLong)") + TestUtil.AssertEqual(VarType(TestInt), 2, "VarType(TestInt)") + TestUtil.AssertEqual(VarType(TestDateTime), 7, "VarType(TestDateTime)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testVarType", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/weekday.vb b/basic/qa/vba_tests/weekday.vb index 55158d985e57..2ff4fbe4703e 100644 --- a/basic/qa/vba_tests/weekday.vb +++ b/basic/qa/vba_tests/weekday.vb @@ -1,48 +1,31 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testWeekDay -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testWeekDay + doUnitTest = TestUtil.GetResult() End Function Sub verify_testWeekDay() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test WeekDay function" On Error GoTo errorHandler - date2 = 7 - date1 = Weekday(#6/7/2009#, vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - date2 = 2 - date1 = Weekday(#7/7/2009#, vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - date2 = 5 - date1 = Weekday(#8/7/2009#, vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - date2 = 1 - date1 = Weekday(#12/7/2009#, vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - date2 = 1 - date1 = Weekday(#6/7/2009#, vbSunday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - date2 = 5 - date1 = Weekday(#6/7/2009#, 4) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Weekday(#6/7/2009#, vbMonday), 7, "Weekday(#6/7/2009#, vbMonday)") + TestUtil.AssertEqual(Weekday(#7/7/2009#, vbMonday), 2, "Weekday(#7/7/2009#, vbMonday)") + TestUtil.AssertEqual(Weekday(#8/7/2009#, vbMonday), 5, "Weekday(#8/7/2009#, vbMonday)") + TestUtil.AssertEqual(Weekday(#12/7/2009#, vbMonday), 1, "Weekday(#12/7/2009#, vbMonday)") + TestUtil.AssertEqual(Weekday(#6/7/2009#, vbSunday), 1, "Weekday(#6/7/2009#, vbSunday)") + TestUtil.AssertEqual(Weekday(#6/7/2009#, 4), 5, "Weekday(#6/7/2009#, 4)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testWeekDay", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/weekdayname.vb b/basic/qa/vba_tests/weekdayname.vb index 6adb460c7631..5cc7bd9571fe 100644 --- a/basic/qa/vba_tests/weekdayname.vb +++ b/basic/qa/vba_tests/weekdayname.vb @@ -1,52 +1,32 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testWeekDayName -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testWeekDayName + doUnitTest = TestUtil.GetResult() End Function Sub verify_testWeekDayName() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test WeekDayName function" On Error GoTo errorHandler - date2 = "Sunday" - date1 = WeekdayName(1) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Sunday" - date1 = WeekdayName(1, , vbSunday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Monday" - date1 = WeekdayName(1, , vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Monday" - date1 = WeekdayName(2) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Tue" - date1 = WeekdayName(2, True, vbMonday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Wed" - date1 = WeekdayName(2, True, vbTuesday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - date2 = "Thu" - date1 = WeekdayName(2, True, vbWednesday) - TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(WeekdayName(1), "Sunday", "WeekdayName(1)") + TestUtil.AssertEqual(WeekdayName(1, , vbSunday), "Sunday", "WeekdayName(1, , vbSunday)") + TestUtil.AssertEqual(WeekdayName(1, , vbMonday), "Monday", "WeekdayName(1, , vbMonday)") + TestUtil.AssertEqual(WeekdayName(2), "Monday", "WeekdayName(2)") + TestUtil.AssertEqual(WeekdayName(2, True, vbMonday), "Tue", "WeekdayName(2, True, vbMonday)") + TestUtil.AssertEqual(WeekdayName(2, True, vbTuesday), "Wed", "WeekdayName(2, True, vbTuesday)") + TestUtil.AssertEqual(WeekdayName(2, True, vbWednesday), "Thu", "WeekdayName(2, True, vbWednesday)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testWeekDayName", Err, Error$, Erl) End Sub - diff --git a/basic/qa/vba_tests/win32compat.vb b/basic/qa/vba_tests/win32compat.vb index 067c53e48674..020c1245ba59 100644 --- a/basic/qa/vba_tests/win32compat.vb +++ b/basic/qa/vba_tests/win32compat.vb @@ -1,6 +1,3 @@ -Option VBASupport 1 -Option Explicit - ' ' This file is part of the LibreOffice project. ' @@ -13,17 +10,19 @@ Option Explicit ' the system. ' +Option VBASupport 1 +Option Explicit + Private Declare Function QueryPerformanceCounter Lib "kernel32" (ByRef lpPerformanceCount As Currency) As Long Private Declare Function QueryPerformanceFrequency Lib "kernel32" (ByRef lpFrequency As Currency) As Long Function doUnitTest() As String + TestUtil.TestInit() verify_win32compat - doUnitTest = TestUtilModule.GetResult() + doUnitTest = TestUtil.GetResult() End Function Sub verify_win32compat() - TestUtilModule.TestInit() - Dim freq As Currency Dim count_a As Currency Dim count_b As Currency @@ -32,18 +31,17 @@ Sub verify_win32compat() On Error GoTo errorHandler success = QueryPerformanceFrequency(freq) - TestUtilModule.AssertTrue(success <> 0, "fetching perf. frequency") - TestUtilModule.AssertTrue(freq > 0, "perf. frequency is incorrect " & freq) + TestUtil.Assert(success <> 0, "QueryPerformanceFrequency") + TestUtil.Assert(freq > 0, "QueryPerformanceFrequency", "perf. frequency is incorrect " & freq) success = QueryPerformanceCounter(count_a) - TestUtilModule.AssertTrue(success <> 0, "fetching performance count") + TestUtil.Assert(success <> 0, "QueryPerformanceCounter(count_a)") success = QueryPerformanceCounter(count_b) - TestUtilModule.AssertTrue(success <> 0, "fetching performance count") - TestUtilModule.AssertTrue(count_a < count_b, "count mismatch " & count_a & " is > " & count_b) - Exit Sub + TestUtil.Assert(success <> 0, "QueryPerformanceCounter(count_b)") + TestUtil.Assert(count_a < count_b, "count mismatch " & count_a & " is > " & count_b) + Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")") - + TestUtil.ReportErrorHandler("verify_win32compat", Err, Error$, Erl) End Sub diff --git a/basic/qa/vba_tests/win32compatb.vb b/basic/qa/vba_tests/win32compatb.vb index b85f07808d80..f729725ea55e 100644 --- a/basic/qa/vba_tests/win32compatb.vb +++ b/basic/qa/vba_tests/win32compatb.vb @@ -1,6 +1,3 @@ -Option VBASupport 1 -Option Explicit - ' ' This file is part of the LibreOffice project. ' @@ -15,6 +12,9 @@ Option Explicit ' This module tests different signatures for the same methods. ' +Option VBASupport 1 +Option Explicit + Private Type LARGE_INTEGER lowpart As Long highpart As Long @@ -24,8 +24,9 @@ Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCo Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long Function doUnitTest() As String - verify_win32compat - doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_win32compatb + doUnitTest = TestUtil.GetResult() End Function Function convertLarge(scratch As LARGE_INTEGER) As Double @@ -36,9 +37,7 @@ Function convertLarge(scratch As LARGE_INTEGER) As Double convertLarge = ret End Function -Sub verify_win32compat() - TestUtilModule.TestInit - +Sub verify_win32compatb() Dim scratch as LARGE_INTEGER Dim freq As Double Dim count_a As Double @@ -48,21 +47,20 @@ Sub verify_win32compat() On Error GoTo errorHandler success = QueryPerformanceFrequency(scratch) - TestUtilModule.AssertTrue(success <> 0, "fetching perf. frequency") + TestUtil.Assert(success <> 0, "QueryPerformanceFrequency") freq = convertLarge(scratch) - TestUtilModule.AssertTrue(freq > 0, "perf. frequency is incorrect " & freq) + TestUtil.Assert(freq > 0, "QueryPerformanceFrequency", "perf. frequency is incorrect " & freq) success = QueryPerformanceCounter(scratch) - TestUtilModule.AssertTrue(success <> 0, "fetching performance count") + TestUtil.Assert(success <> 0, "QueryPerformanceCounter") count_a = convertLarge(scratch) ' success = QueryPerformanceCounter(scratch) -' TestUtilModule.AssertTrue(success <> 0, "fetching performance count") +' TestUtil.Assert(success <> 0, "fetching performance count") ' count_b = convertLarge(scratch) -' TestUtilModule.AssertTrue(count_a < count_b, "count mismatch " & count_a & " is > " & count_b) - Exit Sub +' TestUtil.Assert(count_a < count_b, "count mismatch " & count_a & " is > " & count_b) + Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")") - + TestUtil.ReportErrorHandler("verify_win32compatb", Err, Error$, Erl) End Sub diff --git a/basic/qa/vba_tests/year.vb b/basic/qa/vba_tests/year.vb index 15d4f2c25ff7..3ba0df62d527 100644 --- a/basic/qa/vba_tests/year.vb +++ b/basic/qa/vba_tests/year.vb @@ -1,32 +1,27 @@ +' +' 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 VBASupport 1 Option Explicit Function doUnitTest() As String -verify_testYear -doUnitTest = TestUtilModule.GetResult() + TestUtil.TestInit + verify_testYear + doUnitTest = TestUtil.GetResult() End Function Sub verify_testYear() - - TestUtilModule.TestInit - - Dim testName As String - Dim date1, date2 - testName = "Test Year function" On Error GoTo errorHandler - date2 = 1969 - date1 = Year("12/2/1969") - TestUtilModule.AssertTrue(date1 = date2, "the return Year is: " & date1) - - date2 = 1900 - date1 = Year(256) - TestUtilModule.AssertTrue(date1 = date2, "the return Year is: " & date1) - - TestUtilModule.TestEnd + TestUtil.AssertEqual(Year("12/2/1969"), 1969, "Year(""12/2/1969"")") + TestUtil.AssertEqual(Year(256), 1900, "Year(256)") Exit Sub errorHandler: - TestUtilModule.AssertTrue(False, testName & ": hit error handler") + TestUtil.ReportErrorHandler("verify_testYear", Err, Error$, Erl) End Sub - |