summaryrefslogtreecommitdiff
path: root/basic/qa/cppunit
diff options
context:
space:
mode:
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