summaryrefslogtreecommitdiff
path: root/basic/qa/cppunit
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-06-19 23:10:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-06-20 12:46:27 +0200
commitf4ff0ed55707078868415541c4a1aebd3db1e142 (patch)
tree1739eb7d535dd1f3f30fb7313797556b0cbcb1c5 /basic/qa/cppunit
parent2c68c419c1fce6de1a81e1f13a84b7069125a204 (diff)
tdf#149622: also clear return value before calling method from SbxObject::Call
Moves the custom cleanup logic to overridden SbxMethod::Clear, to simplify the cleanup code and make sure it restores empty Variant correctly. Change-Id: I01fa0529acd9ac787ffcda60fd6836ade4afdcb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136108 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/qa/cppunit')
-rw-r--r--basic/qa/cppunit/_test_asserts.bas10
-rw-r--r--basic/qa/cppunit/_test_asserts.vb10
2 files changed, 16 insertions, 4 deletions
diff --git a/basic/qa/cppunit/_test_asserts.bas b/basic/qa/cppunit/_test_asserts.bas
index 51442a0590a6..68865755bdcd 100644
--- a/basic/qa/cppunit/_test_asserts.bas
+++ b/basic/qa/cppunit/_test_asserts.bas
@@ -34,8 +34,8 @@ Sub Assert(Assertion As Boolean, Optional testId As String, Optional testComment
If Not IsMissing(testId) Then
testMsg = " " + testId
End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
+ If Not IsMissing(testComment) Then
+ If Not (testComment = "") Then testMsg = testMsg + " (" + testComment + ")"
End If
result = result & Chr$(10) & " Failed:" & testMsg
@@ -52,6 +52,12 @@ Sub AssertEqual(actual As Variant, expected As Variant, testName As String)
End If
End Sub
+' Same as AssertEqual, but also checks actual and expected types
+Sub AssertEqualStrict(actual As Variant, expected As Variant, testName As String)
+ AssertEqual(actual, expected, testName)
+ AssertEqual(TypeName(actual), TypeName(expected), testName & " type mismatch:")
+End Sub
+
Sub AssertEqualApprox(actual, expected, epsilon, testName As String)
If Abs(expected - actual) <= epsilon Then
passCount = passCount + 1
diff --git a/basic/qa/cppunit/_test_asserts.vb b/basic/qa/cppunit/_test_asserts.vb
index 0f1d0d88610f..2130ce02f454 100644
--- a/basic/qa/cppunit/_test_asserts.vb
+++ b/basic/qa/cppunit/_test_asserts.vb
@@ -35,8 +35,8 @@ Sub Assert(Assertion As Boolean, Optional testId As String, Optional testComment
If Not IsMissing(testId) Then
testMsg = " " + testId
End If
- If Not IsMissing(testComment) And Not (testComment = "") Then
- testMsg = testMsg + " (" + testComment + ")"
+ If Not IsMissing(testComment) Then
+ If Not (testComment = "") Then testMsg = testMsg + " (" + testComment + ")"
End If
result = result & Chr$(10) & " Failed:" & testMsg
@@ -53,6 +53,12 @@ Sub AssertEqual(actual As Variant, expected As Variant, testName As String)
End If
End Sub
+' Same as AssertEqual, but also checks actual and expected types
+Sub AssertEqualStrict(actual As Variant, expected As Variant, testName As String)
+ AssertEqual actual, expected, testName
+ AssertEqual TypeName(actual), TypeName(expected), testName & " type mismatch:"
+End Sub
+
Sub AssertEqualApprox(actual, expected, epsilon, testName As String)
If Abs(expected - actual) <= epsilon Then
passCount = passCount + 1