Skip to main content

UnicodeAssertions

Short summary

Class provides assert statements for UTF-8 and UTF-16 strings with an undefined length.

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

AccessAbstractFinalExtendsImplements
INTERNALNoNoAbstractAssertionIUnicodeStringAssertions

UML Diagram

Parameters

none

Properties

className

Type: CNM_AbstractObject.ClassName

This abstract property returns the class name of the concrete object,

Methods

contains

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • searchString (ANY_STRING): string must be found in stringToCheck
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck contains the search string

containsNo

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • searchString (ANY_STRING): string that must not be found in stringToCheck
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck not contains the search string

endsWith

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • end (ANY_STRING): expected end of stringToCheck
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • trim (BOOL): TRUE means truncation of spaces on the right side of stringToCheck
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck ends with end

isEmpty

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is empty

isEqualTo

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • expected (ANY_STRING): stringToCheck must be equal to expected
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck is equal to expected

isNotEmpty

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is not empty

isNotEqualTo

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • unexpected (ANY_STRING): stringToCheck must be not equal to expected
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck is not equal to unexpected

lengthIsBetween

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • minLength (UDINT): lower limit of the string length
    • maxLength (UDINT): upper limit of the string length
    • stringLengthUnit (UnicodeStringLengthUnit): string length units of measurement
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is length

lengthIsExact

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • expectedLength (UDINT): expected length of stringToCheck
    • stringLengthUnit (UnicodeStringLengthUnit): string length units of measurement
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is length

lengthIsMax

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • maxLength (UDINT): upper limit of the length of stringToCheck
    • stringLengthUnit (UnicodeStringLengthUnit): string length units of measurement
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is length

lengthIsMin

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • minLength (UDINT): lower limit of the length of stringToCheck
    • stringLengthUnit (UnicodeStringLengthUnit): string length units of measurement
    • message (AssertMessage): message if the assertion is false
  • Return type: VOID

This assertion method checks if the current string stringToCheck is length

setCallBack

  • Parameters:
    • callBack (IAssertCallBack): the class that must be informed if an assertion is false
  • Return type: VOID

This methods is the setter for the callback class if an assertion was false

startsWith

  • Parameters:
    • stringToCheck (ANY_STRING): current string to check
    • start (ANY_STRING): expected start of stringToCheck
    • message (AssertMessage): message if the assertion is false
    • ignoreCases (BOOL): TRUE means ignore cases; FALSE means cases must be equal too
    • trim (BOOL): TRUE means truncation of spaces on the left side of stringToCheck
    • normalizeStrings (BOOL): normalize both strings for check
  • Return type: VOID

This assertion method checks if the current string stringToCheck starts with start

Code

Declaration

{attribute 'reflection'}
FUNCTION_BLOCK INTERNAL UnicodeAssertions EXTENDS AbstractAssertion IMPLEMENTS IUnicodeStringAssertions
VAR
(* class to handle the utf 8 string assertions *)
utf8Assertions :Utf8StringPointerAssertions();
(* class to handle the utf 16 string assertions *)
utf16Assertions :Utf16StringPointerAssertions();
END_VAR