[Libreoffice-commits] core.git: basic/qa
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 22 05:19:37 UTC 2020
basic/qa/cppunit/test_vba.cxx | 2
basic/qa/vba_tests/Err.Raise.vb | 31 +-
basic/qa/vba_tests/_test_asserts.vb | 38 +-
basic/qa/vba_tests/abs.vb | 39 +-
basic/qa/vba_tests/array.vb | 64 +---
basic/qa/vba_tests/asc.vb | 39 +-
basic/qa/vba_tests/atn.vb | 48 +--
basic/qa/vba_tests/bytearraystring.vb | 26 -
basic/qa/vba_tests/cbool.vb | 80 +----
basic/qa/vba_tests/cdate.vb | 38 +-
basic/qa/vba_tests/cdbl.vb | 43 +-
basic/qa/vba_tests/cdec.vb | 63 +---
basic/qa/vba_tests/choose.vb | 51 +--
basic/qa/vba_tests/chr.vb | 38 +-
basic/qa/vba_tests/cint.vb | 77 +----
basic/qa/vba_tests/clng.vb | 61 +---
basic/qa/vba_tests/constants.vb | 28 +
basic/qa/vba_tests/cos.vb | 39 +-
basic/qa/vba_tests/csng.vb | 43 +-
basic/qa/vba_tests/cstr.vb | 37 +-
basic/qa/vba_tests/cvdate.vb | 40 +-
basic/qa/vba_tests/cverr.vb | 67 +---
basic/qa/vba_tests/dateadd.vb | 92 +-----
basic/qa/vba_tests/datediff.vb | 124 ++------
basic/qa/vba_tests/datepart.vb | 69 +---
basic/qa/vba_tests/dateserial.vb | 34 +-
basic/qa/vba_tests/datevalue.vb | 34 --
basic/qa/vba_tests/day.vb | 28 -
basic/qa/vba_tests/enum.vb | 15 -
basic/qa/vba_tests/error.vb | 29 -
basic/qa/vba_tests/exp.vb | 28 -
basic/qa/vba_tests/fix.vb | 38 +-
basic/qa/vba_tests/format.vb | 457 +++++++------------------------
basic/qa/vba_tests/formatnumber.vb | 58 +--
basic/qa/vba_tests/hex.vb | 57 +--
basic/qa/vba_tests/hour.vb | 41 +-
basic/qa/vba_tests/iif.vb | 38 +-
basic/qa/vba_tests/instr.vb | 58 +--
basic/qa/vba_tests/instrrev.vb | 58 +--
basic/qa/vba_tests/int.vb | 48 +--
basic/qa/vba_tests/isarray.vb | 42 +-
basic/qa/vba_tests/isdate.vb | 38 +-
basic/qa/vba_tests/isempty.vb | 37 +-
basic/qa/vba_tests/iserror.vb | 33 --
basic/qa/vba_tests/ismissing.vb | 113 ++++---
basic/qa/vba_tests/isnull.vb | 33 --
basic/qa/vba_tests/isnumeric.vb | 58 +--
basic/qa/vba_tests/isobject.vb | 36 +-
basic/qa/vba_tests/join.vb | 45 +--
basic/qa/vba_tests/lbound.vb | 35 +-
basic/qa/vba_tests/lcase.vb | 43 +-
basic/qa/vba_tests/left.vb | 38 +-
basic/qa/vba_tests/len.vb | 38 +-
basic/qa/vba_tests/log.vb | 38 +-
basic/qa/vba_tests/ltrim.vb | 28 -
basic/qa/vba_tests/mid.vb | 38 +-
basic/qa/vba_tests/minute.vb | 28 -
basic/qa/vba_tests/month.vb | 50 +--
basic/qa/vba_tests/monthname.vb | 38 +-
basic/qa/vba_tests/oct.vb | 38 +-
basic/qa/vba_tests/optional_paramters.vb | 115 ++++---
basic/qa/vba_tests/partition.vb | 46 +--
basic/qa/vba_tests/qbcolor.vb | 68 +---
basic/qa/vba_tests/rate.vb | 56 +--
basic/qa/vba_tests/replace.vb | 58 +--
basic/qa/vba_tests/rgb.vb | 41 +-
basic/qa/vba_tests/right.vb | 38 +-
basic/qa/vba_tests/rtrim.vb | 28 -
basic/qa/vba_tests/second.vb | 33 --
basic/qa/vba_tests/sgn.vb | 48 +--
basic/qa/vba_tests/sin.vb | 28 -
basic/qa/vba_tests/space.vb | 28 -
basic/qa/vba_tests/sqr.vb | 28 -
basic/qa/vba_tests/str.vb | 43 +-
basic/qa/vba_tests/strcomp.vb | 71 +---
basic/qa/vba_tests/strconv.vb | 69 +---
basic/qa/vba_tests/string.vb | 39 +-
basic/qa/vba_tests/stringplusdouble.vb | 149 +++-------
basic/qa/vba_tests/strreverse.vb | 43 +-
basic/qa/vba_tests/switch.vb | 33 +-
basic/qa/vba_tests/timeserial.vb | 40 +-
basic/qa/vba_tests/timevalue.vb | 31 +-
basic/qa/vba_tests/trim.vb | 28 -
basic/qa/vba_tests/typename.vb | 67 +---
basic/qa/vba_tests/ubound.vb | 38 +-
basic/qa/vba_tests/ucase.vb | 28 -
basic/qa/vba_tests/val.vb | 69 +---
basic/qa/vba_tests/vartype.vb | 53 +--
basic/qa/vba_tests/weekday.vb | 53 +--
basic/qa/vba_tests/weekdayname.vb | 58 +--
basic/qa/vba_tests/win32compat.vb | 26 -
basic/qa/vba_tests/win32compatb.vb | 30 --
basic/qa/vba_tests/year.vb | 33 --
93 files changed, 1772 insertions(+), 2989 deletions(-)
New commits:
commit 66b135fa80452144baf57e91a6814b172f8174e2
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Dec 21 09:00:03 2020 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Dec 22 06:18:50 2020 +0100
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 at collabora.com>
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")
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list