isNotEqualTo
Short summary
This assertion method checks if the current string stringToCheck is not equal to unexpected.
Processed strings must be in Windows-1252 or Windows-1251 encoding
Attention: All strings are handled as null-terminated byte streams
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringToCheck | POINTER TO BYTE | current string to check | input |
| unexpected | POINTER TO BYTE | stringToCheck must be not equal to expected | input |
| ignoreCases | BOOL | TRUE means ignore cases; FALSE means that cases must be equal too | input |
| message | AssertMessage | message if the assertion is false | input |
| sbcsType | Tc2_Utilities.E_SBCSType | used Single Byte Character Set (SBCS), is set in Tc2_Utilities.GLOBAL_SBCS_TABLE | input |
Code
Declaration
METHOD isNotEqualTo
VAR_INPUT
(* current string to check *)
stringToCheck :POINTER TO BYTE;
(* ``stringToCheck`` must be not equal to expected *)
unexpected :POINTER TO BYTE;
(* ``TRUE`` means ignore cases; ``FALSE`` means that cases must be equal too *)
ignoreCases :BOOL;
(* message if the assertion is false *)
message :AssertMessage;
(* used Single Byte Character Set (SBCS), is set in Tc2_Utilities.GLOBAL_SBCS_TABLE *)
sbcsType :Tc2_Utilities.E_SBCSType := Tc2_Utilities.E_SBCSType.eSBCS_WesternEuropean;
END_VAR
VAR
(* length of current string to check *)
lengthStringToCheck :UDINT;
(* length of ``unexpected`` *)
lengthUnexpectedString :UDINT;
(* string address we use to compare, if it's case sensitive it's equal to ``stringToCheck`` *)
usedStringToCheck :POINTER TO BYTE;
(* seacrch string address we use to compare, if it's case sensitive it's equal to ``expected`` *)
usedUnexpectedString :POINTER TO BYTE;
END_VAR
VAR CONSTANT
(* length of an empty string to avoid Tc2_System.MEMCMP with length 0 *)
EMPTY_STRING_LENGTH :UDINT := 0;
END_VAR
Implementation
lengthStringToCheck := THIS^.getStringLength(stringToCheck);
lengthUnexpectedString := THIS^.getStringLength(unexpected);
IF lengthStringToCheck = EMPTY_STRING_LENGTH AND_THEN lengthUnexpectedString = EMPTY_STRING_LENGTH THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('isNotEqualTo'));
RETURN;
END_IF
usedStringToCheck := THIS^.getNewUpperCaseString(stringToCheck, lengthStringToCheck, ignoreCases, sbcsType := sbcsType);
usedUnexpectedString := THIS^.getNewUpperCaseString(unexpected, lengthUnexpectedString, ignoreCases, sbcsType := sbcsType);
IF (
(lengthStringToCheck = lengthUnexpectedString)
AND_THEN
Tc2_System.MEMCMP(
usedStringToCheck,
usedUnexpectedString,
lengthUnexpectedString
) = CNM_ReturnTypes.ComparationResult.EQUAL
) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('isNotEqualTo'));
END_IF;
THIS^.freeMemory(usedStringToCheck, ignoreCases);
THIS^.freeMemory(usedUnexpectedString, ignoreCases);