summaryrefslogtreecommitdiff
path: root/basic/qa
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2022-10-13 14:20:00 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2022-10-14 10:06:38 +0200
commitbdfcad586d7b1d4d26bcba50058af7fcb279558d (patch)
tree62899efebf547b490f41c50742355075a8d239e8 /basic/qa
parentaa451a4230778f9d4e6a931f51a60dba5f7a116a (diff)
tdf#151503 - Do not evaluate a missing optional variable to a boolean
Change-Id: I671f857344f91de63612eabcbbdb2cab9b94cc0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141296 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'basic/qa')
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_basic.bas15
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_compatible.bas15
2 files changed, 30 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.bas b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
index a684fc256054..40475664fb7a 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_basic.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
@@ -125,6 +125,12 @@ Sub verify_testOptionalsBasic()
' - Actual : 448 (Actual value of the variable)
TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
+ ' tdf#151503 - error handling of missing optional parameters (boolean operations)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 0 (No error code since a missing parameter evaluates to true)
+ TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
+
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testOptionalsBasic", Err, Error$, Erl)
@@ -229,6 +235,15 @@ errorHandler:
TestObjectError = Err()
End Function
+Function TestBooleanOperations(Optional optBool As Boolean)
+On Error GoTo errorHandler
+ if optBool then
+ TestBooleanOperations = 0
+ end if
+errorHandler:
+ TestBooleanOperations = Err()
+End Function
+
Function CollectionSum(C)
Dim idx As Integer
CollectionSum = 0
diff --git a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
index 56b314288e7a..fc3ca385951c 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
@@ -127,6 +127,12 @@ Sub verify_testOptionalsCompatible()
' - Actual : 448 (Actual value of the variable)
TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
+ ' tdf#151503 - error handling of missing optional parameters (boolean operations)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 0 (No error code since a missing parameter evaluates to true)
+ TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
+
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testOptionalsCompatible", Err, Error$, Erl)
@@ -231,6 +237,15 @@ errorHandler:
TestObjectError = Err()
End Function
+Function TestBooleanOperations(Optional optBool As Boolean)
+On Error GoTo errorHandler
+ if optBool then
+ TestBooleanOperations = 0
+ end if
+errorHandler:
+ TestBooleanOperations = Err()
+End Function
+
Function CollectionSum(C)
Dim idx As Integer
CollectionSum = 0