summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorGeorge Bateman <george.bateman16@gmail.com>2020-12-16 22:28:02 +0000
committerMike Kaganski <mike.kaganski@collabora.com>2020-12-19 23:40:13 +0100
commit73ba462935a217a2b2d5ad296679d54f42f4b1ba (patch)
tree643bc69450bf6d1f6b2d1b7d3acad453dac65e99 /basic
parent6c161bfe61679194d5f09d83c0bf8f780b508d1f (diff)
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@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/cppunit/basic_coverage.cxx2
-rw-r--r--basic/qa/cppunit/basictest.cxx10
-rw-r--r--basic/qa/cppunit/basictest.hxx4
-rw-r--r--basic/qa/cppunit/test_vba.cxx6
-rw-r--r--basic/qa/vba_tests/Err.Raise.vb67
-rw-r--r--basic/qa/vba_tests/_test_asserts.vb51
-rw-r--r--basic/qa/vba_tests/abs.vb52
-rw-r--r--basic/qa/vba_tests/array.vb61
-rw-r--r--basic/qa/vba_tests/asc.vb53
-rw-r--r--basic/qa/vba_tests/atn.vb57
-rw-r--r--basic/qa/vba_tests/bytearraystring.vb54
-rw-r--r--basic/qa/vba_tests/cbool.vb68
-rw-r--r--basic/qa/vba_tests/cdate.vb52
-rw-r--r--basic/qa/vba_tests/cdbl.vb55
-rw-r--r--basic/qa/vba_tests/cdec.vb66
-rw-r--r--basic/qa/vba_tests/choose.vb60
-rw-r--r--basic/qa/vba_tests/chr.vb53
-rw-r--r--basic/qa/vba_tests/cint.vb70
-rw-r--r--basic/qa/vba_tests/clng.vb65
-rw-r--r--basic/qa/vba_tests/constants.vb48
-rw-r--r--basic/qa/vba_tests/cos.vb54
-rw-r--r--basic/qa/vba_tests/csng.vb52
-rw-r--r--basic/qa/vba_tests/cstr.vb50
-rw-r--r--basic/qa/vba_tests/cvdate.vb56
-rw-r--r--basic/qa/vba_tests/cverr.vb68
-rw-r--r--basic/qa/vba_tests/dateadd.vb70
-rw-r--r--basic/qa/vba_tests/datediff.vb86
-rw-r--r--basic/qa/vba_tests/datepart.vb65
-rw-r--r--basic/qa/vba_tests/dateserial.vb51
-rw-r--r--basic/qa/vba_tests/datevalue.vb46
-rw-r--r--basic/qa/vba_tests/day.vb48
-rw-r--r--basic/qa/vba_tests/enum.vb52
-rw-r--r--basic/qa/vba_tests/error.vb50
-rw-r--r--basic/qa/vba_tests/exp.vb48
-rw-r--r--basic/qa/vba_tests/fix.vb52
-rw-r--r--basic/qa/vba_tests/format.vb225
-rw-r--r--basic/qa/vba_tests/formatnumber.vb58
-rw-r--r--basic/qa/vba_tests/hex.vb61
-rw-r--r--basic/qa/vba_tests/hour.vb52
-rw-r--r--basic/qa/vba_tests/iif.vb52
-rw-r--r--basic/qa/vba_tests/instr.vb60
-rw-r--r--basic/qa/vba_tests/instrrev.vb60
-rw-r--r--basic/qa/vba_tests/int.vb56
-rw-r--r--basic/qa/vba_tests/isarray.vb52
-rw-r--r--basic/qa/vba_tests/isdate.vb52
-rw-r--r--basic/qa/vba_tests/isempty.vb52
-rw-r--r--basic/qa/vba_tests/iserror.vb50
-rw-r--r--basic/qa/vba_tests/ismissing.vb132
-rw-r--r--basic/qa/vba_tests/isnull.vb50
-rw-r--r--basic/qa/vba_tests/isnumeric.vb60
-rw-r--r--basic/qa/vba_tests/isobject.vb50
-rw-r--r--basic/qa/vba_tests/join.vb54
-rw-r--r--basic/qa/vba_tests/lbound.vb51
-rw-r--r--basic/qa/vba_tests/lcase.vb55
-rw-r--r--basic/qa/vba_tests/left.vb52
-rw-r--r--basic/qa/vba_tests/len.vb53
-rw-r--r--basic/qa/vba_tests/log.vb52
-rw-r--r--basic/qa/vba_tests/ltrim.vb48
-rw-r--r--basic/qa/vba_tests/mid.vb53
-rw-r--r--basic/qa/vba_tests/minute.vb48
-rw-r--r--basic/qa/vba_tests/month.vb57
-rw-r--r--basic/qa/vba_tests/monthname.vb52
-rw-r--r--basic/qa/vba_tests/oct.vb52
-rw-r--r--basic/qa/vba_tests/optional_paramters.vb132
-rw-r--r--basic/qa/vba_tests/partition.vb55
-rw-r--r--basic/qa/vba_tests/qbcolor.vb64
-rw-r--r--basic/qa/vba_tests/rate.vb59
-rw-r--r--basic/qa/vba_tests/replace.vb64
-rw-r--r--basic/qa/vba_tests/rgb.vb53
-rw-r--r--basic/qa/vba_tests/right.vb52
-rw-r--r--basic/qa/vba_tests/rtrim.vb48
-rw-r--r--basic/qa/vba_tests/second.vb50
-rw-r--r--basic/qa/vba_tests/sgn.vb56
-rw-r--r--basic/qa/vba_tests/sin.vb48
-rw-r--r--basic/qa/vba_tests/space.vb48
-rw-r--r--basic/qa/vba_tests/sqr.vb48
-rw-r--r--basic/qa/vba_tests/str.vb55
-rw-r--r--basic/qa/vba_tests/strcomp.vb64
-rw-r--r--basic/qa/vba_tests/strconv.vb62
-rw-r--r--basic/qa/vba_tests/string.vb52
-rw-r--r--basic/qa/vba_tests/stringplusdouble.vb118
-rw-r--r--basic/qa/vba_tests/strreverse.vb54
-rw-r--r--basic/qa/vba_tests/switch.vb52
-rw-r--r--basic/qa/vba_tests/timeserial.vb52
-rw-r--r--basic/qa/vba_tests/timevalue.vb46
-rw-r--r--basic/qa/vba_tests/trim.vb48
-rw-r--r--basic/qa/vba_tests/typename.vb68
-rw-r--r--basic/qa/vba_tests/ubound.vb52
-rw-r--r--basic/qa/vba_tests/ucase.vb48
-rw-r--r--basic/qa/vba_tests/val.vb64
-rw-r--r--basic/qa/vba_tests/vartype.vb58
-rw-r--r--basic/qa/vba_tests/weekday.vb59
-rw-r--r--basic/qa/vba_tests/weekdayname.vb60
-rw-r--r--basic/qa/vba_tests/win32compat.vb59
-rw-r--r--basic/qa/vba_tests/win32compatb.vb58
-rw-r--r--basic/qa/vba_tests/year.vb50
96 files changed, 1327 insertions, 4180 deletions
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...
TestStr = Format(myDate, "General Date") ' 1/6/98
- TestLog_ASSERT IsDate(TestStr), "General Date: " & TestStr & " (Test only applies to en_US locale)"
- 'TestLog_ASSERT TestStr = "1/6/98", "General Date: " & TestStr
+ TestUtilModule.AssertTrue(IsDate(TestStr), "General Date: " & TestStr & " (Test only applies to en_US locale)")
+ 'TestUtilModule.AssertTrue(TestStr = "1/6/98", "General Date: " & TestStr)
TestStr = Format(myDate, "Long Date") ' Tuesday, January 06, 1998
- TestLog_ASSERT TestStr = "Tuesday, January 06, 1998", "Long Date: " & TestStr & " (Test only applies to en_US locale)"
- 'TestLog_ASSERT IsDate(TestStr), "Long Date: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "Tuesday, January 06, 1998", "Long Date: " & TestStr & " (Test only applies to en_US locale)")
+ 'TestUtilModule.AssertTrue(IsDate(TestStr), "Long Date: " & TestStr)
TestStr = Format(myDate, "Medium Date") ' 06-Jan-98
- 'TestLog_ASSERT TestStr = "06-Jan-98", "Medium Date: " & TestStr
- TestLog_ASSERT IsDate(TestStr), "Medium Date: " & TestStr & " (Test only applies to en_US locale)"
-
+ 'TestUtilModule.AssertTrue(TestStr = "06-Jan-98", "Medium Date: " & TestStr)
+ TestUtilModule.AssertTrue(IsDate(TestStr), "Medium Date: " & TestStr & " (Test only applies to en_US locale)")
TestStr = Format(myDate, "Short Date") ' 1/6/98
- 'TestLog_ASSERT TestStr = "1/6/98", "Short Date: " & TestStr
- TestLog_ASSERT IsDate(TestStr), "Short Date: " & TestStr & " (Test only applies to en_US locale)"
+ 'TestUtilModule.AssertTrue(TestStr = "1/6/98", "Short Date: " & TestStr)
+ TestUtilModule.AssertTrue(IsDate(TestStr), "Short Date: " & TestStr & " (Test only applies to en_US locale)")
TestStr = Format(MyTime, "Long Time") ' 5:08:06 PM
- 'TestLog_ASSERT TestStr = "5:08:06 PM", "Long Time: " & TestStr
- TestLog_ASSERT IsDate(TestStr), "Long Time: " & TestStr & " (Test only applies to en_US locale)"
-
+ 'TestUtilModule.AssertTrue(TestStr = "5:08:06 PM", "Long Time: " & TestStr)
+ TestUtilModule.AssertTrue(IsDate(TestStr), "Long Time: " & TestStr & " (Test only applies to en_US locale)")
TestStr = Format(MyTime, "Medium Time") ' 05:08 PM
- 'TestLog_ASSERT TestStr = "05:08 PM", "Medium Time: " & TestStr
- TestLog_ASSERT IsDate(TestStr), "Medium Time: " & TestStr & " (Test only applies to en_US locale)"
-
+ 'TestUtilModule.AssertTrue(TestStr = "05:08 PM", "Medium Time: " & TestStr)
+ TestUtilModule.AssertTrue(IsDate(TestStr), "Medium Time: " & TestStr & " (Test only applies to en_US locale)")
TestStr = Format(MyTime, "Short Time") ' 17:08
- 'TestLog_ASSERT TestStr = "17:08", "Short Time: " & TestStr
- TestLog_ASSERT IsDate(TestStr), "Short Time: " & TestStr & " (Test only applies to en_US locale)"
+ 'TestUtilModule.AssertTrue(TestStr = "17:08", "Short Time: " & TestStr)
+ TestUtilModule.AssertTrue(IsDate(TestStr), "Short Time: " & TestStr & " (Test only applies to en_US locale)")
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
Sub Predefined_Number_Format_Sample()
@@ -86,56 +70,56 @@ Sub Predefined_Number_Format_Sample()
On Error GoTo errorHandler
TestStr = Format(myNumber, "General Number") '562486.2356
- TestLog_ASSERT TestStr = "562486.2356", "General Number: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "562486.2356", "General Number: " & TestStr)
'MsgBox TestStr
TestStr = Format(0.2, "Fixed") '0.20
- TestLog_ASSERT TestStr = "0.20", "Fixed: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "0.20", "Fixed: " & TestStr)
'MsgBox TestStr
TestStr = Format(myNumber, "Standard") '562,486.24
- TestLog_ASSERT TestStr = "562,486.24", "Standard: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "562,486.24", "Standard: " & TestStr)
'MsgBox TestStr
TestStr = Format(0.7521, "Percent") '75.21%
- TestLog_ASSERT TestStr = "75.21%", "Percent: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "75.21%", "Percent: " & TestStr)
'MsgBox TestStr
TestStr = Format(myNumber, "Scientific") '5.62E+05
- TestLog_ASSERT TestStr = "5.62E+05", "Scientific: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "5.62E+05", "Scientific: " & TestStr)
'MsgBox TestStr
TestStr = Format(-3456.789, "Scientific") '-3.46E+03
- TestLog_ASSERT TestStr = "-3.46E+03", "Scientific: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "-3.46E+03", "Scientific: " & TestStr)
'MsgBox TestStr
TestStr = Format(0, "Yes/No") 'No
- TestLog_ASSERT TestStr = "No", "Yes/No: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "No", "Yes/No: " & TestStr)
'MsgBox TestStr
TestStr = Format(23, "Yes/No") 'Yes
- TestLog_ASSERT TestStr = "Yes", "Yes/No: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "Yes", "Yes/No: " & TestStr)
'MsgBox TestStr
TestStr = Format(0, "True/False") 'False
- TestLog_ASSERT TestStr = "False", "True/False: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "False", "True/False: " & TestStr)
'MsgBox TestStr
TestStr = Format(23, "True/False") 'True
- TestLog_ASSERT TestStr = "True", "True/False: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "True", "True/False: " & TestStr)
'MsgBox TestStr
TestStr = Format(0, "On/Off") 'Off
- TestLog_ASSERT TestStr = "Off", "On/Off: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "Off", "On/Off: " & TestStr)
'MsgBox TestStr
TestStr = Format(23, "On/Off") 'On
- TestLog_ASSERT TestStr = "On", "On/Off: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "On", "On/Off: " & TestStr)
'MsgBox TestStr
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
@@ -150,107 +134,105 @@ Sub Custom_Datetime_Format_Sample()
On Error GoTo errorHandler
TestStr = Format("01/06/98 17:08:06", "c") ' 1/6/98 5:08:06 PM
- TestLog_ASSERT TestStr = "1/6/98 5:08:06 PM", "c: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "1/6/98 5:08:06 PM", "c: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "dddddd") ' (Long Date), Tuesday, January 06, 1998
- TestLog_ASSERT TestStr = "Tuesday, January 06, 1998", "dddddd: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "Tuesday, January 06, 1998", "dddddd: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "mm-dd-yyyy") ' 01-06-19s98
- TestLog_ASSERT TestStr = "01-06-1998", "mm-dd-yyyy: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "01-06-1998", "mm-dd-yyyy: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "d") ' 6
- TestLog_ASSERT TestStr = "6", "d: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "6", "d: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "dd") ' 06
- TestLog_ASSERT TestStr = "06", "dd: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "06", "dd: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "ddd") ' Tue
- TestLog_ASSERT TestStr = "Tue", "ddd: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "Tue", "ddd: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "dddd") ' Tuesday
- TestLog_ASSERT TestStr = "Tuesday", "dddd: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "Tuesday", "dddd: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "h") ' 5
- TestLog_ASSERT TestStr = "5", "h: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "5", "h: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "hh") ' 05
- TestLog_ASSERT TestStr = "05", "hh: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "05", "hh: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "n") ' 8
- TestLog_ASSERT TestStr = "8", "n: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "8", "n: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "nn") ' 08
- TestLog_ASSERT TestStr = "08", "nn: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "08", "nn: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "m") ' 1
- TestLog_ASSERT TestStr = "1", "m: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "1", "m: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "mm") ' 01
- TestLog_ASSERT TestStr = "01", "mm: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "01", "mm: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "mmm") ' Jan
- TestLog_ASSERT TestStr = "Jan", "mmm: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "Jan", "mmm: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "mmmm") ' January
- TestLog_ASSERT TestStr = "January", "mmmm: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "January", "mmmm: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "s") ' 6
- TestLog_ASSERT TestStr = "6", "s: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "6", "s: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(MyTime, "ss") ' 06
- TestLog_ASSERT TestStr = "06", "ss: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "06", "ss: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
-
MyTime = "17:08:06"
TestStr = Format(MyTime, "hh:mm:ss AM/PM") ' 05:08:06 PM
- TestLog_ASSERT TestStr = "05:08:06 PM", "hh:mm:ss AM/PM: " & TestStr & " (Test only applies to en_US locale)"
-
+ TestUtilModule.AssertTrue(TestStr = "05:08:06 PM", "hh:mm:ss AM/PM: " & TestStr & " (Test only applies to en_US locale)")
TestStr = Format(MyTime, "hh:mm:ss") ' 17:08:06
- TestLog_ASSERT TestStr = "17:08:06", "hh:mm:ss: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "17:08:06", "hh:mm:ss: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "ww") ' 2
- TestLog_ASSERT TestStr = "2", "ww: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "2", "ww: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "w") ' 3
- TestLog_ASSERT TestStr = "3", "w: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "3", "w: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "y") ' 6
- TestLog_ASSERT TestStr = "6", "y: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "6", "y: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "yy") ' 98
- TestLog_ASSERT TestStr = "98", "yy: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "98", "yy: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
TestStr = Format(myDate, "yyyy") ' 1998
- TestLog_ASSERT TestStr = "1998", "yyyy: " & TestStr & " (Test only applies to en_US locale)"
+ TestUtilModule.AssertTrue(TestStr = "1998", "yyyy: " & TestStr & " (Test only applies to en_US locale)")
'MsgBox TestStr
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
Sub Custom_Number_Format_Sample()
@@ -261,100 +243,100 @@ Sub Custom_Number_Format_Sample()
On Error GoTo errorHandler
TestStr = Format(23.675, "00.0000") ' 23.6750
- TestLog_ASSERT TestStr = "23.6750", "00.0000: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "23.6750", "00.0000: " & TestStr)
'MsgBox TestStr
TestStr = Format(23.675, "00.00") ' 23.68
- TestLog_ASSERT TestStr = "23.68", "00.00: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "23.68", "00.00: " & TestStr)
'MsgBox TestStr
TestStr = Format(2658, "00000") ' 02658
- TestLog_ASSERT TestStr = "02658", "00000: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "02658", "00000: " & TestStr)
'MsgBox TestStr
TestStr = Format(2658, "00.00") ' 2658.00
- TestLog_ASSERT TestStr = "2658.00", "00.00: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "2658.00", "00.00: " & TestStr)
'MsgBox TestStr
TestStr = Format(23.675, "##.####") ' 23.675
- TestLog_ASSERT TestStr = "23.675", "##.####: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "23.675", "##.####: " & TestStr)
'MsgBox TestStr
TestStr = Format(23.675, "##.##") ' 23.68
- TestLog_ASSERT TestStr = "23.68", "##.##: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "23.68", "##.##: " & TestStr)
'MsgBox TestStr
TestStr = Format(12345.25, "#,###.##") '12,345.25
- TestLog_ASSERT TestStr = "12,345.25", "#,###.##: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "12,345.25", "#,###.##: " & TestStr)
'MsgBox TestStr
TestStr = Format(0.25, "##.00%") '25.00%
- TestLog_ASSERT TestStr = "25.00%", "##.00%: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "25.00%", "##.00%: " & TestStr)
'MsgBox TestStr
TestStr = Format(1000000, "#,###") '1,000,000
- TestLog_ASSERT TestStr = "1,000,000", "#,###: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1,000,000", "#,###: " & TestStr)
'MsgBox TestStr
TestStr = Format(1.09837555, "#.#####E+###") '1.09838E+000
- TestLog_ASSERT TestStr = "1.09838E+000", "#.#####E+###: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1.09838E+000", "#.#####E+###: " & TestStr)
'MsgBox TestStr
TestStr = Format(1.09837555, "###.####E#") '1.0984E0 with engineering notation
- TestLog_ASSERT TestStr = "1.0984E0", "###.####E#: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1.0984E0", "###.####E#: " & TestStr)
'MsgBox TestStr
TestStr = Format(1098.37555, "###.####E#") '1.0984E3 with engineering notation
- TestLog_ASSERT TestStr = "1.0984E3", "###.####E#: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1.0984E3", "###.####E#: " & TestStr)
'MsgBox TestStr
TestStr = Format(1098375.55, "###.####E#") '1.0984E6 with engineering notation
- TestLog_ASSERT TestStr = "1.0984E6", "###.####E#: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1.0984E6", "###.####E#: " & TestStr)
'MsgBox TestStr
TestStr = Format(1.09837555, "######E#") '1E0 with engineering notation
- TestLog_ASSERT TestStr = "1E0", "######E#: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "1E0", "######E#: " & TestStr)
'MsgBox TestStr
TestStr = Format(123456.789, "###E0") '123E3 with engineering notation
- TestLog_ASSERT TestStr = "123E3", "###E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "123E3", "###E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(123567.89, "###E0") '124E3 with engineering notation
- TestLog_ASSERT TestStr = "124E3", "###E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "124E3", "###E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(12, "###E0") '12E0 with engineering notation
- TestLog_ASSERT TestStr = "12E0", "###E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "12E0", "###E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(12, "000E0") '012E0 with engineering notation
- TestLog_ASSERT TestStr = "012E0", "000E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "012E0", "000E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(0.12345, "###E0") '123E-3 with engineering notation
- TestLog_ASSERT TestStr = "123E-3", "###E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "123E-3", "###E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(123456, "####E0") '12E4 with interval-4 notation
- TestLog_ASSERT TestStr = "12E4", "####E0: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "12E4", "####E0: " & TestStr)
'MsgBox TestStr
TestStr = Format(2345.25, "$#,###.##") '$2.345.25
- TestLog_ASSERT TestStr = "$2,345.25", "$#,###.##: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "$2,345.25", "$#,###.##: " & TestStr)
'MsgBox TestStr
TestStr = Format(0.25, "##.###\%") '.25%
- TestLog_ASSERT TestStr = ".25%", "##.###\%: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = ".25%", "##.###\%: " & TestStr)
'MsgBox TestStr
TestStr = Format(12.25, "0.???") '12.25_
- TestLog_ASSERT TestStr = "12.25 ", "0.???: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "12.25 ", "0.???: " & TestStr)
'MsgBox TestStr
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & ": hit error handler"
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
Sub Custom_Text_Format_Sample()
@@ -367,20 +349,18 @@ Sub Custom_Text_Format_Sample()
On Error GoTo errorHandler
TestStr = Format(myText, "<") 'vba
- TestLog_ASSERT TestStr = "vba", "<: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "vba", "<: " & TestStr)
'MsgBox TestStr
TestStr = Format("vba", ">") 'VBA
- TestLog_ASSERT TestStr = "VBA", ">: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "VBA", ">: " & TestStr)
'MsgBox TestStr
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & "hit error handler"
+ TestUtilModule.AssertTrue(False, testName & "hit error handler")
End Sub
-
-
Sub testFormat()
Dim testName As String
Dim TestDateTime As Date
@@ -394,57 +374,38 @@ Sub testFormat()
' Returns the value of TestDateTime in user-defined date/time formats.
' Returns "17:4:23".
TestStr = Format(TestDateTime, "h:m:s")
- TestLog_ASSERT TestStr = "17:4:23", "the format of h:m:s: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "17:4:23", "the format of h:m:s: " & TestStr)
' Returns "05:04:23 PM".
TestStr = Format(TestDateTime, "ttttt")
- TestLog_ASSERT TestStr = "5:04:23 PM", "the format of ttttt: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "5:04:23 PM", "the format of ttttt: " & TestStr)
' Returns "Saturday, Jan 27 2001".
TestStr = Format(TestDateTime, "dddd, MMM d yyyy")
- TestLog_ASSERT TestStr = "Saturday, Jan 27 2001", "the format of dddd, MMM d yyyy: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "Saturday, Jan 27 2001", "the format of dddd, MMM d yyyy: " & TestStr)
' Returns "17:04:23".
TestStr = Format(TestDateTime, "HH:mm:ss")
- TestLog_ASSERT TestStr = "17:04:23", "the format of HH:mm:ss: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "17:04:23", "the format of HH:mm:ss: " & TestStr)
' Returns "23".
TestStr = Format(23)
- TestLog_ASSERT TestStr = "23", "no format:" & TestStr
+ TestUtilModule.AssertTrue(TestStr = "23", "no format:" & TestStr)
' User-defined numeric formats.
' Returns "5,459.40".
TestStr = Format(5459.4, "##,##0.00")
- TestLog_ASSERT TestStr = "5,459.40", "the format of ##,##0.00: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "5,459.40", "the format of ##,##0.00: " & TestStr)
' Returns "334.90".
TestStr = Format(334.9, "###0.00")
- TestLog_ASSERT TestStr = "334.90", "the format of ###0.00: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "334.90", "the format of ###0.00: " & TestStr)
' Returns "500.00%".
TestStr = Format(5, "0.00%")
- TestLog_ASSERT TestStr = "500.00%", "the format of 0.00%: " & TestStr
+ TestUtilModule.AssertTrue(TestStr = "500.00%", "the format of 0.00%: " & TestStr)
Exit Sub
errorHandler:
- TestLog_ASSERT (false), testName & ": hit error handler"
-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
-
+ TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub
diff --git a/basic/qa/vba_tests/formatnumber.vb b/basic/qa/vba_tests/formatnumber.vb
index 357fd19426f0..d26fc4ae2843 100644
--- a/basic/qa/vba_tests/formatnumber.vb
+++ b/basic/qa/vba_tests/formatnumber.vb
@@ -1,25 +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_testFormatNumber()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testFormatNumber
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testFormatNumber() As String
-
- passCount = 0
- failCount = 0
+Sub verify_testFormatNumber()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim str1 As String, str2 As String
@@ -28,56 +17,37 @@ Function verify_testFormatNumber() As String
testName = "Test 1: positive, 2 decimals"
str2 = "12.20"
str1 = FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
testName = "Test 2: negative, 20 decimals, use leading zero"
str2 = "-0.20000000000000000000"
str1 = FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
testName = "Test 3: negative, 20 decimals, no leading zero"
str2 = "-.20000000000000000000"
str1 = FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
testName = "Test 4: negative, no leading zero, use parens"
str2 = "(.20)"
str1 = FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
testName = "Test 5: negative, default leading zero, use parens"
str2 = "(0.20)"
str1 = FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
testName = "Test 6: group digits"
str2 = "-12,345,678.00"
str1 = FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue)
- TestLog_ASSERT str1 = str2, testName, "FormatNumber returned: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, testName, "FormatNumber returned: " & str1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testFormatNumber = 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 = 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/hex.vb b/basic/qa/vba_tests/hex.vb
index 83af4c148338..47ac7094d912 100644
--- a/basic/qa/vba_tests/hex.vb
+++ b/basic/qa/vba_tests/hex.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_testHex()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testHex
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testHex()
-
-Function verify_testHex() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,57 +17,36 @@ Function verify_testHex() As String
date2 = "9"
date1 = Hex(9)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "9"
date1 = Hex(9)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "A"
date1 = Hex(10)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "10"
date1 = Hex(16)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "FF"
date1 = Hex(255)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "100"
date1 = Hex(256)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
date2 = "1CB"
date1 = Hex(459)
- TestLog_ASSERT date1 = date2, "the return Hex is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hex is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testHex = 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/hour.vb b/basic/qa/vba_tests/hour.vb
index 9236463f42e8..e0de888e8f2c 100644
--- a/basic/qa/vba_tests/hour.vb
+++ b/basic/qa/vba_tests/hour.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_testHour()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testHour
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testHour()
-
-Function verify_testHour() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2, myTime
@@ -30,42 +18,22 @@ Function verify_testHour() As String
myTime = "6:25:39 AM"
date2 = 6
date1 = Hour(myTime)
- TestLog_ASSERT date1 = date2, "the return Hour is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1)
myTime = "6:25:39 PM"
date2 = 18
date1 = Hour(myTime)
- TestLog_ASSERT date1 = date2, "the return Hour is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1)
myTime = "06:25:39 AM"
date2 = 6
date1 = Hour(myTime)
- TestLog_ASSERT date1 = date2, "the return Hour is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Hour is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testHour = 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/iif.vb b/basic/qa/vba_tests/iif.vb
index fd77563e52df..ecb264b81640 100644
--- a/basic/qa/vba_tests/iif.vb
+++ b/basic/qa/vba_tests/iif.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_testIIf()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIIf
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIIf()
-
-Function verify_testIIf() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2, testnr
@@ -29,41 +17,21 @@ Function verify_testIIf() As String
date2 = "it is true"
date1 = IIf(True, "it is true", "it is false")
- TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1)
date2 = "it is false"
date1 = IIf(False, "It is true", "it is false")
- TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1)
testnr = 1001
date2 = "Large"
date1 = IIf(testnr > 1000, "Large", "Small")
- TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IIf is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIIf = 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/instr.vb b/basic/qa/vba_tests/instr.vb
index b8977088ba83..cefcd9359453 100644
--- a/basic/qa/vba_tests/instr.vb
+++ b/basic/qa/vba_tests/instr.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_testInStr()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testInStr
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testInStr()
-
-Function verify_testInStr() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2, SearchString, SearchChar
@@ -29,58 +17,38 @@ Function verify_testInStr() As String
date2 = 5
date1 = InStr(1, "somemoretext", "more")
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
date2 = 5
date1 = InStr("somemoretext", "more")
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
date2 = 1
date1 = InStr("somemoretext", "somemoretext")
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
date2 = 0
date1 = InStr("somemoretext", "nothing")
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
SearchString = "XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".
date2 = 6
date1 = InStr(4, SearchString, SearchChar, 1)
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
date2 = 9
date1 = InStr(1, SearchString, SearchChar, 0)
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
date2 = 0
date1 = InStr(1, SearchString, "W")
- TestLog_ASSERT date1 = date2, "the return InStr is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStr is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testInStr = 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/instrrev.vb b/basic/qa/vba_tests/instrrev.vb
index 7fe02cd60617..b201594ffa40 100644
--- a/basic/qa/vba_tests/instrrev.vb
+++ b/basic/qa/vba_tests/instrrev.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_testInStrRev()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testInStrRev
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testInStrRev()
-
-Function verify_testInStrRev() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2, SearchString, SearchChar
@@ -29,58 +17,38 @@ Function verify_testInStrRev() As String
date2 = 5
date1 = InStrRev("somemoretext", "more", -1)
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
date2 = 5
date1 = InStrRev("somemoretext", "more")
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
date2 = 1
date1 = InStrRev("somemoretext", "somemoretext")
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
date2 = 0
date1 = InStrRev("somemoretext", "nothing")
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
SearchString = "XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".
date2 = 3
date1 = InStrRev(SearchString, SearchChar, 4, 1)
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
date2 = 12
date1 = InStrRev(SearchString, SearchChar, -1, 0)
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
date2 = 0
date1 = InStrRev(SearchString, "W", 1)
- TestLog_ASSERT date1 = date2, "the return InStrRev is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return InStrRev is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testInStrRev = 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/int.vb b/basic/qa/vba_tests/int.vb
index c5495a87d5f9..e809a0d975c1 100644
--- a/basic/qa/vba_tests/int.vb
+++ b/basic/qa/vba_tests/int.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_testInt()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testInt
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testInt()
-
-Function verify_testInt() 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,28 @@ Function verify_testInt() As String
date2 = 99
date1 = Int(99.8)
- TestLog_ASSERT date1 = date2, "the return Int is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1)
date2 = -100
date1 = Int(-99.8)
- TestLog_ASSERT date1 = date2, "the return Int is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1)
date2 = -100
date1 = Int(-99.2)
- TestLog_ASSERT date1 = date2, "the return Int is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1)
date2 = 0
date1 = Int(0.2)
- TestLog_ASSERT date1 = date2, "the return Int is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1)
date2 = 0
date1 = Int(0)
- TestLog_ASSERT date1 = date2, "the return Int is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Int is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testInt = 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/isarray.vb b/basic/qa/vba_tests/isarray.vb
index 3f7dc8a8c265..1a76d8af3b37 100644
--- a/basic/qa/vba_tests/isarray.vb
+++ b/basic/qa/vba_tests/isarray.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_testIsArray()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsArray
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsArray()
-
-Function verify_testIsArray() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -31,40 +19,20 @@ Function verify_testIsArray() As String
date2 = True
date1 = IsArray(MyArray)
- TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1)
date2 = True
date1 = IsArray(YourArray)
- TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1)
date2 = False
date1 = IsArray(date2)
- TestLog_ASSERT date1 = date2, "the return IsArray is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsArray is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsArray = 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/isdate.vb b/basic/qa/vba_tests/isdate.vb
index 355c9bb8b942..c4993cbee876 100644
--- a/basic/qa/vba_tests/isdate.vb
+++ b/basic/qa/vba_tests/isdate.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_testIsDate()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsDate
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsDate()
-
-Function verify_testIsDate() 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_testIsDate() As String
date2 = True
date1 = IsDate(cdate("12/2/1969"))
- TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1)
date2 = True
date1 = IsDate("12:22:12")
- TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1)
date2 = False
date1 = IsDate("a12.2.1969")
- TestLog_ASSERT date1 = date2, "the return IsDate is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsDate is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsDate = 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/isempty.vb b/basic/qa/vba_tests/isempty.vb
index 1080122fada3..d4066f0a7e3b 100644
--- a/basic/qa/vba_tests/isempty.vb
+++ b/basic/qa/vba_tests/isempty.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_testIsEmpty()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsEmpty
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsEmpty()
-
-Function verify_testIsEmpty() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2, MyVar
@@ -29,42 +17,22 @@ Function verify_testIsEmpty() As String
date2 = True
date1 = IsEmpty(MyVar)
- TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1)
MyVar = Null ' Assign Null.
date2 = False
date1 = IsEmpty(MyVar)
- TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1)
MyVar = Empty ' Assign Empty.
date2 = True
date1 = IsEmpty(MyVar)
- TestLog_ASSERT date1 = date2, "the return IsEmpty is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsEmpty is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsEmpty = 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/iserror.vb b/basic/qa/vba_tests/iserror.vb
index d1a9b2d857af..919c3c47656a 100644
--- a/basic/qa/vba_tests/iserror.vb
+++ b/basic/qa/vba_tests/iserror.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_testIsError()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsError
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsError()
-
-Function verify_testIsError() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,36 +17,16 @@ Function verify_testIsError() As String
date2 = False
date1 = IsError("12.2.1969")
- TestLog_ASSERT date1 = date2, "the return IsError is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsError is: " & date1)
date2 = True
date1 = IsError(CVErr(64))
- TestLog_ASSERT date1 = date2, "the return IsError is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsError is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsError = 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/ismissing.vb b/basic/qa/vba_tests/ismissing.vb
index 623c153d4d72..5e60915473ef 100644
--- a/basic/qa/vba_tests/ismissing.vb
+++ b/basic/qa/vba_tests/ismissing.vb
@@ -1,21 +1,13 @@
Option VBASupport 1
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Const IsMissingNone = -1
Const IsMissingA = 0
Const IsMissingB = 1
Const IsMissingAB = 2
Function doUnitTest() As String
- result = verify_testIsMissingVba()
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ verify_testIsMissingVba
+ doUnitTest = TestUtilModule.GetResult()
End Function
' tdf#36737 - Test isMissing function with different datatypes. In LO Basic
@@ -23,62 +15,59 @@ End Function
' default values. Missing optional parameters having types other than variant,
' which don't have explicit default values, will be initialized to their
' respective default value of its datatype.
-Function verify_testIsMissingVba() As String
-
- passCount = 0
- failCount = 0
+Sub verify_testIsMissingVba()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
testName = "Test missing (VBA)"
On Error GoTo errorHandler
' optionals with variant datatypes
- TestLog_ASSERT TestOptVariant(), IsMissingA, "TestOptVariant()"
- TestLog_ASSERT TestOptVariant(123), IsMissingNone, "TestOptVariant(123)"
- TestLog_ASSERT TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)"
- TestLog_ASSERT TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)"
+ TestUtilModule.AssertEqual(TestOptVariant(), IsMissingA, "TestOptVariant()")
+ TestUtilModule.AssertEqual(TestOptVariant(123), IsMissingNone, "TestOptVariant(123)")
+ TestUtilModule.AssertEqual(TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)")
+ TestUtilModule.AssertEqual(TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)")
' optionals with variant datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()"
- TestLog_ASSERT TestOptVariantByRefByVal(123),IsMissingNone, "TestOptVariantByRefByVal(123)"
- TestLog_ASSERT TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)"
- TestLog_ASSERT TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)"
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123),IsMissingNone, "TestOptVariantByRefByVal(123)")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)")
' optionals with double datatypes
- TestLog_ASSERT TestOptDouble(), IsMissingNone, "TestOptDouble()"
- TestLog_ASSERT TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)"
- TestLog_ASSERT TestOptDouble(, 567.8), IsMissingNone, "TestOptDouble(, 567.8)"
- TestLog_ASSERT TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)"
+ TestUtilModule.AssertEqual(TestOptDouble(), IsMissingNone, "TestOptDouble()")
+ TestUtilModule.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtilModule.AssertEqual(TestOptDouble(, 567.8), IsMissingNone, "TestOptDouble(, 567.8)")
+ TestUtilModule.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)")
' optionals with double datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptDoubleByRefByVal(), IsMissingNone, "TestOptDouble()"
- TestLog_ASSERT TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)"
- TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(, 567.8)"
- TestLog_ASSERT TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)"
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(), IsMissingNone, "TestOptDouble()")
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)")
' optionals with integer datatypes
- TestLog_ASSERT TestOptInteger(), IsMissingNone, "TestOptInteger()"
- TestLog_ASSERT TestOptInteger(123), IsMissingNone, "TestOptInteger(123)"
- TestLog_ASSERT TestOptInteger(, 456), IsMissingNone, "TestOptInteger(, 456)"
- TestLog_ASSERT TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)"
+ TestUtilModule.AssertEqual(TestOptInteger(), IsMissingNone, "TestOptInteger()")
+ TestUtilModule.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)")
+ TestUtilModule.AssertEqual(TestOptInteger(, 456), IsMissingNone, "TestOptInteger(, 456)")
+ TestUtilModule.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)")
' optionals with integer datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptIntegerByRefByVal(), IsMissingNone, "TestOptIntegerByRefByVal()"
- TestLog_ASSERT TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)"
- TestLog_ASSERT TestOptIntegerByRefByVal(, 456), IsMissingNone, "TestOptIntegerByRefByVal(, 456)"
- TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)"
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(), IsMissingNone, "TestOptIntegerByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingNone, "TestOptIntegerByRefByVal(, 456)")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)")
' optionals with string datatypes
- TestLog_ASSERT TestOptString(), IsMissingNone, "TestOptString()"
- TestLog_ASSERT TestOptString("123"), IsMissingNone, "TestOptString(""123"")"
- TestLog_ASSERT TestOptString(, "456"), IsMissingNone, "TestOptString(, ""456"")"
- TestLog_ASSERT TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")"
+ TestUtilModule.AssertEqual(TestOptString(), IsMissingNone, "TestOptString()")
+ TestUtilModule.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")")
+ TestUtilModule.AssertEqual(TestOptString(, "456"), IsMissingNone, "TestOptString(, ""456"")")
+ TestUtilModule.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")")
' optionals with string datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptStringByRefByVal(), IsMissingNone, "TestOptStringByRefByVal()"
- TestLog_ASSERT TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")"
- TestLog_ASSERT TestOptStringByRefByVal(, "456"), IsMissingNone, "TestOptStringByRefByVal(, ""456"")"
- TestLog_ASSERT TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")"
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal(), IsMissingNone, "TestOptStringByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingNone, "TestOptStringByRefByVal(, ""456"")")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")")
' optionals with object datatypes
Dim cA As New Collection
@@ -87,16 +76,16 @@ Function verify_testIsMissingVba() As String
Dim cB As New Collection
cB.Add (123.4)
cB.Add (567.8)
- TestLog_ASSERT TestOptObject(), IsMissingAB, "TestOptObject()"
- TestLog_ASSERT TestOptObject(cA), IsMissingB, "TestOptObject(A)"
- TestLog_ASSERT TestOptObject(, cB), IsMissingA, "TestOptObject(, B)"
- TestLog_ASSERT TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)"
+ TestUtilModule.AssertEqual(TestOptObject(), IsMissingAB, "TestOptObject()")
+ TestUtilModule.AssertEqual(TestOptObject(cA), IsMissingB, "TestOptObject(A)")
+ TestUtilModule.AssertEqual(TestOptObject(, cB), IsMissingA, "TestOptObject(, B)")
+ TestUtilModule.AssertEqual(TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)")
' optionals with object datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()"
- TestLog_ASSERT TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)"
- TestLog_ASSERT TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)"
- TestLog_ASSERT TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)"
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)")
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)")
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)")
' optionals with array datatypes
Dim aA(0 To 1) As Integer
@@ -106,25 +95,24 @@ Function verify_testIsMissingVba() As String
aB(0) = 123.4
aB(1) = 567.8
' TODO - New bug report? Scanner initializes variable not as an array
- ' TestLog_ASSERT TestOptArray(), IsMissingAB, "TestOptArray()"
- ' TestLog_ASSERT TestOptArray(aA), IsMissingB, "TestOptArray(A)"
- ' TestLog_ASSERT TestOptArray(, aB), IsMissingA, "TestOptArray(, B)"
- TestLog_ASSERT TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)"
+ ' TestUtilModule.AssertEqual(TestOptArray(), IsMissingAB, "TestOptArray()")
+ ' TestUtilModule.AssertEqual(TestOptArray(aA), IsMissingB, "TestOptArray(A)")
+ ' TestUtilModule.AssertEqual(TestOptArray(, aB), IsMissingA, "TestOptArray(, B)")
+ TestUtilModule.AssertEqual(TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)")
' optionals with array datatypes (ByRef and ByVal)
' TODO - New bug report? Scanner initializes variable not as an array
- ' TestLog_ASSERT TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()"
- ' TestLog_ASSERT TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)"
- ' TestLog_ASSERT TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)"
- TestLog_ASSERT TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)"
+ ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()")
+ ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)")
+ ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)")
+ TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)")
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsMissingVba = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT False, True, Err.Description
-End Function
+ TestUtilModule.AssertEqual(False, True, Err.Description)
+End Sub
Function TestOptVariant(Optional A, Optional B As Variant = 123)
TestOptVariant = WhatIsMissing(IsMissing(A), IsMissing(B))
@@ -186,11 +174,3 @@ Function WhatIsMissing(is_missingA, is_missingB)
End If
End Function
-Sub TestLog_ASSERT(actual As Variant, expected As Integer, testName As String)
- If expected = actual Then
- passCount = passCount + 1
- Else
- result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
- failCount = failCount + 1
- End If
-End Sub \ No newline at end of file
diff --git a/basic/qa/vba_tests/isnull.vb b/basic/qa/vba_tests/isnull.vb
index 145294f6d961..1819f3c72ef3 100644
--- a/basic/qa/vba_tests/isnull.vb
+++ b/basic/qa/vba_tests/isnull.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_testIsNull()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsNull
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsNull()
-
-Function verify_testIsNull() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,36 +17,16 @@ Function verify_testIsNull() As String
date2 = True
date1 = IsNull(Null)
- TestLog_ASSERT date1 = date2, "the return IsNull is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNull is: " & date1)
date2 = False
date1 = IsNull("")
- TestLog_ASSERT date1 = date2, "the return IsNull is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNull is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsNull = 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/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb
index 511a51bd9106..d2b6e2715182 100644
--- a/basic/qa/vba_tests/isnumeric.vb
+++ b/basic/qa/vba_tests/isnumeric.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_testIsNumeric()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsNumeric
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsNumeric()
-
-Function verify_testIsNumeric() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,56 +17,36 @@ Function verify_testIsNumeric() As String
date2 = True
date1 = IsNumeric(123)
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
date2 = True
date1 = IsNumeric(-123)
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
date2 = True
date1 = IsNumeric(123.8)
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
date2 = False
date1 = IsNumeric("a")
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
rem date2 = True
rem date1 = IsNumeric(True)
-rem TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+rem TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
date2 = True
date1 = IsNumeric("123")
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
date2 = True
date1 = IsNumeric("+123")
- TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsNumeric is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsNumeric = 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/isobject.vb b/basic/qa/vba_tests/isobject.vb
index 82a1a0aa39a6..e6a73fd7fba1 100644
--- a/basic/qa/vba_tests/isobject.vb
+++ b/basic/qa/vba_tests/isobject.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_testIsObject()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testIsObject
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testIsObject()
-
-Function verify_testIsObject() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestStr As String
@@ -32,36 +20,16 @@ Function verify_testIsObject() As String
Set YourObject = MyObject ' Assign an object reference.
date2 = True
date1 = IsObject(YourObject)
- TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsObject is: " & date1)
date2 = False
date1 = IsObject(TestStr)
- TestLog_ASSERT date1 = date2, "the return IsObject is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return IsObject is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testIsObject = 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/join.vb b/basic/qa/vba_tests/join.vb
index e09cf8ac8dfa..6e57f5b68132 100644
--- a/basic/qa/vba_tests/join.vb
+++ b/basic/qa/vba_tests/join.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_testJoin()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testJoin
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testJoin()
-
-Function verify_testJoin() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim str1, str2 As String
@@ -33,44 +21,24 @@ Function verify_testJoin() As String
str2 = "string1 string2 string3"
str1 = Join(vaArray)
- TestLog_ASSERT str1 = str2, "the return Join is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1)
str2 = "string1 string2 string3"
str1 = Join(vaArray, " ")
- TestLog_ASSERT str1 = str2, "the return Join is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1)
str2 = "string1<>string2<>string3"
str1 = Join(vaArray, "<>")
- TestLog_ASSERT str1 = str2, "the return Join is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1)
str2 = "string1string2string3"
str1 = Join(vaArray, "")
- TestLog_ASSERT str1 = str2, "the return Join is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return Join is: " & str1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testJoin = 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/lbound.vb b/basic/qa/vba_tests/lbound.vb
index 34999c534349..20ff5eb3b3d0 100644
--- a/basic/qa/vba_tests/lbound.vb
+++ b/basic/qa/vba_tests/lbound.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_testLBound()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLBound
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLBound()
-
-Function verify_testLBound() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -30,37 +18,16 @@ Function verify_testLBound() As String
date2 = 1
date1 = LBound(MyArray, 1)
- TestLog_ASSERT date1 = date2, "the return LBound is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return LBound is: " & date1)
date2 = 10
date1 = LBound(MyArray, 3)
- TestLog_ASSERT date1 = date2, "the return LBound is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return LBound is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLBound = 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/lcase.vb b/basic/qa/vba_tests/lcase.vb
index d0916341d64d..ed6610d105d3 100644
--- a/basic/qa/vba_tests/lcase.vb
+++ b/basic/qa/vba_tests/lcase.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_testLCase()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLCase
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLCase()
-
-Function verify_testLCase() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim str1, str2 As String 'variables for test
@@ -29,45 +17,24 @@ Function verify_testLCase() As String
str2 = "lowercase"
str1 = LCase("LOWERCASE")
- TestLog_ASSERT str1 = str2, "the return LCase is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1)
str2 = "lowercase"
str1 = LCase("LowerCase")
- TestLog_ASSERT str1 = str2, "the return LCase is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1)
str2 = "lowercase"
str1 = LCase("lowercase")
- TestLog_ASSERT str1 = str2, "the return LCase is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1)
str2 = "lower case"
str1 = LCase("LOWER CASE")
- TestLog_ASSERT str1 = str2, "the return LCase is: " & str1
+ TestUtilModule.AssertTrue(str1 = str2, "the return LCase is: " & str1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLCase = 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/left.vb b/basic/qa/vba_tests/left.vb
index 8a6576fd2cbc..609eee535b91 100644
--- a/basic/qa/vba_tests/left.vb
+++ b/basic/qa/vba_tests/left.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_testLeft()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLeft
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLeft()
-
-Function verify_testLeft() 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_testLeft() As String
date2 = "some"
date1 = Left("sometext", 4)
- TestLog_ASSERT date1 = date2, "the return Left is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1)
date2 = "sometext"
date1 = Left("sometext", 48)
- TestLog_ASSERT date1 = date2, "the return Left is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1)
date2 = ""
date1 = Left("", 4)
- TestLog_ASSERT date1 = date2, "the return Left is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Left is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLeft = 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/len.vb b/basic/qa/vba_tests/len.vb
index d524d96b8af1..679ccc49cdbd 100644
--- a/basic/qa/vba_tests/len.vb
+++ b/basic/qa/vba_tests/len.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_testLen()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLen
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLen()
-
-Function verify_testLen() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,41 +17,20 @@ Function verify_testLen() As String
date2 = 8
date1 = Len("sometext")
- TestLog_ASSERT date1 = date2, "the return Len is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1)
date2 = 9
date1 = Len("some text")
- TestLog_ASSERT date1 = date2, "the return Len is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1)
date2 = 0
date1 = Len("")
- TestLog_ASSERT date1 = date2, "the return Len is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Len is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLen = 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/log.vb b/basic/qa/vba_tests/log.vb
index 08656bdf59c1..2f9fc5f871aa 100644
--- a/basic/qa/vba_tests/log.vb
+++ b/basic/qa/vba_tests/log.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_testLog()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLog
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLog()
-
-Function verify_testLog() 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_testLog() As String
date2 = 4.454
date1 = Log(86)
- TestLog_ASSERT Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1)
date2 = 4
date1 = Exp(Log(4))
- TestLog_ASSERT date1 = date2, "the return Log is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Log is: " & date1)
date2 = 1
date1 = Log(2.7182818)
- TestLog_ASSERT Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 3) = Round(date2, 3), "the return Log is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLog = 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/ltrim.vb b/basic/qa/vba_tests/ltrim.vb
index d85d02a76966..7e2b27e34de2 100644
--- a/basic/qa/vba_tests/ltrim.vb
+++ b/basic/qa/vba_tests/ltrim.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_testLTrim()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testLTrim
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testLTrim()
-
-Function verify_testLTrim() 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_testLTrim() As String
date2 = "some text "
date1 = LTrim(" some text ")
- TestLog_ASSERT date1 = date2, "the return LTrim is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return LTrim is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testLTrim = 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/mid.vb b/basic/qa/vba_tests/mid.vb
index b7070b33b86d..32b71b8f7d93 100644
--- a/basic/qa/vba_tests/mid.vb
+++ b/basic/qa/vba_tests/mid.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_testMid()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testMid
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testMid()
-
-Function verify_testMid() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,41 +17,20 @@ Function verify_testMid() As String
date2 = "Mid"
date1 = Mid("Mid Function Demo", 1, 3)
- TestLog_ASSERT date1 = date2, "the return Mid is: " & date1
+ TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1)
date2 = "Demo"
date1 = Mid("Mid Function Demo", 14, 4)
- TestLog_ASSERT date1 = date2, "the return Mid is: " & date1
+ TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1)
date2 = "Function Demo"
date1 = Mid("Mid Function Demo", 5)
- TestLog_ASSERT date1 = date2, "the return Mid is: " & date1
+ TestUtilModule.AssertEqual(date1, date2, "the return Mid is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testMid = 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/minute.vb b/basic/qa/vba_tests/minute.vb
index 20761b1e70cd..00ea54f5ac15 100644
--- a/basic/qa/vba_tests/minute.vb
+++ b/basic/qa/vba_tests/minute.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_testMinute()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testMinute
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testMinute()
-
-Function verify_testMinute() 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_testMinute() As String
date2 = 34
date1 = Minute("09:34:20")
- TestLog_ASSERT date1 = date2, "the return Minute is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Minute is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testMinute = 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/month.vb b/basic/qa/vba_tests/month.vb
index 98d614a571b2..faa074560b3d 100644
--- a/basic/qa/vba_tests/month.vb
+++ b/basic/qa/vba_tests/month.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_testMonth()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testMonth
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testMonth()
-
-Function verify_testMonth() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -31,49 +19,28 @@ Function verify_testMonth() As String
date2 = 4
date1 = Month(ldate)
- TestLog_ASSERT date1 = date2, "the return Month is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1)
date2 = 2
date1 = Month("01/02/2007")
- TestLog_ASSERT date1 = date2, "the return Month is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1)
date2 = 12
date1 = Month(1)
- TestLog_ASSERT date1 = date2, "the return Month is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1)
date2 = 2
date1 = Month(60)
- TestLog_ASSERT date1 = date2, "the return Month is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1)
date2 = 6
date1 = Month(2000)
- TestLog_ASSERT date1 = date2, "the return Month is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Month is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testMonth = 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/monthname.vb b/basic/qa/vba_tests/monthname.vb
index 627f9095b036..f173153c1c2b 100644
--- a/basic/qa/vba_tests/monthname.vb
+++ b/basic/qa/vba_tests/monthname.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_testMonthName()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testMonthName
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testMonthName()
-
-Function verify_testMonthName() 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_testMonthName() As String
date2 = "February"
date1 = MonthName(2)
- TestLog_ASSERT date1 = date2, "the return MonthName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1)
date2 = "Feb"
date1 = MonthName(2, True)
- TestLog_ASSERT date1 = date2, "the return MonthName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1)
date2 = "February"
date1 = MonthName(2, False)
- TestLog_ASSERT date1 = date2, "the return MonthName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return MonthName is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testMonthName = 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/oct.vb b/basic/qa/vba_tests/oct.vb
index 52feef2c8146..8d08934b1942 100644
--- a/basic/qa/vba_tests/oct.vb
+++ b/basic/qa/vba_tests/oct.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_testOct()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testOct
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testOct()
-
-Function verify_testOct() 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_testOct() As String
date2 = 4
date1 = Oct(4)
- TestLog_ASSERT date1 = date2, "the return Oct is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1)
date2 = 10
date1 = Oct(8)
- TestLog_ASSERT date1 = date2, "the return Oct is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1)
date2 = 713
date1 = Oct(459)
- TestLog_ASSERT date1 = date2, "the return Oct is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Oct is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testOct = 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/optional_paramters.vb b/basic/qa/vba_tests/optional_paramters.vb
index 2f527e5d72a7..8fc647aa516d 100644
--- a/basic/qa/vba_tests/optional_paramters.vb
+++ b/basic/qa/vba_tests/optional_paramters.vb
@@ -1,16 +1,8 @@
Option VBASupport 1
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Function doUnitTest() As String
- result = verify_testOptionalsVba()
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ verify_testOptionalsVba
+ doUnitTest = TestUtilModule.GetResult()
End Function
' tdf#36737 - Test optionals with different datatypes. In LO Basic
@@ -18,62 +10,59 @@ End Function
' default values. Missing optional parameters having types other than variant,
' which don't have explicit default values, will be initialized to their
' respective default value of its datatype
-Function verify_testOptionalsVba() As String
-
- passCount = 0
- failCount = 0
+Sub verify_testOptionalsVba()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
testName = "Test optionals (VBA)"
On Error GoTo errorHandler
' optionals with variant datatypes
- TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()"
- TestLog_ASSERT TestOptVariant(123), 246, "TestOptVariant(123)"
- TestLog_ASSERT TestOptVariant(, 456), 456, "TestOptVariant(, 456)"
- TestLog_ASSERT TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)"
+ TestUtilModule.AssertEqual(TestOptVariant(), 123, "TestOptVariant()")
+ TestUtilModule.AssertEqual(TestOptVariant(123), 246, "TestOptVariant(123)")
+ TestUtilModule.AssertEqual(TestOptVariant(, 456), 456, "TestOptVariant(, 456)")
+ TestUtilModule.AssertEqual(TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)")
' optionals with variant datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()"
- TestLog_ASSERT TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)"
- TestLog_ASSERT TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)"
- TestLog_ASSERT TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)"
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)")
+ TestUtilModule.AssertEqual(TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)")
' optionals with double datatypes
- TestLog_ASSERT TestOptDouble(), 123.4, "TestOptDouble()"
- TestLog_ASSERT TestOptDouble(123.4), 246.8, "TestOptDouble(123.4)"
- TestLog_ASSERT TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)"
- TestLog_ASSERT Format(TestOptDouble(123.4, 567.8), "0.0"), 691.2, "TestOptDouble(123.4, 567.8)"
+ TestUtilModule.AssertEqual(TestOptDouble(), 123.4, "TestOptDouble()")
+ TestUtilModule.AssertEqual(TestOptDouble(123.4), 246.8, "TestOptDouble(123.4)")
+ TestUtilModule.AssertEqual(TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)")
+ TestUtilModule.AssertEqual(Format(TestOptDouble(123.4, 567.8), "0.0"), 691.2, "TestOptDouble(123.4, 567.8)")
' optionals with double datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptDoubleByRefByVal(), 123.4, "TestOptDouble()"
- TestLog_ASSERT TestOptDoubleByRefByVal(123.4), 246.8, "TestOptDouble(123.4)"
- TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)"
- TestLog_ASSERT Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0"), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)"
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(), 123.4, "TestOptDouble()")
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(123.4), 246.8, "TestOptDouble(123.4)")
+ TestUtilModule.AssertEqual(TestOptDoubleByRefByVal(, 567.8), 567.8, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtilModule.AssertEqual(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0"), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)")
' optionals with integer datatypes
- TestLog_ASSERT TestOptInteger(), 123, "TestOptInteger()"
- TestLog_ASSERT TestOptInteger(123), 246, "TestOptInteger(123)"
- TestLog_ASSERT TestOptInteger(, 456), 456, "TestOptInteger(, 456)"
- TestLog_ASSERT TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)"
+ TestUtilModule.AssertEqual(TestOptInteger(), 123, "TestOptInteger()")
+ TestUtilModule.AssertEqual(TestOptInteger(123), 246, "TestOptInteger(123)")
+ TestUtilModule.AssertEqual(TestOptInteger(, 456), 456, "TestOptInteger(, 456)")
+ TestUtilModule.AssertEqual(TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)")
' optionals with integer datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()"
- TestLog_ASSERT TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)"
- TestLog_ASSERT TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)"
- TestLog_ASSERT TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)"
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)")
+ TestUtilModule.AssertEqual(TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)")
' optionals with string datatypes
- TestLog_ASSERT TestOptString(), "123", "TestOptString()"
- TestLog_ASSERT TestOptString("123"), "123123", "TestOptString(""123"")"
- TestLog_ASSERT TestOptString(, "456"), "456", "TestOptString(, ""456"")"
- TestLog_ASSERT TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")"
+ TestUtilModule.AssertEqual(TestOptString(), "123", "TestOptString()")
+ TestUtilModule.AssertEqual(TestOptString("123"), "123123", "TestOptString(""123"")")
+ TestUtilModule.AssertEqual(TestOptString(, "456"), "456", "TestOptString(, ""456"")")
+ TestUtilModule.AssertEqual(TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")")
' optionals with string datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()"
- TestLog_ASSERT TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")"
- TestLog_ASSERT TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")"
- TestLog_ASSERT TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")"
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")")
+ TestUtilModule.AssertEqual(TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")")
' optionals with object datatypes
Dim cA As New Collection
@@ -82,16 +71,16 @@ Function verify_testOptionalsVba() As String
Dim cB As New Collection
cB.Add (123.4)
cB.Add (567.8)
- TestLog_ASSERT TestOptObject(), 0, "TestOptObject()"
- TestLog_ASSERT TestOptObject(cA), 579, "TestOptObject(A)"
- TestLog_ASSERT Format(TestOptObject(, cB), "0.0"), 691.2, "TestOptObject(, B)"
- TestLog_ASSERT Format(TestOptObject(cA, cB), "0.0"), 1270.2, "TestOptObject(A, B)"
+ TestUtilModule.AssertEqual(TestOptObject(), 0, "TestOptObject()")
+ TestUtilModule.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)")
+ TestUtilModule.AssertEqual(Format(TestOptObject(, cB), "0.0"), 691.2, "TestOptObject(, B)")
+ TestUtilModule.AssertEqual(Format(TestOptObject(cA, cB), "0.0"), 1270.2, "TestOptObject(A, B)")
' optionals with object datatypes (ByRef and ByVal)
- TestLog_ASSERT TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()"
- TestLog_ASSERT TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)"
- TestLog_ASSERT Format(TestOptObjectByRefByVal(, cB), "0.0"), 691.2, "TestOptObjectByRefByVal(, B)"
- TestLog_ASSERT Format(TestOptObjectByRefByVal(cA, cB), "0.0"), 1270.2, "TestOptObjectByRefByVal(A, B)"
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()")
+ TestUtilModule.AssertEqual(TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)")
+ TestUtilModule.AssertEqual(Format(TestOptObjectByRefByVal(, cB), "0.0"), 691.2, "TestOptObjectByRefByVal(, B)")
+ TestUtilModule.AssertEqual(Format(TestOptObjectByRefByVal(cA, cB), "0.0"), 1270.2, "TestOptObjectByRefByVal(A, B)")
' optionals with array datatypes
Dim aA(0 To 1) As Integer
@@ -101,25 +90,24 @@ Function verify_testOptionalsVba() As String
aB(0) = 123.4
aB(1) = 567.8
' TODO - New bug report? Scanner initializes variable not as an array
- ' TestLog_ASSERT TestOptArray(), 0, "TestOptArray()"
- ' TestLog_ASSERT TestOptArray(aA), 579, "TestOptArray(A)"
- ' TestLog_ASSERT Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)"
- TestLog_ASSERT Format(TestOptArray(aA, aB), "0.0"), 1270.2, "TestOptArray(A, B)"
+ ' TestUtilModule.AssertEqual(TestOptArray(), 0, "TestOptArray()")
+ ' TestUtilModule.AssertEqual(TestOptArray(aA), 579, "TestOptArray(A)")
+ ' TestUtilModule.AssertEqual(Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)")
+ TestUtilModule.AssertEqual(Format(TestOptArray(aA, aB), "0.0"), 1270.2, "TestOptArray(A, B)")
' optionals with array datatypes (ByRef and ByVal)
' TODO - New bug report? Scanner initializes variable not as an array
- ' TestLog_ASSERT TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()"
- ' TestLog_ASSERT TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)"
- ' TestLog_ASSERT Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)"
- TestLog_ASSERT Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)"
+ ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()")
+ ' TestUtilModule.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)")
+ ' TestUtilModule.AssertEqual(Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)")
+ TestUtilModule.AssertEqual(Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)")
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testOptionalsVba = result
+ TestUtilModule.TestEnd
- Exit Function
+ Exit Sub
errorHandler:
- TestLog_ASSERT False, True, Err.Description
-End Function
+ TestUtilModule.AssertEqual(False, True, Err.Description)
+End Sub
Function TestOptVariant(Optional A, Optional B As Variant = 123)
TestOptVariant = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
@@ -205,11 +193,3 @@ Function ArraySum(is_missingC As Boolean, C)
End If
End Function
-Sub TestLog_ASSERT(actual As Variant, expected As Variant, testName As String)
- If expected = actual Then
- passCount = passCount + 1
- Else
- result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
- failCount = failCount + 1
- End If
-End Sub \ No newline at end of file
diff --git a/basic/qa/vba_tests/partition.vb b/basic/qa/vba_tests/partition.vb
index e4c2bda6743e..a917f4dd64e2 100644
--- a/basic/qa/vba_tests/partition.vb
+++ b/basic/qa/vba_tests/partition.vb
@@ -1,24 +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_testPartition()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testPartition
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testPartition() as String
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+Sub verify_testPartition()
+ TestUtilModule.TestInit
Dim testName As String
Dim retStr As String
@@ -27,45 +17,26 @@ Function verify_testPartition() as String
retStr = Partition(20, 0, 98, 5)
'MsgBox retStr
- TestLog_ASSERT retStr = "20:24", "the number 20 occurs in the range:" & retStr
+ TestUtilModule.AssertTrue(retStr = "20:24", "the number 20 occurs in the range:" & retStr)
retStr = Partition(20, 0, 99, 1)
'MsgBox retStr
- TestLog_ASSERT retStr = " 20: 20", "the number 20 occurs in the range:" & retStr
+ TestUtilModule.AssertTrue(retStr = " 20: 20", "the number 20 occurs in the range:" & retStr)
retStr = Partition(120, 0, 99, 5)
'MsgBox retStr
- TestLog_ASSERT retStr = "100: ", "the number 120 occurs in the range:" & retStr
+ TestUtilModule.AssertTrue(retStr = "100: ", "the number 120 occurs in the range:" & retStr)
retStr = Partition(-5, 0, 99, 5)
'MsgBox retStr
- TestLog_ASSERT retStr = " : -1", "the number -5 occurs in the range:" & retStr
+ TestUtilModule.AssertTrue(retStr = " : -1", "the number -5 occurs in the range:" & retStr)
retStr = Partition(2, 0, 5, 2)
'MsgBox retStr
- TestLog_ASSERT retStr = " 2: 3", "the number 2 occurs in the range:" & retStr
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testPartition = result
- Exit Function
+ TestUtilModule.AssertTrue(retStr = " 2: 3", "the number 2 occurs in the range:" & retStr)
+ TestUtilModule.TestEnd
+ Exit Sub
errorHandler:
- TestLog_ASSERT (false), "verify_testPartition failed, 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, "verify_testPartition failed, hit error handler")
End Sub
+
diff --git a/basic/qa/vba_tests/qbcolor.vb b/basic/qa/vba_tests/qbcolor.vb
index d9f617219b26..92cea22d9b7f 100644
--- a/basic/qa/vba_tests/qbcolor.vb
+++ b/basic/qa/vba_tests/qbcolor.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_testQBcolor()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testQBcolor
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testQBcolor()
-
-Function verify_testQBcolor() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2 As Long
@@ -29,64 +17,44 @@ Function verify_testQBcolor() As String
date2 = 0
date1 = QBColor(0)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 8388608
date1 = QBColor(1)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 32768
date1 = QBColor(2)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 8421376
date1 = QBColor(3)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 128
date1 = QBColor(4)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 8388736
date1 = QBColor(5)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 32896
date1 = QBColor(6)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 12632256
date1 = QBColor(7)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
date2 = 8421504
date1 = QBColor(8)
- TestLog_ASSERT date1 = date2, "the return QBcolor is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return QBcolor is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testQBcolor = 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/rate.vb b/basic/qa/vba_tests/rate.vb
index 898705911b32..86da7e08a1d3 100644
--- a/basic/qa/vba_tests/rate.vb
+++ b/basic/qa/vba_tests/rate.vb
@@ -1,27 +1,15 @@
Option VBASupport 1
Rem Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testRATE()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testRATE
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testRATE()
-
-Function verify_testRATE() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestDateTime As Date
@@ -32,53 +20,32 @@ Function verify_testRATE() As String
date2 = 0.07
date1 = Rate(3, -5, 0, 16)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
date2 = 0
date1 = Rate(3, -5, 0, 15)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
date2 = 0.79
date1 = Rate(3, -5, 0, 30)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
date2 = 1
date1 = Rate(3, -5, 0, 35)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
date2 = 0.077
date1 = Rate(4, -300, 1000, 0, 0)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
date2 = 0.14
date1 = Rate(4, -300, 1000, 0, 1)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testRATE = 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/replace.vb b/basic/qa/vba_tests/replace.vb
index 1349c10fae20..f6b2fed2394a 100644
--- a/basic/qa/vba_tests/replace.vb
+++ b/basic/qa/vba_tests/replace.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_testReplace()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testReplace
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testReplace() as String
- passCount = 0
- failCount = 0
+Sub verify_testReplace()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim srcStr, destStr, repStr, start, count, retStr
@@ -27,51 +18,32 @@ Function verify_testReplace() as String
destStr = "bc"
repStr = "ef"
retStr = Replace(srcStr, destStr, repStr)
- TestLog_ASSERT retStr = "aefefdBc", "common string:" & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdBc", "common string:" & retStr)
retStr = Replace("abcbcdbc", destStr, repStr)
- TestLog_ASSERT retStr = "aefefdef", "expression string:" & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdef", "expression string:" & retStr)
retStr = Replace(srcStr, destStr, repStr, 1, -1, vbBinaryCompare)
- TestLog_ASSERT retStr = "aefefdBc", "binary compare:" & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdBc", "binary compare:" & retStr)
retStr = Replace(srcStr, destStr, repStr, 1, -1, vbTextCompare)
- TestLog_ASSERT retStr = "aefefdef", "text compare:" & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdef", "text compare:" & retStr)
retStr = Replace(srcStr, destStr, repStr, compare:=vbTextCompare)
- TestLog_ASSERT retStr = "aefefdef", "text compare:" & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdef", "text compare:" & retStr)
retStr = Replace(srcStr, destStr, repStr, 3, -1, vbBinaryCompare)
- TestLog_ASSERT retStr = "cefdBc", "start = 3:" & retStr
+ TestUtilModule.AssertTrue(retStr = "cefdBc", "start = 3:" & retStr)
retStr = Replace(srcStr, destStr, repStr, 1, 2, vbBinaryCompare)
- TestLog_ASSERT retStr = "aefefdBc", "count = 2: " & retStr
+ TestUtilModule.AssertTrue(retStr = "aefefdBc", "count = 2: " & retStr)
retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare)
- TestLog_ASSERT retStr = "abcbcdBc", "start = 1, count = 0, not support in Unix: " & retStr
+ TestUtilModule.AssertTrue(retStr = "abcbcdBc", "start = 1, count = 0, not support in Unix: " & retStr)
' tdf#132389 - case-insensitive operation for non-ASCII characters
retStr = Replace("ABCabc", "b", "*", 1, 2, vbTextCompare)
- TestLog_ASSERT retStr = "A*Ca*c", "case-insensitive ASCII: " & retStr
+ TestUtilModule.AssertTrue(retStr = "A*Ca*c", "case-insensitive ASCII: " & retStr)
retStr = Replace("АБВабв", "б", "*", 1, 2, vbTextCompare)
- TestLog_ASSERT retStr = "А*Ва*в", "case-insensitive non-ASCII: " & retStr
+ TestUtilModule.AssertTrue(retStr = "А*Ва*в", "case-insensitive non-ASCII: " & retStr)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testReplace = 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/rgb.vb b/basic/qa/vba_tests/rgb.vb
index b36f3e099c9f..5ec9d590d123 100644
--- a/basic/qa/vba_tests/rgb.vb
+++ b/basic/qa/vba_tests/rgb.vb
@@ -1,27 +1,15 @@
Option VBASupport 1
Rem Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_testRGB()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testRGB
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testRGB()
-
-Function verify_testRGB() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestDateTime As Date
@@ -32,41 +20,20 @@ Function verify_testRGB() As String
date2 = 255
date1 = RGB(255, 0, 0)
- TestLog_ASSERT date1 = date2, "the return RGB is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1)
date2 = 13339467
date1 = RGB(75, 139, 203)
- TestLog_ASSERT date1 = date2, "the return RGB is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1)
date2 = 16777215
date1 = RGB(255, 255, 255)
- TestLog_ASSERT date1 = date2, "the return RGB is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return RGB is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testRGB = 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/right.vb b/basic/qa/vba_tests/right.vb
index 0e09bc11cca3..79bcaa2d4015 100644
--- a/basic/qa/vba_tests/right.vb
+++ b/basic/qa/vba_tests/right.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_testRight()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testRight
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testRight()
-
-Function verify_testRight() 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_testRight() As String
date2 = "text"
date1 = Right("sometext", 4)
- TestLog_ASSERT date1 = date2, "the return Right is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1)
date2 = "sometext"
date1 = Right("sometext", 48)
- TestLog_ASSERT date1 = date2, "the return Right is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1)
date2 = ""
date1 = Right("", 4)
- TestLog_ASSERT date1 = date2, "the return Right is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Right is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testRight = 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/rtrim.vb b/basic/qa/vba_tests/rtrim.vb
index d99cfd85f2d1..38185b4cb46e 100644
--- a/basic/qa/vba_tests/rtrim.vb
+++ b/basic/qa/vba_tests/rtrim.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_testRTrim()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testRTrim
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testRTrim()
-
-Function verify_testRTrim() 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_testRTrim() As String
date2 = " some text"
date1 = RTrim(" some text ")
- TestLog_ASSERT date1 = date2, "the return RTrim is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return RTrim is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testRTrim = 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/second.vb b/basic/qa/vba_tests/second.vb
index 4d84b4f737a6..ab7025a41f23 100644
--- a/basic/qa/vba_tests/second.vb
+++ b/basic/qa/vba_tests/second.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_testSecond()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSecond
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSecond()
-
-Function verify_testSecond() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,36 +17,16 @@ Function verify_testSecond() As String
date2 = 0
date1 = Second(37566.3)
- TestLog_ASSERT date1 = date2, "the return Second is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Second is: " & date1)
date2 = 17
date1 = Second("4:35:17")
- TestLog_ASSERT date1 = date2, "the return Second is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Second is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSecond = 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/sgn.vb b/basic/qa/vba_tests/sgn.vb
index e72215679e6d..e15962d502fe 100644
--- a/basic/qa/vba_tests/sgn.vb
+++ b/basic/qa/vba_tests/sgn.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_SGN()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_SGN
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_SGN()
-
-Function verify_SGN() 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,28 @@ Function verify_SGN() As String
date2 = 0
date1 = sgn(0)
- TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1)
date2 = -1
date1 = sgn(-1)
- TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1)
date2 = 1
date1 = sgn(1)
- TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1)
date2 = 1
date1 = sgn(50)
- TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1)
date2 = -1
date1 = sgn(-50)
- TestLog_ASSERT date1 = date2, "the return SGN is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SGN is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_SGN = 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/sin.vb b/basic/qa/vba_tests/sin.vb
index af2e73bd98c2..48bf6058e992 100644
--- a/basic/qa/vba_tests/sin.vb
+++ b/basic/qa/vba_tests/sin.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_testSIN()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSIN
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSIN()
-
-Function verify_testSIN() 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_testSIN() As String
date2 = 0.43
date1 = Sin(0.45)
- TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return SIN is: " & date1
+ TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return SIN is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSIN = 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/space.vb b/basic/qa/vba_tests/space.vb
index efcc9c992b65..9a655ee2afe5 100644
--- a/basic/qa/vba_tests/space.vb
+++ b/basic/qa/vba_tests/space.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_testSpace()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSpace
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSpace()
-
-Function verify_testSpace() 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_testSpace() As String
date2 = " "
date1 = Space(2)
- TestLog_ASSERT date1 = date2, "the return Space is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Space is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSpace = 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/sqr.vb b/basic/qa/vba_tests/sqr.vb
index 75a4ae7c1a4c..9ab8aa3bc329 100644
--- a/basic/qa/vba_tests/sqr.vb
+++ b/basic/qa/vba_tests/sqr.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_testSQR()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSQR
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSQR()
-
-Function verify_testSQR() 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_testSQR() As String
date2 = 3
date1 = Sqr(9)
- TestLog_ASSERT date1 = date2, "the return SQR is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return SQR is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSQR = 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/str.vb b/basic/qa/vba_tests/str.vb
index e46371ed5812..0cd013606730 100644
--- a/basic/qa/vba_tests/str.vb
+++ b/basic/qa/vba_tests/str.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_testSTR()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSTR
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSTR()
-
-Function verify_testSTR() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,45 +17,24 @@ Function verify_testSTR() As String
date2 = " 459"
date1 = Str(459)
- TestLog_ASSERT date1 = date2, "the return STR is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1)
date2 = "-459.65"
date1 = Str(-459.65)
- TestLog_ASSERT date1 = date2, "the return STR is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1)
date2 = " 459.001"
date1 = Str(459.001)
- TestLog_ASSERT date1 = date2, "the return STR is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1)
date2 = " .24"
date1 = Str(0.24)
- TestLog_ASSERT date1 = date2, "the return STR is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STR is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSTR = 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/strcomp.vb b/basic/qa/vba_tests/strcomp.vb
index 48735835808c..e6c2d32308af 100644
--- a/basic/qa/vba_tests/strcomp.vb
+++ b/basic/qa/vba_tests/strcomp.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_testSTRcomp()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSTRcomp
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSTRcomp()
-
-Function verify_testSTRcomp() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestStr, TestStr1, TestStr2 As String
@@ -32,64 +20,44 @@ Function verify_testSTRcomp() As String
date2 = 0
date1 = StrComp(TestStr1, TestStr2, vbTextCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = -1
date1 = StrComp(TestStr1, TestStr2, vbBinaryCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = -1
date1 = StrComp(TestStr1, TestStr2)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = 0
date1 = StrComp("text", "text", vbBinaryCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = 1
date1 = StrComp("text ", "text", vbBinaryCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = -1
date1 = StrComp("Text", "text", vbBinaryCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = 0
date1 = StrComp("text", "text", vbTextCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = 1
date1 = StrComp("text ", "text", vbTextCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
date2 = 0
date1 = StrComp("Text", "text", vbTextCompare)
- TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return STRcomp is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSTRcomp = 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/strconv.vb b/basic/qa/vba_tests/strconv.vb
index 35a73af17d69..0a9e5628a966 100644
--- a/basic/qa/vba_tests/strconv.vb
+++ b/basic/qa/vba_tests/strconv.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_testStrConv()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testStrConv
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testStrConv() as String
- passCount = 0
- failCount = 0
+Sub verify_testStrConv()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim srcStr, retStr As String
@@ -28,63 +19,44 @@ Function verify_testStrConv() as String
retStr = StrConv(srcStr, vbUpperCase)
'MsgBox retStr
- TestLog_ASSERT retStr = "ABC EFG HIJ", "Converts the string to uppercase characters:" & retStr
+ TestUtilModule.AssertTrue(retStr = "ABC EFG HIJ", "Converts the string to uppercase characters:" & retStr)
retStr = StrConv(srcStr, vbLowerCase)
'MsgBox retStr
- TestLog_ASSERT retStr = "abc efg hij", "Converts the string to lowercase characters:" & retStr
+ TestUtilModule.AssertTrue(retStr = "abc efg hij", "Converts the string to lowercase characters:" & retStr)
retStr = StrConv(srcStr, vbProperCase)
'MsgBox retStr
- TestLog_ASSERT retStr = "Abc Efg Hij", "Converts the first letter of every word in string to uppercase:" & retStr
+ TestUtilModule.AssertTrue(retStr = "Abc Efg Hij", "Converts the first letter of every word in string to uppercase:" & retStr)
'retStr = StrConv("ABCDEVB¥ì¥¹¥­¥å©`", vbWide)
'MsgBox retStr
- 'TestLog_ASSERT retStr = "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", "Converts narrow (single-byte) characters in string to wide"
+ 'TestUtilModule.AssertTrue(retStr = "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", "Converts narrow (single-byte) characters in string to wide")
'retStr = StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", vbNarrow)
'MsgBox retStr
- 'TestLog_ASSERT retStr = "ABCDEVB¥ì¥¹¥­¥å©`", "Converts wide (double-byte) characters in string to narrow (single-byte) characters." & retStr
+ 'TestUtilModule.AssertTrue(retStr = "ABCDEVB¥ì¥¹¥­¥å©`", "Converts wide (double-byte) characters in string to narrow (single-byte) characters." & retStr)
'retStr = StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana)
'MsgBox retStr
- 'TestLog_ASSERT retStr = "¥Ï¥Ê¥Á¥ã¥ó", "Converts Hiragana characters in string to Katakana characters.." & retStr
+ 'TestUtilModule.AssertTrue(retStr = "¥Ï¥Ê¥Á¥ã¥ó", "Converts Hiragana characters in string to Katakana characters.." & retStr)
' retStr = StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana)
'MsgBox retStr
- ' TestLog_ASSERT retStr = "¤Ï¤Ê¤Á¤ã¤ó", "Converts Katakana characters in string to Hiragana characters.." & retStr
+ ' TestUtilModule.AssertTrue(retStr = "¤Ï¤Ê¤Á¤ã¤ó", "Converts Katakana characters in string to Hiragana characters.." & retStr)
'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
'MsgBox retStr
- 'TestLog_ASSERT UBound(x) = 8, "Converts the string from Unicode, the length is : " & UBound(x) + 1
+ 'TestUtilModule.AssertTrue(UBound(x) = 8, "Converts the string from Unicode, the length is : " & UBound(x) + 1)
' retStr = StrConv(x, vbUnicode)
'MsgBox retStr
- ' TestLog_ASSERT retStr = "ÉϺ£ÊÐABC", "Converts the string to Unicode: " & retStr
+ ' TestUtilModule.AssertTrue(retStr = "ÉϺ£ÊÐABC", "Converts the string to Unicode: " & retStr)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testStrConv = 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/string.vb b/basic/qa/vba_tests/string.vb
index 79496738c56c..f6e9d5376011 100644
--- a/basic/qa/vba_tests/string.vb
+++ b/basic/qa/vba_tests/string.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_testString()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testString
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testString()
-
-Function verify_testString() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestStr As String
@@ -30,40 +18,20 @@ Function verify_testString() As String
date2 = "PPPPP"
date1 = String(5, "P")
- TestLog_ASSERT date1 = date2, "the return String is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1)
date2 = "aaaaa"
date1 = String(5, "a")
- TestLog_ASSERT date1 = date2, "the return String is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1)
date2 = ""
date1 = String(0, "P")
- TestLog_ASSERT date1 = date2, "the return String is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return String is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testString = 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/stringplusdouble.vb b/basic/qa/vba_tests/stringplusdouble.vb
index 7d416709a4c0..bee43d1c5fc1 100644
--- a/basic/qa/vba_tests/stringplusdouble.vb
+++ b/basic/qa/vba_tests/stringplusdouble.vb
@@ -1,30 +1,20 @@
Option VBASupport 1
Option Explicit
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
Function doUnitTest() As String
-result = verify_stringplusdouble()
-If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_stringplusdouble
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_stringplusdouble() as String
- passCount = 0
- failCount = 0
+Sub verify_stringplusdouble()
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
DSD
SSD
DSS
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_stringplusdouble = result
-End Function
+ TestUtilModule.TestEnd
+End Sub
Sub DSD()
Dim testName As String
@@ -39,64 +29,63 @@ Sub DSD()
testCompute = "s = null, d = null, r = s + d"
r = s + d
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = null, d = null, r = s & d"
r = s & d
- TestLog_ASSERT r = 0, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 0, testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s + d"
d = 20
r = s + d
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s & d"
d = 20
r = s & d
- TestLog_ASSERT r = 20, testCompute & " .The result is: " & r
-
+ TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r)
''''''''''''''
s = "10"
Dim d2 As Double
testCompute = "s = '10', d = null, r = s + d"
r = s + d2
- TestLog_ASSERT r = 10, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = null, r = s & d"
r = s & d2
- TestLog_ASSERT r = 100, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 100, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s + d"
d2 = 20
r = s + d2
- TestLog_ASSERT r = 30, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 30, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s & d"
d2 = 20
r = s & d2
- TestLog_ASSERT r = 1020, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r)
''''''''''''''
s = "abc"
Dim d3 As Double
testCompute = "s = 'abc', d = null, r = s + d"
r = s + d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = null, r = s & d"
r = s & d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s + d"
d3 = 20
r = s + d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s & d"
d3 = 20
r = s & d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
Exit Sub
@@ -106,7 +95,6 @@ ErrorHandler:
Resume Next
End Sub
-
Sub SSD()
Dim testName As String
testName = "string = string + double"
@@ -120,64 +108,63 @@ Sub SSD()
testCompute = "s = null, d = null, r = s + d"
r = s + d
- TestLog_ASSERT r = "-1", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r)
testCompute = "s = null, d = null, r = s & d"
r = s & d
- TestLog_ASSERT r = "0", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "0", testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s + d"
d = 20
r = s + d
- TestLog_ASSERT r = "-1", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s & d"
d = 20
r = s & d
- TestLog_ASSERT r = "20", testCompute & " .The result is: " & r
-
+ TestUtilModule.AssertTrue(r = "20", testCompute & " .The result is: " & r)
''''''''''''''
s = "10"
Dim d2 As Double
testCompute = "s = '10', d = null, r = s + d"
r = s + d2
- TestLog_ASSERT r = "10", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "10", testCompute & " .The result is: " & r)
testCompute = "s = '10', d = null, r = s & d"
r = s & d2
- TestLog_ASSERT r = "100", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "100", testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s + d"
d2 = 20
r = s + d2
- TestLog_ASSERT r = "30", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "30", testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s & d"
d2 = 20
r = s & d2
- TestLog_ASSERT r = "1020", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "1020", testCompute & " .The result is: " & r)
''''''''''''''
s = "abc"
Dim d3 As Double
testCompute = "s = 'abc', d = null, r = s + d"
r = s + d3
- TestLog_ASSERT r = "-1", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = null, r = s & d"
r = s & d3
- TestLog_ASSERT r = "abc0", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "abc0", testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s + d"
d3 = 20
r = s + d3
- TestLog_ASSERT r = "-1", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "-1", testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s & d"
d3 = 20
r = s & d3
- TestLog_ASSERT r = "abc20", testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = "abc20", testCompute & " .The result is: " & r)
Exit Sub
ErrorHandler:
@@ -199,64 +186,63 @@ Sub DSS()
testCompute = "s = null, d = null, r = s + d"
r = s + d
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = null, d = null, r = s & d"
r = s & d
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s + d"
d = "20"
r = s + d
- TestLog_ASSERT r = 20, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r)
testCompute = "s = null, d = 20, r = s & d"
d = "20"
r = s & d
- TestLog_ASSERT r = 20, testCompute & " .The result is: " & r
-
+ TestUtilModule.AssertTrue(r = 20, testCompute & " .The result is: " & r)
''''''''''''''
s = "10"
Dim d2 As String
testCompute = "s = '10', d = null, r = s + d"
r = s + d2
- TestLog_ASSERT r = 10, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = null, r = s & d"
r = s & d2
- TestLog_ASSERT r = 10, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 10, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s + d"
d2 = "20"
r = s + d2
- TestLog_ASSERT r = 1020, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r)
testCompute = "s = '10', d = 20, r = s & d"
d2 = "20"
r = s & d2
- TestLog_ASSERT r = 1020, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = 1020, testCompute & " .The result is: " & r)
''''''''''''''
s = "abc"
Dim d3 As String
testCompute = "s = 'abc', d = null, r = s + d"
r = s + d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = null, r = s & d"
r = s & d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s + d"
d3 = "20"
r = s + d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
testCompute = "s = 'abc', d = 20, r = s & d"
d3 = "20"
r = s & d3
- TestLog_ASSERT r = -1, testCompute & " .The result is: " & r
+ TestUtilModule.AssertTrue(r = -1, testCompute & " .The result is: " & r)
Exit Sub
ErrorHandler:
@@ -265,8 +251,6 @@ ErrorHandler:
Resume Next
End Sub
-
-
Sub test2()
Dim s As String
Dim d As Double
@@ -308,21 +292,3 @@ Sub testCurrency()
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/strreverse.vb b/basic/qa/vba_tests/strreverse.vb
index e0866a008804..fb143facf9a9 100644
--- a/basic/qa/vba_tests/strreverse.vb
+++ b/basic/qa/vba_tests/strreverse.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_testStrReverse()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testStrReverse
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testStrReverse()
-
-Function verify_testStrReverse() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,44 +17,24 @@ Function verify_testStrReverse() As String
date2 = "dcba"
date1 = StrReverse("abcd")
- TestLog_ASSERT date1 = date2, "the return StrReverse is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1)
date2 = "BABABA"
date1 = StrReverse("ABABAB")
- TestLog_ASSERT date1 = date2, "the return StrReverse is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1)
date2 = "654321"
date1 = StrReverse("123456")
- TestLog_ASSERT date1 = date2, "the return StrReverse is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1)
date2 = "6"
date1 = StrReverse(6)
- TestLog_ASSERT date1 = date2, "the return StrReverse is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return StrReverse is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testStrReverse = 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/switch.vb b/basic/qa/vba_tests/switch.vb
index a6acea77d616..3add8cba7e52 100644
--- a/basic/qa/vba_tests/switch.vb
+++ b/basic/qa/vba_tests/switch.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_testSwitch()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testSwitch
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testSwitch()
-
-Function verify_testSwitch() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,39 +17,17 @@ Function verify_testSwitch() As String
date2 = "French"
date1 = MatchUp("Paris")
- TestLog_ASSERT date1 = date2, "the return Switch is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Switch is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testSwitch = 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 MatchUp(CityName As String)
MatchUp = Switch(CityName = "London", "English", CityName _
= "Rome", "Italian", CityName = "Paris", "French")
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/timeserial.vb b/basic/qa/vba_tests/timeserial.vb
index a663d516ccbe..d0dafad7a70d 100644
--- a/basic/qa/vba_tests/timeserial.vb
+++ b/basic/qa/vba_tests/timeserial.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_testTimeSerial()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testTimeSerial
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testTimeSerial()
-
-Function verify_testTimeSerial() 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,40 +18,20 @@ Function verify_testTimeSerial() As String
rem bug 114229
rem date2 = "5:45:00"
rem date1 = (TimeSerial(12 - 6, -15, 0))
-rem TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+rem TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1)
date2 = "12:30:00"
date1 = TimeSerial(12, 30, 0)
- TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1)
rem date2 = "11:30:00"
rem date1 = TimeSerial(10, 90, 0)
-rem TestLog_ASSERT date1 = date2, "the return TimeSerial is: " & date1
+rem TestUtilModule.AssertTrue(date1 = date2, "the return TimeSerial is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testTimeSerial = 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/timevalue.vb b/basic/qa/vba_tests/timevalue.vb
index a27feb35aca7..a44cdabd5c84 100644
--- a/basic/qa/vba_tests/timevalue.vb
+++ b/basic/qa/vba_tests/timevalue.vb
@@ -1,24 +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_testTimeValue()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testTimeValue
+doUnitTest = TestUtilModule.GetResult()
End Function
-Function verify_testTimeValue() As String
+Sub verify_testTimeValue()
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
@@ -28,32 +18,12 @@ Function verify_testTimeValue() As String
date2 = "16:35:17"
date1 = TimeValue("4:35:17 PM")
- TestLog_ASSERT date1 = date2, "the return TimeValue is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TimeValue is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testTimeValue = 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/trim.vb b/basic/qa/vba_tests/trim.vb
index c61845d5d94f..4c11ab8cd4b7 100644
--- a/basic/qa/vba_tests/trim.vb
+++ b/basic/qa/vba_tests/trim.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_testTrim()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testTrim
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testTrim()
-
-Function verify_testTrim() 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_testTrim() As String
date2 = "some text"
date1 = Trim(" some text ")
- TestLog_ASSERT date1 = date2, "the return Trim is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Trim is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testTrim = 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/typename.vb b/basic/qa/vba_tests/typename.vb
index 7e49a4d61cdc..117d432ec423 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.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_testTypeName()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testTypeName
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testTypeName()
-
-Function verify_testTypeName() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -35,62 +23,42 @@ Function verify_testTypeName() As String
date2 = "String"
date1 = TypeName(testName)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Boolean"
date1 = TypeName(b1)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Byte"
date1 = TypeName(c1)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Date"
date1 = TypeName(d1)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Double"
date1 = TypeName(d2)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Integer"
date1 = TypeName(i1)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
date2 = "Long"
date1 = TypeName(l1)
- TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return TypeName is: " & date1)
' tdf#129596 - Types of constant values
- TestLog_ASSERT TypeName(32767) = "Integer", "the return TypeName(32767) is: " & TypeName(32767)
- TestLog_ASSERT TypeName(-32767) = "Integer", "the return TypeName(-32767) is: " & TypeName(-32767)
- TestLog_ASSERT TypeName(1048575) = "Long", "the return TypeName(1048575) is: " & TypeName(1048575)
- TestLog_ASSERT TypeName(-1048575) = "Long", "the return TypeName(-1048575) is: " & TypeName(-1048575)
+ TestUtilModule.AssertTrue(TypeName(32767) = "Integer", "the return TypeName(32767) is: " & TypeName(32767))
+ TestUtilModule.AssertTrue(TypeName(-32767) = "Integer", "the return TypeName(-32767) is: " & TypeName(-32767))
+ TestUtilModule.AssertTrue(TypeName(1048575) = "Long", "the return TypeName(1048575) is: " & TypeName(1048575))
+ TestUtilModule.AssertTrue(TypeName(-1048575) = "Long", "the return TypeName(-1048575) is: " & TypeName(-1048575))
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testTypeName = 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/ubound.vb b/basic/qa/vba_tests/ubound.vb
index e52299fb4dd3..9eb954b04bf9 100644
--- a/basic/qa/vba_tests/ubound.vb
+++ b/basic/qa/vba_tests/ubound.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_testUBound()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testUBound
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testUBound()
-
-Function verify_testUBound() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -30,40 +18,20 @@ Function verify_testUBound() As String
date2 = 100
date1 = UBound(A, 1)
- TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1)
date2 = 3
date1 = UBound(A, 2)
- TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1)
date2 = 4
date1 = UBound(A, 3)
- TestLog_ASSERT date1 = date2, "the return UBound is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return UBound is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testUBound = 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/ucase.vb b/basic/qa/vba_tests/ucase.vb
index 369be4f8ebaa..f8376258393d 100644
--- a/basic/qa/vba_tests/ucase.vb
+++ b/basic/qa/vba_tests/ucase.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_testUCase()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testUCase
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testUCase()
-
-Function verify_testUCase() 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_testUCase() As String
date2 = "HELLO 12"
date1 = UCase("hello 12") '2/12/1969
- TestLog_ASSERT date1 = date2, "the return UCase is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return UCase is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testUCase = 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/val.vb b/basic/qa/vba_tests/val.vb
index 39796d7b4997..b50b93b3334c 100644
--- a/basic/qa/vba_tests/val.vb
+++ b/basic/qa/vba_tests/val.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_testVal()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testVal
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testVal()
-
-Function verify_testVal() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,64 +17,44 @@ Function verify_testVal() As String
date2 = 2
date1 = Val("02/04/2010")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 1050
date1 = Val("1050")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 130.75
date1 = Val("130.75")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 50
date1 = Val("50 Park Lane")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 1320
date1 = Val("1320 then some text")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 0
date1 = Val("L13.5")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
date2 = 0
date1 = Val("sometext")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
REM date2 = 1
REM date1 = Val("1, 2")
-REM TestLog_ASSERT date1 = date2, "the return Val is: " & date1
+REM TestUtilModule.AssertTrue(date1 = date2, "the return Val is: " & date1)
REM tdf#111999
date2 = -1
date1 = Val("&HFFFF")
- TestLog_ASSERT date1 = date2, "the return Val is: " & date1
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testVal = result
+ TestUtilModule.AssertTrue(date1 = date2, "the return Val 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/vartype.vb b/basic/qa/vba_tests/vartype.vb
index f500268ae663..b012be3374c0 100644
--- a/basic/qa/vba_tests/vartype.vb
+++ b/basic/qa/vba_tests/vartype.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_testVarType()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testVarType
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testVarType()
-
-Function verify_testVarType() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim TestDateTime As Date
@@ -35,52 +23,32 @@ Function verify_testVarType() As String
date2 = 8
date1 = VarType(testName)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
date2 = 11
date1 = VarType(TestBoo)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
date2 = 5
date1 = VarType(TestDouble)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
date2 = 3
date1 = VarType(TestLong)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
date2 = 2
date1 = VarType(TestInt)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
date2 = 7
date1 = VarType(TestDateTime)
- TestLog_ASSERT date1 = date2, "the return VarType is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return VarType is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testVarType = 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/weekday.vb b/basic/qa/vba_tests/weekday.vb
index a37f07d1fac4..55158d985e57 100644
--- a/basic/qa/vba_tests/weekday.vb
+++ b/basic/qa/vba_tests/weekday.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_testWeekDay()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testWeekDay
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testWeekDay()
-
-Function verify_testWeekDay() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,53 +17,32 @@ Function verify_testWeekDay() As String
date2 = 7
date1 = Weekday(#6/7/2009#, vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
date2 = 2
date1 = Weekday(#7/7/2009#, vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
date2 = 5
date1 = Weekday(#8/7/2009#, vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
date2 = 1
date1 = Weekday(#12/7/2009#, vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
date2 = 1
date1 = Weekday(#6/7/2009#, vbSunday)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
date2 = 5
date1 = Weekday(#6/7/2009#, 4)
- TestLog_ASSERT date1 = date2, "the return WeekDay is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDay is: " & date1)
+ TestUtilModule.TestEnd
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testWeekDay = 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/weekdayname.vb b/basic/qa/vba_tests/weekdayname.vb
index 6c8f0b57568c..6adb460c7631 100644
--- a/basic/qa/vba_tests/weekdayname.vb
+++ b/basic/qa/vba_tests/weekdayname.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_testWeekDayName()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testWeekDayName
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testWeekDayName()
-
-Function verify_testWeekDayName() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,56 +17,36 @@ Function verify_testWeekDayName() As String
date2 = "Sunday"
date1 = WeekdayName(1)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Sunday"
date1 = WeekdayName(1, , vbSunday)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Monday"
date1 = WeekdayName(1, , vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Monday"
date1 = WeekdayName(2)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Tue"
date1 = WeekdayName(2, True, vbMonday)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Wed"
date1 = WeekdayName(2, True, vbTuesday)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
date2 = "Thu"
date1 = WeekdayName(2, True, vbWednesday)
- TestLog_ASSERT date1 = date2, "the return WeekDayName is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return WeekDayName is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testWeekDayName = 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/win32compat.vb b/basic/qa/vba_tests/win32compat.vb
index 58a8e4e510c2..067c53e48674 100644
--- a/basic/qa/vba_tests/win32compat.vb
+++ b/basic/qa/vba_tests/win32compat.vb
@@ -8,36 +8,21 @@ Option Explicit
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at http://mozilla.org/MPL/2.0/.
'
-'
' Test built-in compatibility versions of methods whose absence
' is really felt in VBA, and large numbers of macros import from
' the system.
'
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Private Declare Function QueryPerformanceCounter Lib "kernel32" (ByRef lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (ByRef lpFrequency As Currency) As Long
-' FIXME: all this cut/paste should be factored out !
-
Function doUnitTest() As String
- result = verify_win32compat()
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ verify_win32compat
+ doUnitTest = TestUtilModule.GetResult()
End Function
-
-Function verify_win32compat() as String
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "================" & Chr$(10)
+Sub verify_win32compat()
+ TestUtilModule.TestInit()
Dim freq As Currency
Dim count_a As Currency
@@ -47,40 +32,18 @@ Function verify_win32compat() as String
On Error GoTo errorHandler
success = QueryPerformanceFrequency(freq)
- TestLog_ASSERT success <> 0, "fetching perf. frequency"
- TestLog_ASSERT freq > 0, "perf. frequency is incorrect " & freq
+ TestUtilModule.AssertTrue(success <> 0, "fetching perf. frequency")
+ TestUtilModule.AssertTrue(freq > 0, "perf. frequency is incorrect " & freq)
success = QueryPerformanceCounter(count_a)
- TestLog_ASSERT success <> 0, "fetching performance count"
+ TestUtilModule.AssertTrue(success <> 0, "fetching performance count")
success = QueryPerformanceCounter(count_b)
- TestLog_ASSERT success <> 0, "fetching performance count"
- TestLog_ASSERT count_a < count_b, "count mismatch " & count_a & " is > " & count_b
-
- verify_win32compat = "OK"
- Exit Function
+ TestUtilModule.AssertTrue(success <> 0, "fetching performance count")
+ TestUtilModule.AssertTrue(count_a < count_b, "count mismatch " & count_a & " is > " & count_b)
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")"
- verify_win32compat = result
-
-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, "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")")
End Sub
diff --git a/basic/qa/vba_tests/win32compatb.vb b/basic/qa/vba_tests/win32compatb.vb
index 56335c62fda7..b85f07808d80 100644
--- a/basic/qa/vba_tests/win32compatb.vb
+++ b/basic/qa/vba_tests/win32compatb.vb
@@ -8,7 +8,6 @@ Option Explicit
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at http://mozilla.org/MPL/2.0/.
'
-'
' Test built-in compatibility versions of methods whose absence
' is really felt in VBA, and large numbers of macros import from
' the system.
@@ -16,10 +15,6 @@ Option Explicit
' This module tests different signatures for the same methods.
'
-Dim passCount As Integer
-Dim failCount As Integer
-Dim result As String
-
Private Type LARGE_INTEGER
lowpart As Long
highpart As Long
@@ -28,15 +23,9 @@ End Type
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
-' FIXME: all this cut/paste should be factored out !
-
Function doUnitTest() As String
- result = verify_win32compat()
- If failCount <> 0 Or passCount = 0 Then
- doUnitTest = result
- Else
- doUnitTest = "OK"
- End If
+ verify_win32compat
+ doUnitTest = TestUtilModule.GetResult()
End Function
Function convertLarge(scratch As LARGE_INTEGER) As Double
@@ -47,11 +36,8 @@ Function convertLarge(scratch As LARGE_INTEGER) As Double
convertLarge = ret
End Function
-Function verify_win32compat() as String
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "================" & Chr$(10)
+Sub verify_win32compat()
+ TestUtilModule.TestInit
Dim scratch as LARGE_INTEGER
Dim freq As Double
@@ -62,43 +48,21 @@ Function verify_win32compat() as String
On Error GoTo errorHandler
success = QueryPerformanceFrequency(scratch)
- TestLog_ASSERT success <> 0, "fetching perf. frequency"
+ TestUtilModule.AssertTrue(success <> 0, "fetching perf. frequency")
freq = convertLarge(scratch)
- TestLog_ASSERT freq > 0, "perf. frequency is incorrect " & freq
+ TestUtilModule.AssertTrue(freq > 0, "perf. frequency is incorrect " & freq)
success = QueryPerformanceCounter(scratch)
- TestLog_ASSERT success <> 0, "fetching performance count"
+ TestUtilModule.AssertTrue(success <> 0, "fetching performance count")
count_a = convertLarge(scratch)
' success = QueryPerformanceCounter(scratch)
-' TestLog_ASSERT success <> 0, "fetching performance count"
+' TestUtilModule.AssertTrue(success <> 0, "fetching performance count")
' count_b = convertLarge(scratch)
-' TestLog_ASSERT count_a < count_b, "count mismatch " & count_a & " is > " & count_b
-
- verify_win32compat = "OK"
- Exit Function
+' TestUtilModule.AssertTrue(count_a < count_b, "count mismatch " & count_a & " is > " & count_b)
+ Exit Sub
errorHandler:
- TestLog_ASSERT (False), "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")"
- verify_win32compat = result
-
-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, "hit error handler - " & Err & ": " & Error$ & " (line : " & Erl & ")")
End Sub
diff --git a/basic/qa/vba_tests/year.vb b/basic/qa/vba_tests/year.vb
index 62d08234d6c4..15d4f2c25ff7 100644
--- a/basic/qa/vba_tests/year.vb
+++ b/basic/qa/vba_tests/year.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_testYear()
-If failCount <> 0 or passCount = 0 Then
- doUnitTest = result
-Else
- doUnitTest = "OK"
-End If
+verify_testYear
+doUnitTest = TestUtilModule.GetResult()
End Function
+Sub verify_testYear()
-
-Function verify_testYear() As String
-
- passCount = 0
- failCount = 0
-
- result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ TestUtilModule.TestInit
Dim testName As String
Dim date1, date2
@@ -29,36 +17,16 @@ Function verify_testYear() As String
date2 = 1969
date1 = Year("12/2/1969")
- TestLog_ASSERT date1 = date2, "the return Year is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Year is: " & date1)
date2 = 1900
date1 = Year(256)
- TestLog_ASSERT date1 = date2, "the return Year is: " & date1
+ TestUtilModule.AssertTrue(date1 = date2, "the return Year is: " & date1)
- result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
- verify_testYear = 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