isNotEmpty
Short summary
This assertion method checks if the current string stringToCheck is not empty
Attention: All strings are handled as null terminated byte/word streams. For UTF-8 is end of the string 16#00 For UTF-16 is end of the string 16#00_00
Attention:
The interface IUnicodeAssertions uses ANY_STRING,
for this it's not possible to use literals/constants,
because for ANY types generates the compiler __SYSTEM.AnyType
and __SYSTEM.AnyType contains a pointer
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringToCheck | ANY_STRING | current string to check | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
METHOD isNotEmpty
VAR_INPUT
(* current string to check *)
stringToCheck :ANY_STRING;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
VAR CONSTANT
(* strings are null terminated *)
END_OF_UTF8_STRING :BYTE := 16#00;
(* strings are null terminated *)
END_OF_UTF16_STRING :WORD := 16#0000;
END_VAR
Implementation
CASE stringToCheck.TypeClass OF
TYPE_CLASS.TYPE_STRING:
IF (stringToCheck.pValue^ = END_OF_UTF8_STRING) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('isNotEmpty'));
END_IF
TYPE_CLASS.TYPE_WSTRING:
IF (stringToCheck.pValue^ = END_OF_UTF16_STRING) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('isNotEmpty'));
END_IF
ELSE
; // do nothing
END_CASE