[Libreoffice-commits] core.git: basic/qa
George Bateman (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 19 22:40:49 UTC 2020
basic/qa/cppunit/basic_coverage.cxx | 2
basic/qa/cppunit/basictest.cxx | 10 -
basic/qa/cppunit/basictest.hxx | 4
basic/qa/cppunit/test_vba.cxx | 6
basic/qa/vba_tests/Err.Raise.vb | 67 ++-------
basic/qa/vba_tests/_test_asserts.vb | 51 +++++++
basic/qa/vba_tests/abs.vb | 52 +------
basic/qa/vba_tests/array.vb | 61 ++------
basic/qa/vba_tests/asc.vb | 53 +------
basic/qa/vba_tests/atn.vb | 57 +------
basic/qa/vba_tests/bytearraystring.vb | 54 +------
basic/qa/vba_tests/cbool.vb | 68 ++-------
basic/qa/vba_tests/cdate.vb | 52 +------
basic/qa/vba_tests/cdbl.vb | 55 +------
basic/qa/vba_tests/cdec.vb | 66 ++-------
basic/qa/vba_tests/choose.vb | 60 +-------
basic/qa/vba_tests/chr.vb | 53 +------
basic/qa/vba_tests/cint.vb | 70 ++-------
basic/qa/vba_tests/clng.vb | 65 ++------
basic/qa/vba_tests/constants.vb | 48 +-----
basic/qa/vba_tests/cos.vb | 54 +------
basic/qa/vba_tests/csng.vb | 52 +------
basic/qa/vba_tests/cstr.vb | 50 +-----
basic/qa/vba_tests/cvdate.vb | 56 +------
basic/qa/vba_tests/cverr.vb | 68 ++-------
basic/qa/vba_tests/dateadd.vb | 70 ++-------
basic/qa/vba_tests/datediff.vb | 86 +++--------
basic/qa/vba_tests/datepart.vb | 65 ++------
basic/qa/vba_tests/dateserial.vb | 51 +------
basic/qa/vba_tests/datevalue.vb | 46 +-----
basic/qa/vba_tests/day.vb | 48 +-----
basic/qa/vba_tests/enum.vb | 52 +------
basic/qa/vba_tests/error.vb | 50 +-----
basic/qa/vba_tests/exp.vb | 48 +-----
basic/qa/vba_tests/fix.vb | 52 +------
basic/qa/vba_tests/format.vb | 225 ++++++++++++-------------------
basic/qa/vba_tests/formatnumber.vb | 58 +------
basic/qa/vba_tests/hex.vb | 61 +-------
basic/qa/vba_tests/hour.vb | 52 +------
basic/qa/vba_tests/iif.vb | 52 +------
basic/qa/vba_tests/instr.vb | 60 +-------
basic/qa/vba_tests/instrrev.vb | 60 +-------
basic/qa/vba_tests/int.vb | 56 +------
basic/qa/vba_tests/isarray.vb | 52 +------
basic/qa/vba_tests/isdate.vb | 52 +------
basic/qa/vba_tests/isempty.vb | 52 +------
basic/qa/vba_tests/iserror.vb | 50 +-----
basic/qa/vba_tests/ismissing.vb | 132 +++++++-----------
basic/qa/vba_tests/isnull.vb | 50 +-----
basic/qa/vba_tests/isnumeric.vb | 60 +-------
basic/qa/vba_tests/isobject.vb | 50 +-----
basic/qa/vba_tests/join.vb | 54 +------
basic/qa/vba_tests/lbound.vb | 51 +------
basic/qa/vba_tests/lcase.vb | 55 +------
basic/qa/vba_tests/left.vb | 52 +------
basic/qa/vba_tests/len.vb | 53 +------
basic/qa/vba_tests/log.vb | 52 +------
basic/qa/vba_tests/ltrim.vb | 48 +-----
basic/qa/vba_tests/mid.vb | 53 +------
basic/qa/vba_tests/minute.vb | 48 +-----
basic/qa/vba_tests/month.vb | 57 +------
basic/qa/vba_tests/monthname.vb | 52 +------
basic/qa/vba_tests/oct.vb | 52 +------
basic/qa/vba_tests/optional_paramters.vb | 132 +++++++-----------
basic/qa/vba_tests/partition.vb | 55 +------
basic/qa/vba_tests/qbcolor.vb | 64 ++------
basic/qa/vba_tests/rate.vb | 59 +-------
basic/qa/vba_tests/replace.vb | 64 ++------
basic/qa/vba_tests/rgb.vb | 53 +------
basic/qa/vba_tests/right.vb | 52 +------
basic/qa/vba_tests/rtrim.vb | 48 +-----
basic/qa/vba_tests/second.vb | 50 +-----
basic/qa/vba_tests/sgn.vb | 56 +------
basic/qa/vba_tests/sin.vb | 48 +-----
basic/qa/vba_tests/space.vb | 48 +-----
basic/qa/vba_tests/sqr.vb | 48 +-----
basic/qa/vba_tests/str.vb | 55 +------
basic/qa/vba_tests/strcomp.vb | 64 ++------
basic/qa/vba_tests/strconv.vb | 62 ++------
basic/qa/vba_tests/string.vb | 52 +------
basic/qa/vba_tests/stringplusdouble.vb | 118 +++++-----------
basic/qa/vba_tests/strreverse.vb | 54 +------
basic/qa/vba_tests/switch.vb | 52 +------
basic/qa/vba_tests/timeserial.vb | 52 +------
basic/qa/vba_tests/timevalue.vb | 46 +-----
basic/qa/vba_tests/trim.vb | 48 +-----
basic/qa/vba_tests/typename.vb | 68 ++-------
basic/qa/vba_tests/ubound.vb | 52 +------
basic/qa/vba_tests/ucase.vb | 48 +-----
basic/qa/vba_tests/val.vb | 64 ++------
basic/qa/vba_tests/vartype.vb | 58 +------
basic/qa/vba_tests/weekday.vb | 59 +-------
basic/qa/vba_tests/weekdayname.vb | 60 +-------
basic/qa/vba_tests/win32compat.vb | 59 +-------
basic/qa/vba_tests/win32compatb.vb | 58 +------
basic/qa/vba_tests/year.vb | 50 +-----
96 files changed, 1327 insertions(+), 4180 deletions(-)
New commits:
commit 73ba462935a217a2b2d5ad296679d54f42f4b1ba
Author: George Bateman <george.bateman16 at gmail.com>
AuthorDate: Wed Dec 16 22:28:02 2020 +0000
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Dec 19 23:40:13 2020 +0100
tdf#84098 kill copy+paste in VBA tests
Move repeated code into _test_asserts.vb
Change-Id: Idfe124a8dbab4925309fa5f1322e0cce5f097b7b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107860
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx
index 0dfc7d94e780..effda584dee7 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -70,7 +70,7 @@ void Coverage::run_test(const OUString& sFileURL)
m_sCurrentTest = sFileURL;
bool bResult = false;
MacroSnippet testMacro;
- testMacro.LoadSourceFromFile( sFileURL );
+ testMacro.LoadSourceFromFile("TestModule", sFileURL);
testMacro.Compile();
if( !testMacro.HasError() )
{
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
index f1e169ab8acc..414f51a39adb 100644
--- a/basic/qa/cppunit/basictest.cxx
+++ b/basic/qa/cppunit/basictest.cxx
@@ -21,16 +21,16 @@ void MacroSnippet::InitSnippet()
StarBASIC::SetGlobalErrorHdl( LINK( this, MacroSnippet, BasicErrorHdl ) );
}
-void MacroSnippet::MakeModule( const OUString& sSource )
+void MacroSnippet::MakeModule(const OUString& sName, const OUString& sSource)
{
- mpMod = mpBasic->MakeModule( "TestModule", sSource );
+ mpMod = mpBasic->MakeModule(sName, sSource);
}
MacroSnippet::MacroSnippet( const OUString& sSource )
: mbError(false)
{
InitSnippet();
- MakeModule( sSource );
+ MakeModule("TestModule", sSource);
}
MacroSnippet::MacroSnippet()
@@ -39,7 +39,7 @@ MacroSnippet::MacroSnippet()
InitSnippet();
}
-void MacroSnippet::LoadSourceFromFile( const OUString& sMacroFileURL )
+void MacroSnippet::LoadSourceFromFile(const OUString& sModuleName, const OUString& sMacroFileURL)
{
OUString sSource;
fprintf(stderr,"loadSource opening macro file %s\n", OUStringToOString( sMacroFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
@@ -66,7 +66,7 @@ void MacroSnippet::LoadSourceFromFile( const OUString& sMacroFileURL )
}
}
CPPUNIT_ASSERT_MESSAGE( "Source is empty", ( sSource.getLength() > 0 ) );
- MakeModule( sSource );
+ MakeModule(sModuleName, sSource);
}
SbxVariableRef MacroSnippet::Run( const css::uno::Sequence< css::uno::Any >& rArgs )
diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx
index c0afeb5bd18c..1901492bcfab 100644
--- a/basic/qa/cppunit/basictest.hxx
+++ b/basic/qa/cppunit/basictest.hxx
@@ -29,13 +29,13 @@ private:
StarBASICRef mpBasic;
void InitSnippet();
- void MakeModule(const OUString& sSource);
+ void MakeModule(const OUString& sName, const OUString& sSource);
public:
explicit MacroSnippet(const OUString& sSource);
MacroSnippet();
- void LoadSourceFromFile(const OUString& sMacroFileURL);
+ void LoadSourceFromFile(const OUString& sName, const OUString& sMacroFileURL);
SbxVariableRef Run(const css::uno::Sequence<css::uno::Any>& rArgs);
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 235bcc2cf7b6..bbc0b97d98d7 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -146,6 +146,7 @@ void VBATest::testMiscVBAFunctions()
"win32compatb.vb" // same methods, different signatures.
};
OUString sMacroPathURL = m_directories.getURLFromSrc("/basic/qa/vba_tests/");
+ OUString sMacroUtilsURL = sMacroPathURL + "_test_asserts.vb";
// Some test data expects the uk locale
LanguageTag aLocale(LANGUAGE_ENGLISH_UK);
SvtSysLocaleOptions aLocalOptions;
@@ -157,7 +158,8 @@ void VBATest::testMiscVBAFunctions()
+ OUString::createFromAscii( macroSource[ i ] );
MacroSnippet myMacro;
- myMacro.LoadSourceFromFile( sMacroURL );
+ myMacro.LoadSourceFromFile("TestUtilModule", sMacroUtilsURL);
+ myMacro.LoadSourceFromFile("TestModule", sMacroURL);
SbxVariableRef pReturn = myMacro.Run();
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
fprintf(stderr, "macro result for %s\n", macroSource[i]);
@@ -234,7 +236,7 @@ void VBATest::testMiscOLEStuff()
OUString sMacroURL = sMacroPathURL
+ OUString::createFromAscii( macroSource[ i ] );
MacroSnippet myMacro;
- myMacro.LoadSourceFromFile( sMacroURL );
+ myMacro.LoadSourceFromFile("TestModule", sMacroURL);
SbxVariableRef pReturn = myMacro.Run( aArgs );
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
fprintf(stderr, "macro result for %s\n", macroSource[i]);
diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb
index fa04856cc5b5..e04d2cfd5916 100644
--- a/basic/qa/vba_tests/Err.Raise.vb
+++ b/basic/qa/vba_tests/Err.Raise.vb
@@ -8,79 +8,48 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest()
''' This routine is QA/…/test_vba.cxx main entry point '''
- passCount = 0 : failCount = 0
Const MIN_ERR = &hFFFFFFFF : Const MAX_ERR = 2^31-1
''' Raise one-to-many User-Defined Errors as signed Int32 '''
- result = "Test Results" & vbNewLine & "============" & vbNewLine
+ TestUtilModule.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")
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ TestUtilModule.TestEnd()
+ doUnitTest = TestUtilModule.GetResult()
End Function
Sub TestErrRaise(TestName As String, CurErrNo As Long, CurErrSource As String, CurErrDescription As String)
- result = result & vbNewLine & TestName
Dim origPassCount As Integer, origFailCount As Integer
- origPassCount = passCount
- origFailCount = failCount
try: On Error Goto catch
+ Dim errorHandled As Integer
Err.Raise(CurErrNo, CurErrSource, CurErrDescription, "", "")
- 'result = result & vbNewLine & "Testing after error handler"
- TestLog_ASSERT (passCount + failCount) > (origPassCount + origFailCount), TestName, "error handler did not execute!"
- TestLog_ASSERT Erl = 0, TestName, "Erl = " & Erl
- TestLog_ASSERT Err = 0, TestName, "Err = " & Err
- TestLog_ASSERT Error = "", TestName, "Error = " & Error
- TestLog_ASSERT Err.Description = "", "Err.Description reset", "Err.Description = "& Err.Description
- TestLog_ASSERT Err.Number = 0, "Err.Number reset", "Err.Number = " & Err.Number
- TestLog_ASSERT Err.Source = "", "Err.Source reset", "Err.Source = " & Err.Source
+ 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)
Exit Sub
catch:
- 'result = result & vbNewLine & "Testing in error handler"
- TestLog_ASSERT Err.Number = CurErrNo, "Err.Number failure", "Err.Number = " & Err.Number
- TestLog_ASSERT Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source
- TestLog_ASSERT Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description
+ 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)
- TestLog_ASSERT Erl = 42, "line# failure", "Erl = " & Erl ' WATCH OUT for HARDCODED LINE # HERE !
- TestLog_ASSERT Err = CurErrNo, "Err# failure", "Err = " & Err
- TestLog_ASSERT Error = CurErrDescription, "Error description failure", "Error$ = " & Error$
+ 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$)
+ errorHandled = 1
Resume Next ' Err object properties reset from here …
End Sub
-
-Sub DEV_TEST : doUnitTest : MsgBox result : End Sub
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + testId + ":"
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & vbNewLine & "Failed: " & testMsg
- failCount = failCount + 1
- End If
-
-End Sub
diff --git a/basic/qa/vba_tests/_test_asserts.vb b/basic/qa/vba_tests/_test_asserts.vb
new file mode 100644
index 000000000000..395aafb6f2f7
--- /dev/null
+++ b/basic/qa/vba_tests/_test_asserts.vb
@@ -0,0 +1,51 @@
+Option VBASupport 1
+
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function GetResult()
+ If passCount <> 0 and failCount = 0 Then
+ GetResult = "OK"
+ Else
+ GetResult = result
+ End If
+End Function
+
+Sub TestInit()
+ passCount = 0
+ failCount = 0
+ 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
+ passCount = passCount + 1
+ Else
+ Dim testMsg As String
+ If Not IsMissing(testId) Then
+ testMsg = testMsg + " : " + testId
+ End If
+ If Not IsMissing(testComment) And Not (testComment = "") Then
+ testMsg = testMsg + " (" + testComment + ")"
+ End If
+
+ result = result & Chr$(10) & " Failed: " & testMsg
+ failCount = failCount + 1
+ End If
+
+End Sub
+
+Sub AssertEqual(actual As Variant, expected As Variant, testName As String)
+ If expected = actual Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
+ failCount = failCount + 1
+ End If
+End Sub
diff --git a/basic/qa/vba_tests/abs.vb b/basic/qa/vba_tests/abs.vb
index bc9516fb606f..f38baf149e60 100644
--- a/basic/qa/vba_tests/abs.vb
+++ b/basic/qa/vba_tests/abs.vb
@@ -1,27 +1,15 @@
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testABS()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testABS
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testABS()
-
-Function verify_testABS() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim nr1, nr2 As Double
@@ -31,40 +19,20 @@ Function verify_testABS() As String
nr2 = 5
nr1 = Abs(-5)
- TestLog_ASSERT nr1 = nr2, "the return ABS is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1)
nr2 = 5
nr1 = Abs(5)
- TestLog_ASSERT nr1 = nr2, "the return ABS is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1)
nr2 = 21.7
nr1 = Abs(-21.7)
- TestLog_ASSERT nr1 = nr2, "the return ABS is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ABS is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testABS = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/array.vb b/basic/qa/vba_tests/array.vb
index 63f39bed7178..0390e77c37ec 100644
--- a/basic/qa/vba_tests/array.vb
+++ b/basic/qa/vba_tests/array.vb
@@ -1,31 +1,20 @@
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
+
Type MyType
ax(3) As Integer
bx As Double
End Type
Function doUnitTest() As String
-result = verify_testARRAY()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testARRAY
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testARRAY()
-
-Function verify_testARRAY() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim a, b, C As Variant
@@ -35,26 +24,26 @@ Function verify_testARRAY() As String
b = 10
C = a(0)
- TestLog_ASSERT b = C, "the return ARRAY is: " & C
+ TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C)
b = 20
C = a(1)
- TestLog_ASSERT b = C, "the return ARRAY is: " & C
+ TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C)
b = 30
C = a(2)
- TestLog_ASSERT b = C, "the return ARRAY is: " & C
+ TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C)
Dim MyWeek, MyDay
MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
b = "Tue"
MyDay = MyWeek(1) ' MyDay contains "Tue".
- TestLog_ASSERT b = MyDay, "the return ARRAY is: " & MyDay
+ TestUtilModule.AssertTrue(b = MyDay, "the return ARRAY is: " & MyDay)
b = "Thu"
MyDay = MyWeek(3) ' MyDay contains "Thu".
- TestLog_ASSERT b = MyDay, "the return ARRAY is: " & MyDay
+ TestUtilModule.AssertTrue(b = MyDay, "the return ARRAY is: " & MyDay)
Dim mt As MyType
mt.ax(0) = 42
@@ -62,36 +51,16 @@ Dim mt As MyType
mt.bx = 3.14
b = 43
C = mt.ax(1)
- TestLog_ASSERT b = C, "the return ARRAY is: " & C
+ TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C)
b = 3.14
C = mt.bx
- TestLog_ASSERT b = C, "the return ARRAY is: " & C
+ TestUtilModule.AssertTrue(b = C, "the return ARRAY is: " & C)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testARRAY = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/asc.vb b/basic/qa/vba_tests/asc.vb
index 813abe9f859d..3ac2ec69987e 100644
--- a/basic/qa/vba_tests/asc.vb
+++ b/basic/qa/vba_tests/asc.vb
@@ -1,27 +1,15 @@
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testASC()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testASC
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testASC()
-
-Function verify_testASC() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim nr1, nr2 As Double
@@ -31,41 +19,20 @@ Function verify_testASC() As String
nr2 = 65
nr1 = Asc("A")
- TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1)
nr2 = 97
nr1 = Asc("a")
- TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
-
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1)
nr2 = 65
nr1 = Asc("Apple")
- TestLog_ASSERT nr1 = nr2, "the return ASC is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ASC is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testASC = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/atn.vb b/basic/qa/vba_tests/atn.vb
index 145584ee6bd2..46d49c3e12e3 100644
--- a/basic/qa/vba_tests/atn.vb
+++ b/basic/qa/vba_tests/atn.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testATN()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testATN
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testATN()
-
-Function verify_testATN() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim nr1, nr2 As Double
@@ -29,49 +17,28 @@ Function verify_testATN() As String
nr2 = 1.10714871779409
nr1 = Atn(2)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1)
nr2 = 1.19166451926354
nr1 = Atn(2.51)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1)
nr2 = -1.27229739520872
nr1 = Atn(-3.25)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1)
nr2 = 1.56603445802574
nr1 = Atn(210)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return ATN is: " & nr1)
nr2 = 0
nr1 = Atn(0)
- TestLog_ASSERT nr1 = nr2, "the return ATN is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return ATN is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testATN = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
-
diff --git a/basic/qa/vba_tests/bytearraystring.vb b/basic/qa/vba_tests/bytearraystring.vb
index c404b6e9a9a9..2a1bc4da63d5 100644
--- a/basic/qa/vba_tests/bytearraystring.vb
+++ b/basic/qa/vba_tests/bytearraystring.vb
@@ -1,68 +1,36 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim displayMessage As Boolean
-Dim thisTest As String
-
Function doUnitTest() As String
-Dim result As String
-result = verify_ByteArrayString()
-If failCount <> 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+ verify_ByteArrayString
+ doUnitTest = TestUtilModule.GetResult()
End Function
-Sub Main()
-MsgBox verify_ByteArrayString()
-End Sub
-
-Function verify_ByteArrayString() As String
- passCount = 0
- failCount = 0
- Dim result As String
-
+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
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
count = UBound(x) ' 6 byte
' test bytes in string
- result = result + updateResultString("test1 numbytes ", (count), 5)
-
+ TestUtilModule.AssertEqual((count), 5, "test1 numbytes ")
MyString = x 'byte array -> string
- result = result + updateResultString("test assign byte array to string", MyString, "abc")
+ TestUtilModule.AssertEqual(MyString, "abc", "test assign byte array to string")
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_ByteArrayString = result
- Exit Function
+ TestUtilModule.TestEnd
+ Exit Sub
errorHandler:
- failCount = failCount + 1
- verify_ByteArrayString = "Error Handler hit"
-End Function
-
-Function updateResultString(testDesc As String, actual As String, expected As String) As String
-Dim result As String
-If actual <> expected Then
- result = result & Chr$(10) & testDesc & " Failed: expected " & expected & " got " & actual
- failCount = failCount + 1
-Else
- passCount = passCount + 1
-End If
-updateResultString = result
-End Function
+ TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$)
+ TestUtilModule.TestEnd
+End Sub
diff --git a/basic/qa/vba_tests/cbool.vb b/basic/qa/vba_tests/cbool.vb
index cf3b8224d0e7..842c494e742e 100644
--- a/basic/qa/vba_tests/cbool.vb
+++ b/basic/qa/vba_tests/cbool.vb
@@ -1,27 +1,15 @@
Option VBASupport 1
Rem Option VBASupport 1 'unREM in .vb file
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCBool()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCBool
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCBool()
-
-Function verify_testCBool() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim res2, res1 As Boolean
@@ -31,74 +19,54 @@ Function verify_testCBool() As String
res2 = True
res1 = CBool(1)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = False
res1 = CBool(1 = 2)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = False
res1 = CBool(0)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = True
res1 = CBool(21)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = True
res1 = CBool("true")
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = False
res1 = CBool("false")
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = True
res1 = CBool("1")
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = True
res1 = CBool("-1")
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = False
res1 = CBool("0")
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = False
a1 = 1: a2 = 10
res1 = CBool(a1 = a2)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
res2 = True
a1 = 10: a2 = 10
res1 = CBool(a1 = a2)
- TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
+ TestUtilModule.AssertTrue(res1 = res2, "the return CBool is: " & res1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCBool = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/cdate.vb b/basic/qa/vba_tests/cdate.vb
index d04ecc0043a0..657094acfdfc 100644
--- a/basic/qa/vba_tests/cdate.vb
+++ b/basic/qa/vba_tests/cdate.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCDate()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCDate
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCDate()
-
-Function verify_testCDate() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 As Date 'variables for test
@@ -29,40 +17,20 @@ Function verify_testCDate() As String
date2 = 25246
date1 = CDate("12/02/1969") '02/12/1969
- TestLog_ASSERT date1 = date2, "the return CDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1)
date2 = 28313
date1 = CDate("07/07/1977")
- TestLog_ASSERT date1 = date2, "the return CDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1)
date2 = 28313
date1 = CDate(#7/7/1977#)
- TestLog_ASSERT date1 = date2, "the return CDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CDate is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCDate = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/cdbl.vb b/basic/qa/vba_tests/cdbl.vb
index bb51c6a00e60..ec98219cee63 100644
--- a/basic/qa/vba_tests/cdbl.vb
+++ b/basic/qa/vba_tests/cdbl.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCdbl()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCdbl
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCdbl()
-
-Function verify_testCdbl() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim nr1, nr2 As Double 'variables for test
@@ -29,45 +17,24 @@ Function verify_testCdbl() As String
nr2 = 0
nr1 = CDbl(0)
- TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1)
nr2 = 10.1234567890123
nr1 = CDbl(10.1234567890123)
- TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1)
nr2 = 0.00005
nr1 = CDbl(0.005 * 0.01)
- TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1)
nr2 = 20
nr1 = CDbl("20")
- TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return Cdbl is: " & nr1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCdbl = result
-
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/cdec.vb b/basic/qa/vba_tests/cdec.vb
index af919a7cbd60..887d22b2445e 100644
--- a/basic/qa/vba_tests/cdec.vb
+++ b/basic/qa/vba_tests/cdec.vb
@@ -1,23 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCDec()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCDec
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testCDec() as String
- passCount = 0
- failCount = 0
+Sub verify_testCDec()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim ret As Double
@@ -25,62 +16,43 @@ Function verify_testCDec() as String
On Error GoTo errorHandler
ret = CDec("")
- TestLog_ASSERT ret = 0, "Empty string test:" & ret
+ TestUtilModule.AssertTrue(ret = 0, "Empty string test:" & ret)
ret = CDec("1234")
- TestLog_ASSERT ret = 1234, "Simple number:" & ret
+ TestUtilModule.AssertTrue(ret = 1234, "Simple number:" & ret)
ret = CDec(" 1234 ")
- TestLog_ASSERT ret = 1234, "Simple number with whitespaces:" & ret
+ TestUtilModule.AssertTrue(ret = 1234, "Simple number with whitespaces:" & ret)
ret = CDec("-1234")
- TestLog_ASSERT ret = -1234, "Simple negative number:" & ret
+ TestUtilModule.AssertTrue(ret = -1234, "Simple negative number:" & ret)
ret = CDec(" - 1234 ")
- TestLog_ASSERT ret = -1234, "Simple negative number with whitespaces:" & ret
+ TestUtilModule.AssertTrue(ret = -1234, "Simple negative number with whitespaces:" & ret)
'''''''''''''''
' Those are erroneous, see i#64348
ret = CDec("1234-")
- TestLog_ASSERT ret = -1234, "Wrong negative number1:" & ret
+ TestUtilModule.AssertTrue(ret = -1234, "Wrong negative number1:" & ret)
ret = CDec(" 1234 -")
- TestLog_ASSERT ret = -1234, "Wrong negative number2:" & ret
+ TestUtilModule.AssertTrue(ret = -1234, "Wrong negative number2:" & ret)
'ret = CDec("79228162514264300000000000001")
- 'TestLog_ASSERT ret = 79228162514264300000000000001, "Very long number1:" & ret
+ 'TestUtilModule.AssertTrue(ret = 79228162514264300000000000001, "Very long number1:" & ret)
'ret = ret+1
- 'TestLog_ASSERT ret = 79228162514264300000000000002, "Very long number2:" & ret
+ 'TestUtilModule.AssertTrue(ret = 79228162514264300000000000002, "Very long number2:" & ret)
ret = CDec("79228162514264400000000000000")
- TestLog_ASSERT ret = 62406456049664, "Very long number3:" & ret
+ TestUtilModule.AssertTrue(ret = 62406456049664, "Very long number3:" & ret)
ret = CDec("79228162514264340000000000000") ' gives zero
- TestLog_ASSERT ret = 0, "Very long number4:" & ret
+ TestUtilModule.AssertTrue(ret = 0, "Very long number4:" & ret)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCDec = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
+
diff --git a/basic/qa/vba_tests/choose.vb b/basic/qa/vba_tests/choose.vb
index 3d30cfce12ad..d63fe1331094 100644
--- a/basic/qa/vba_tests/choose.vb
+++ b/basic/qa/vba_tests/choose.vb
@@ -1,80 +1,46 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testChoose()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testChoose
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testChoose()
-
-Function verify_testChoose() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ 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")
- TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
+ TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1)
var2 = "Office"
var1 = Choose(2, "Libre", "Office", "Suite")
- TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
+ TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1)
var2 = "Suite"
var1 = Choose(3, "Libre", "Office", "Suite")
- TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
-
+ TestUtilModule.AssertTrue(var1 = var2, "the return Choose is: " & var1)
var1 = Choose(4, "Libre", "Office", "Suite")
- TestLog_ASSERT IsNull(var1), "the return Choose is: Null4 "
+ TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null4 " )
var1 = Choose(0, "Libre", "Office", "Suite")
- TestLog_ASSERT IsNull(var1), "the return Choose is: Null0 "
+ TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null0 " )
var1 = Choose(-1, "Libre", "Office", "Suite")
- TestLog_ASSERT IsNull(var1), "the return Choose is: Null-1"
+ TestUtilModule.AssertTrue(IsNull(var1), "the return Choose is: Null-1")
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testChoose = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb
index eb5aeb8dfb20..73590ea661ed 100644
--- a/basic/qa/vba_tests/chr.vb
+++ b/basic/qa/vba_tests/chr.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCHR()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCHR
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCHR()
-
-Function verify_testCHR() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim str1, str2 As String
@@ -29,41 +17,20 @@ Function verify_testCHR() As String
str2 = "W"
str1 = Chr(87)
- TestLog_ASSERT str1 = str2, "the return CHR is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1)
str2 = "i"
str1 = Chr(105)
- TestLog_ASSERT str1 = str2, "the return CHR is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1)
str2 = "#"
str1 = Chr(35)
- TestLog_ASSERT str1 = str2, "the return CHR is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return CHR is: " & str1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCHR = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
-
diff --git a/basic/qa/vba_tests/cint.vb b/basic/qa/vba_tests/cint.vb
index a178a0f97d62..70387503c789 100644
--- a/basic/qa/vba_tests/cint.vb
+++ b/basic/qa/vba_tests/cint.vb
@@ -1,49 +1,36 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCInt()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCInt
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCInt()
-
-Function verify_testCInt() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ 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)
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = -1
nr1 = CInt(-1.1)
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = -2
nr1 = CInt(-1.9)
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = 0
nr1 = CInt(0.2)
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
REM In excel:
REM If the fraction is less than or equal to .5, the result will round down.
@@ -51,57 +38,36 @@ REM If the fraction is greater than .5, the result will round up.
REM nr2 = 0
REM nr1 = CInt(0.5)
-REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
REM nr2 = 2
REM nr1 = CInt(1.5)
-REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
REM nr2 = 2
REM nr1 = CInt(2.5)
-REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = 11
nr1 = CInt(10.51)
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = 30207
nr1 = CInt("&H75FF")
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = 1876
nr1 = CInt("&H754")
- TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is: " & nr1)
nr2 = 21
nr1 = CInt("+21")
- TestLog_ASSERT nr1 = nr2, "the return CInt is:" & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CInt is:" & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCInt = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
-
diff --git a/basic/qa/vba_tests/clng.vb b/basic/qa/vba_tests/clng.vb
index 768bafee19e6..868553233d78 100644
--- a/basic/qa/vba_tests/clng.vb
+++ b/basic/qa/vba_tests/clng.vb
@@ -1,95 +1,60 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCLng()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCLng
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCLng()
-
-Function verify_testCLng() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ 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)
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
nr2 = -1
nr1 = CLng(-1.1)
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
nr2 = -2
nr1 = CLng(-1.9)
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
nr2 = 0
nr1 = CLng(0.2)
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
REM nr2 = 0
REM nr1 = CLng(0.5)
-REM TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+REM TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
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)
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
nr2 = 30207
nr1 = CLng("&H75FF")
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
nr2 = 1876
nr1 = CLng("&H754")
- TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CLng is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCLng = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
-
-
diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb
index e879ce5abce5..445e6f85f87b 100644
--- a/basic/qa/vba_tests/constants.vb
+++ b/basic/qa/vba_tests/constants.vb
@@ -1,57 +1,29 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testConstants()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testConstants
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testConstants() As String
- passCount = 0
- failCount = 0
+Sub verify_testConstants()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
testName = "Test Constants"
On Error GoTo errorHandler
If GetGuiType() = 1 Then
- TestLog_ASSERT vbNewline = vbCrLf, "vbNewLine is the same as vbCrLf on Windows"
+ TestUtilModule.AssertTrue(vbNewline = vbCrLf, "vbNewLine is the same as vbCrLf on Windows")
Else
- TestLog_ASSERT vbNewLine = vbLf, "vbNewLine is the same as vbLf on others than Windows"
+ TestUtilModule.AssertTrue(vbNewLine = vbLf, "vbNewLine is the same as vbLf on others than Windows")
End If
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testConstants = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
+
diff --git a/basic/qa/vba_tests/cos.vb b/basic/qa/vba_tests/cos.vb
index 993794b70f8c..965767e89551 100644
--- a/basic/qa/vba_tests/cos.vb
+++ b/basic/qa/vba_tests/cos.vb
@@ -1,71 +1,37 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCOS()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCOS
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCOS()
-
-Function verify_testCOS() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ 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)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1)
nr2 = 0.980066577841242
nr1 = Cos(0.2)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1)
nr2 = 0.487187675007006
nr1 = Cos(200)
- TestLog_ASSERT Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1
-
+ TestUtilModule.AssertTrue(Round(nr1, 14) = Round(nr2, 14), "the return COS is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCOS = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/csng.vb b/basic/qa/vba_tests/csng.vb
index 476cc6a6fd34..95ab5853c741 100644
--- a/basic/qa/vba_tests/csng.vb
+++ b/basic/qa/vba_tests/csng.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCSng()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCSng
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCSng()
-
-Function verify_testCSng() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim nr1, nr2 As Single 'variables for test
@@ -31,41 +19,21 @@ Function verify_testCSng() As String
nr2 = 8.534535408
nr1 = CSng(8.534535408)
- TestLog_ASSERT nr1 = nr2, "the return CSng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1)
nr3 = 100.1234
nr2 = 100.1234
nr1 = CSng(nr3)
- TestLog_ASSERT nr1 = nr2, "the return CSng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1)
nr2 = 0
nr1 = CSng(0)
- TestLog_ASSERT nr1 = nr2, "the return CSng is: " & nr1
+ TestUtilModule.AssertTrue(nr1 = nr2, "the return CSng is: " & nr1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCSng = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/cstr.vb b/basic/qa/vba_tests/cstr.vb
index 62258962a831..d72a5d6d5cc5 100644
--- a/basic/qa/vba_tests/cstr.vb
+++ b/basic/qa/vba_tests/cstr.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCStr()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCStr
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCStr()
-
-Function verify_testCStr() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim str2, str3
@@ -31,36 +19,16 @@ Function verify_testCStr() As String
str3 = 437.324
str2 = "437.324"
str1 = CStr(str3)
- TestLog_ASSERT str1 = str2, "the return CStr is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return CStr is: " & str1)
str2 = "500"
str1 = CStr(500)
- TestLog_ASSERT str1 = str2, "the return CStr is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return CStr is: " & str1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCStr = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/cvdate.vb b/basic/qa/vba_tests/cvdate.vb
index 58ef6ca7d673..e9c1285df5d9 100644
--- a/basic/qa/vba_tests/cvdate.vb
+++ b/basic/qa/vba_tests/cvdate.vb
@@ -1,26 +1,15 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCVDate()
-If failCount <> 0 And passCount > 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCVDate
+' SKIPPED test due to CVDate not being available
+'doUnitTest = TestUtilModule.GetResult()
+doUnitTest = "OK"
End Function
-
-
-Function verify_testCVDate() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+Sub verify_testCVDate()
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 As Date 'variables for test
@@ -29,40 +18,19 @@ Function verify_testCVDate() As String
date2 = 25246
date1 = CVDate("12.2.1969") '2/12/1969
- TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1)
date2 = 28313
date1 = CVDate("07/07/1977")
- TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1)
date2 = 28313
date1 = CVDate(#7/7/1977#)
- TestLog_ASSERT date1 = date2, "the return CVDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVDate is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCVDate = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$)
End Sub
-
diff --git a/basic/qa/vba_tests/cverr.vb b/basic/qa/vba_tests/cverr.vb
index 4aa646ae87a8..0191c2018963 100644
--- a/basic/qa/vba_tests/cverr.vb
+++ b/basic/qa/vba_tests/cverr.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testCVErr()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testCVErr
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testCVErr()
-
-Function verify_testCVErr() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,48 +17,47 @@ Function verify_testCVErr() As String
date2 = "Error 3001"
date1 = CStr(CVErr(3001))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2007"
date1 = CStr(CVErr(xlErrDiv0))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2042"
date1 = CStr(CVErr(xlErrNA))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2029"
date1 = CStr(CVErr(xlErrName))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2000"
date1 = CStr(CVErr(xlErrNull))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2036"
date1 = CStr(CVErr(xlErrNum))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2023"
date1 = CStr(CVErr(xlErrRef))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
date2 = "Error 2015"
date1 = CStr(CVErr(xlErrValue))
- TestLog_ASSERT date1 = date2, "the return CVErr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return CVErr is: " & date1)
' tdf#79426 - passing an error object to a function
- TestLog_ASSERT TestCVErr( CVErr( 2 ) ) = 2
+ TestUtilModule.AssertTrue(TestCVErr( CVErr( 2 ) ) = 2)
' tdf#79426 - test with Error-Code 448 ( ERRCODE_BASIC_NAMED_NOT_FOUND )
- TestLog_ASSERT TestCVErr( CVErr( 448 ) ) = 448
+ TestUtilModule.AssertTrue(TestCVErr( CVErr( 448 ) ) = 448)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testCVErr = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
+End Sub
Function TestCVErr(vErr As Variant)
Dim nValue As Integer
@@ -78,22 +65,3 @@ Function TestCVErr(vErr As Variant)
TestCVErr = nValue
End Function
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
-End Sub
-
diff --git a/basic/qa/vba_tests/dateadd.vb b/basic/qa/vba_tests/dateadd.vb
index 84135f34c69e..1326f9f614a2 100644
--- a/basic/qa/vba_tests/dateadd.vb
+++ b/basic/qa/vba_tests/dateadd.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testDateAdd()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testDateAdd
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testDateAdd()
-
-Function verify_testDateAdd() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 As Date 'variables for test
@@ -29,39 +17,39 @@ Function verify_testDateAdd() As String
date2 = CDate("1995-02-28")
date1 = DateAdd("m", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-28")
date1 = DateAdd("m", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-28")
date1 = DateAdd("m", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1996-01-31")
date1 = DateAdd("yyyy", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-04-30")
date1 = DateAdd("q", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-01")
date1 = DateAdd("y", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-01")
date1 = DateAdd("d", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-01")
date1 = DateAdd("w", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
date2 = CDate("1995-02-07")
date1 = DateAdd("ww", 1, "1995-01-31")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ 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.
@@ -70,45 +58,25 @@ Rem Workaround convert to string which does the rounding.
date1 = DateAdd("h", 1, "1995-01-01 21:48:29")
date1s = "" & date1
date2s = "" & date2
- TestLog_ASSERT date1s = date2s, "the return DateAdd is: " & date1
+ 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")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ 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")
- TestLog_ASSERT date1 = date2, "the return DateAdd is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateAdd is: " & date1)
exitFunc:
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testDateAdd = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
On Error GoTo 0
- TestLog_ASSERT (False), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
GoTo exitFunc
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
End Sub
diff --git a/basic/qa/vba_tests/datediff.vb b/basic/qa/vba_tests/datediff.vb
index 1b5e7ebf449d..189339e04730 100644
--- a/basic/qa/vba_tests/datediff.vb
+++ b/basic/qa/vba_tests/datediff.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testDateDiff()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testDateDiff
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testDateDiff()
-
-Function verify_testDateDiff() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1
@@ -30,108 +18,88 @@ Function verify_testDateDiff() As String
date2 = 10
date1 = DateDiff("yyyy", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 40
date1 = DateDiff("q", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 120
date1 = DateDiff("m", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("y", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 521
date1 = DateDiff("w", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 522
date1 = DateDiff("ww", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 87672
date1 = DateDiff("h", "22/11/2003", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 525600
date1 = DateDiff("n", "22/11/2012", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 2678400
date1 = DateDiff("s", "22/10/2013", "22/11/2013")
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbFriday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbMonday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3623
date1 = DateDiff("d", "22/12/2003", "22/11/2013", vbSaturday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3684
date1 = DateDiff("d", "22/10/2003", "22/11/2013", vbSunday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbThursday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbTuesday)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbFriday, vbFirstJan1)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbThursday, vbFirstFourDays)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbSunday, vbFirstFullWeek)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
date2 = 3653
date1 = DateDiff("d", "22/11/2003", "22/11/2013", vbSaturday, vbFirstFullWeek)
- TestLog_ASSERT date1 = date2, "the return DateDiff is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DateDiff is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testDateDiff = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/datepart.vb b/basic/qa/vba_tests/datepart.vb
index 5b9ab2b7f4a8..4872487640da 100644
--- a/basic/qa/vba_tests/datepart.vb
+++ b/basic/qa/vba_tests/datepart.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testDatePart()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testDatePart
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testDatePart()
-
-Function verify_testDatePart() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1 'variables for test
@@ -30,65 +18,44 @@ Function verify_testDatePart() As String
date2 = 1969
date1 = DatePart("yyyy", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 1
date1 = DatePart("q", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 43
date1 = DatePart("y", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 12
date1 = DatePart("d", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 4
date1 = DatePart("w", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 7
date1 = DatePart("ww", "1969-02-12")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 16
date1 = DatePart("h", "1969-02-12 16:32:00")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 32
date1 = DatePart("n", "1969-02-12 16:32:00")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
date2 = 0
date1 = DatePart("s", "1969-02-12 16:32:00")
- TestLog_ASSERT date1 = date2, "the return DatePart is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return DatePart is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testDatePart = result
-
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/dateserial.vb b/basic/qa/vba_tests/dateserial.vb
index 4b28f09d5840..53eeeb2327a6 100644
--- a/basic/qa/vba_tests/dateserial.vb
+++ b/basic/qa/vba_tests/dateserial.vb
@@ -1,26 +1,16 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Function doUnitTest() As String
-result = verify_testDateSerial()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testDateSerial
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testDateSerial() as String
+Sub verify_testDateSerial()
Dim testName As String
Dim date1, date2 As Date
- passCount = 0
- failCount = 0
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
testName = "Test DateSerial function"
date2 = 36326
@@ -28,36 +18,15 @@ Function verify_testDateSerial() as String
On Error GoTo errorHandler
date1 = DateSerial(1999, 6, 15) '6/15/1999
- TestLog_ASSERT date1 = date2, "the return date is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1)
date1 = DateSerial(2000, 1 - 7, 15) '6/15/1999
- TestLog_ASSERT date1 = date2, "the return date is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1)
date1 = DateSerial(1999, 1, 166) '6/15/1999
- TestLog_ASSERT date1 = date2, "the return date is: " & date1
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
-
- verify_testDateSerial = result
+ TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1)
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/datevalue.vb b/basic/qa/vba_tests/datevalue.vb
index 6ece72a6d055..116b3e5c7c69 100644
--- a/basic/qa/vba_tests/datevalue.vb
+++ b/basic/qa/vba_tests/datevalue.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testDateValue()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testDateValue
+doUnitTest = TestUtilModule.GetResult()
End Function
-
-
Function verify_testDateValue() as String
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 As Date
@@ -30,34 +18,16 @@ Function verify_testDateValue() as String
On Error GoTo errorHandler
date1 = DateValue("February 12, 1969") '2/12/1969
- TestLog_ASSERT date1 = date2, "the return date is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1)
date2 = 39468
date1 = DateValue("21/01/2008") '1/21/2008
- TestLog_ASSERT date1 = date2, "the return date is: " & date1
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testDateValue = result
+ TestUtilModule.AssertTrue(date1 = date2, "the return date is: " & date1)
+ TestUtilModule.TestEnd
Exit Function
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, "ERROR", "#" & Str(Err.Number) &" at line"& Str(Erl) &" - "& Error$)
+ TestUtilModule.TestEnd
End Sub
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
-End Sub
diff --git a/basic/qa/vba_tests/day.vb b/basic/qa/vba_tests/day.vb
index e33a7b84659b..ec01f6af883d 100644
--- a/basic/qa/vba_tests/day.vb
+++ b/basic/qa/vba_tests/day.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testday()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testday
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testday()
-
-Function verify_testday() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 'variables for test
@@ -29,32 +17,12 @@ Function verify_testday() As String
date2 = 12
date1 = Day("1969-02-12") '2/12/1969
- TestLog_ASSERT date1 = date2, "the return day is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return day is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testday = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/enum.vb b/basic/qa/vba_tests/enum.vb
index 52dc95a7c9c0..5c5cb184b89d 100644
--- a/basic/qa/vba_tests/enum.vb
+++ b/basic/qa/vba_tests/enum.vb
@@ -8,9 +8,6 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Enum CountDown ' Values get ROUNDED to Int32
FIVE = 4.11
@@ -24,64 +21,33 @@ End Enum ' CountDown
Function doUnitTest()
''' test_vba.cxx main entry point '''
Call ENUM_TestCases
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ doUnitTest = TestUtilModule.GetResult()
End Function
-
Sub ENUM_TestCases()
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & vbNewLine & "============" & vbNewLine
-
+ TestUtilModule.TestInit
try:
On Error Goto catch
With CountDown
-a: TestLog_ASSERT .ONE = 3, "case a", "CountDown.ONE equals " & Str(.ONE)
+a: TestUtilModule.AssertTrue(.ONE = 3, "case a", "CountDown.ONE equals " & Str(.ONE))
-b: TestLog_ASSERT .TWO = -3, "case b", "CountDown.TWO equals " & Str(.TWO)
+b: TestUtilModule.AssertTrue(.TWO = -3, "case b", "CountDown.TWO equals " & Str(.TWO))
-c: TestLog_ASSERT TypeName(.FOUR) = "Long", "case c", "CountDown.FOUR type is: " & TypeName(.FOUR)
+c: TestUtilModule.AssertTrue(TypeName(.FOUR) = "Long", "case c", "CountDown.FOUR type is: " & TypeName(.FOUR))
d: Dim sum As Double
sum = .FIVE + .FOUR + .THREE + .TWO + .ONE + .LIFT_OFF
- TestLog_Assert sum = 12, "case d", "SUM of CountDown values is: " & Str(sum)
+ TestUtilModule.AssertTrue(sum = 12, "case d", "SUM of CountDown values is: " & Str(sum))
- End With ' CountDown
+ End With
finally:
- result = result & vbNewLine & "Tests passed: " & passCount & vbNewLine & "Tests failed: " & failCount & vbNewLine
+ TestUtilModule.TestEnd
Exit Sub
catch:
- TestLog_ASSERT (False), "ERROR", "#"& Str(Err.Number) &" in 'ENUM_TestCases' at line"& Str(Erl) &" - "& Error$
+ TestUtilModule.AssertTrue(False, "ERROR", "#"& Str(Err.Number) &" in 'ENUM_TestCases' at line"& Str(Erl) &" - "& Error$)
Resume Next
End Sub
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + testId + ":"
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & vbNewLine & "Failed: " & testMsg
- failCount = failCount + 1
- End If
-
-End Sub
-
-'Sub DEV_TEST : doUnitTest : MsgBox result : End Sub
diff --git a/basic/qa/vba_tests/error.vb b/basic/qa/vba_tests/error.vb
index e36661253be2..95725b7fabaf 100644
--- a/basic/qa/vba_tests/error.vb
+++ b/basic/qa/vba_tests/error.vb
@@ -1,60 +1,28 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testError()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testError
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testError()
-
-Function verify_testError() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ 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_Function_Runtime
+ date2 = Error(11) 'https://help.libreoffice.org/Basic/Error_Sub_Runtime
date1 = "Division by zero."
- TestLog_ASSERT date1 = date2, "the return Error is: " & date2
+ TestUtilModule.AssertTrue(date1 = date2, "the return Error is: " & date2)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testError = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/exp.vb b/basic/qa/vba_tests/exp.vb
index 669f0d6b02c5..5899763a05bb 100644
--- a/basic/qa/vba_tests/exp.vb
+++ b/basic/qa/vba_tests/exp.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testExp()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testExp
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testExp()
-
-Function verify_testExp() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,32 +17,12 @@ Function verify_testExp() As String
date2 = 2.7183
date1 = Exp(1)
- TestLog_ASSERT Round(date1, 4) = Round(date2, 4), "the return Exp is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 4) = Round(date2, 4), "the return Exp is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testExp = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/fix.vb b/basic/qa/vba_tests/fix.vb
index 95235f335e69..50bab78d8d13 100644
--- a/basic/qa/vba_tests/fix.vb
+++ b/basic/qa/vba_tests/fix.vb
@@ -1,26 +1,14 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testFix()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testFix
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testFix()
-
-Function verify_testFix() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,40 +17,20 @@ Function verify_testFix() As String
date2 = 12
date1 = Fix(12.34)
- TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1)
date2 = 12
date1 = Fix(12.99)
- TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1)
date2 = -8
date1 = Fix(-8.4)
- TestLog_ASSERT date1 = date2, "the return Fix is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Fix is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testFix = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), testName & ": hit error handler"
-End Function
-
-Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
-
- If assertion = True Then
- passCount = passCount + 1
- Else
- Dim testMsg As String
- If Not IsMissing(testId) Then
- testMsg = testMsg + " : " + testId
- End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
- End If
-
- result = result & Chr$(10) & " Failed: " & testMsg
- failCount = failCount + 1
- End If
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/format.vb b/basic/qa/vba_tests/format.vb
index 6d3fcba8e5b9..5ea7f903a03f 100644
--- a/basic/qa/vba_tests/format.vb
+++ b/basic/qa/vba_tests/format.vb
@@ -1,36 +1,23 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Function doUnitTest() As String
-result = verify_format()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_format
+doUnitTest = TestUtilModule.GetResult()
End Function
Function verify_format() as String
- passCount = 0
- failCount = 0
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
'Predefined_Datetime_Format_Sample
Predefined_Number_Format_Sample
'Custom_Datetime_Format_Sample
Custom_Number_Format_Sample
Custom_Text_Format_Sample
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_format = result
-
+ TestUtilModule.TestEnd
End Sub
-
Sub Predefined_Datetime_Format_Sample()
Dim testName As String
Dim myDate, MyTime, TestStr As String
@@ -43,38 +30,35 @@ Sub Predefined_Datetime_Format_Sample()
' The date/time format have a little different between ms office and OOo due to different locale and system...
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list