endsWith
Short summary
This assertion method checks if the current string stringToCheck ends with end
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
Attention: end of the string is ALWAYS the right side of the string even for writings which written from right to left like Hebrew or Arabic
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringToCheck | ANY_STRING | current string to check | input |
| end | ANY_STRING | expected end of stringToCheck | input |
| message | AssertMessage | message if the assertion is false | input |
| ignoreCases | BOOL | TRUE means ignore cases; FALSE means cases must be equal too | input |
| trim | BOOL | TRUE means truncation of spaces on the right side of stringToCheck | input |
| normalizeStrings | BOOL | normalize both strings for check | input |
Code
Declaration
METHOD endsWith
VAR_INPUT
(* current string to check *)
stringToCheck :ANY_STRING;
(* expected end of ``stringToCheck`` *)
end :ANY_STRING;
(* message if the assertion is false *)
message :AssertMessage;
(* ``TRUE`` means ignore cases; ``FALSE`` means cases must be equal too *)
ignoreCases :BOOL := FALSE;
(* ``TRUE`` means truncation of spaces on the right side of ``stringToCheck``*)
trim :BOOL := FALSE;
(*normalize both strings for check*)
normalizeStrings :BOOL := TRUE;
END_VAR
Implementation
IF ((
stringToCheck.TypeClass <> end.TypeClass
) OR_ELSE (
stringToCheck.diSize = 0
) OR_ELSE (
end.diSize = 0
)
) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('endsWith'));
RETURN;
END_IF
CASE stringToCheck.TypeClass OF
TYPE_CLASS.TYPE_STRING:
THIS^.utf8Assertions.endsWith(
stringToCheck := stringToCheck.pValue,
end := end.pValue,
ignoreCases := ignoreCases,
trim := trim,
message := message,
normalizeStrings := normalizeStrings
);
TYPE_CLASS.TYPE_WSTRING:
THIS^.utf16Assertions.endsWith(
stringToCheck := stringToCheck.pValue,
end := end.pValue,
ignoreCases := ignoreCases,
trim := trim,
message := message,
normalizeStrings := normalizeStrings
);
ELSE
; // do nothing
END_CASE