isContainsNoCheckNecessary
Short summary
Methods for checking if an assert statement with contains or contains not, makes sense based on the string lengths
=
:return: FLASE means it's not necessary
to check the string content, TRUE means
it's necessary to check the string content
to know if the assertion is true or false
- Return type:
BOOL
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringToCheck | POINTER TO BYTE | current string to check | input |
| searchString | POINTER TO BYTE | string must be found in stringToCheck | input |
| lengthStringToCheck | UDINT | length of current string to check | input |
| lengthSearchString | UDINT | length of searchString | input |
| additionalText | Tc2_System.T_MaxString | just additional text if assert is false | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
METHOD PROTECTED isContainsNoCheckNecessary :BOOL
VAR_INPUT
(* current string to check *)
stringToCheck :POINTER TO BYTE;
(* string must be found in ``stringToCheck`` *)
searchString :POINTER TO BYTE;
(* length of current string to check *)
lengthStringToCheck :UDINT;
(* length of ``searchString`` *)
lengthSearchString :UDINT;
(* just additional text if assert is false *)
additionalText :Tc2_System.T_MaxString;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
Implementation
isContainsNoCheckNecessary := FALSE;
IF ((
lengthSearchString > lengthStringToCheck
) OR_ELSE (
(stringToCheck = 0) XOR (searchString = 0)
)
) THEN
RETURN; //assert is true
ELSIF ((
(stringToCheck = 0) AND_THEN (searchString = 0)
) OR_ELSE (
lengthSearchString = 0
)
) THEN
THIS^.assertionWasWrong(message, additionalText);
RETURN;
END_IF
isContainsNoCheckNecessary := TRUE;