Skip to content
QiTASC.com / intaQt Verification /
Verification Built-ins
/ .. /
Verification Built-ins





Verification Built-ins

These built-ins are used for defining Selectors.

Verification Built-ins
Number Matching Built-in
Time Matching Built-in
Bit Matcher Built-in
Check Bits Set
Check Bits Clear
Check Bits With Base
Rounding Built-ins
Date Creation Built-ins

Number Matching Built-in

This built-in checks that the two phone numbers match in a certain format, returning true for a match and false otherwise. For example, it can check if the value of a party's phone number matches the number used in the test case and comes in the specified format.

Syntax

1
2
<doesItMatch Boolean> = check(<phone Identifier>)
    .against(<phoneNumberFormat String>).basedOn(<telephoneNumber String>)

Parameters

  • doesItMatch - true if the phone numbers match. false otherwise.

  • phone - The name assigned to the phone.

  • phoneNumberFormat - "The a phone number's format, e.g. 'CC.NDC.NUMBER'.

  • telephoneNumber - The telephone number to match the named phone against.

Example

1
check(A_Party).against('CC.NDC.NUMBER').basedOn("+4912345678")

Time Matching Built-in

This built-in checks that a time occurs before or after a second time. It also can check that the first time matches a second time with a certain time range. It returns true or false.

Syntax

1
2
3
4
5
6
// Checks that the first time occurs before the second time
<isItBefore Boolean> = check(<matchableTime1 Any>).before(<matchableTime2 Any>)
// Checks that the first time occurs after the second time
<isItAfter Boolean> = check(<matchableTime1 Any>).after(<matchableTime2 Any>)
// Checks the absolute value of the time difference
<doesItMatch Boolean> = check(<matchableTime1 Any>).and(<matchableTime2 Any>).withinMillis(<time Number>)

Parameters

  • isItBefore - true if the first time occurs before the second time. false otherwise.

  • isItAfter - true if the first time occurs after the second time. false otherwise.

  • doesItMatch - true if the first and second time match each other within the specified time range.

  • matchableTimeX - A ticket property name, test case variable or context object resolving to the data type date or number (which will be converted to a date by using Unix epoch time.

  • time - The number of milliseconds.

Example

1
2
3
check(5).after(10)
check(Time_Stamp).before(testcase.finishTime)
check(A.lastCallDuration).and(B.lastCallDuration).withinMillis(1000)

The example above checks:

  • If 5 is after 10 (false).

  • If Time_Stamp is before testcase.finishTime.

  • That the absolute value of A.lastCallDuration minus B.lastCallDuration is smaller than 1000.

Bit Matcher Built-in

The bit matcher built-in checks that a bits' position in a mask corresponds to the bits of a given value converted to a binary number. It returns true or false.

Note: Matching goes from right to left.

Check Bits Set

This method checks if the set bit's (bits with value 1) position corresponds to the mask's set bits.

An additional withBase() method can be prepended, which sets the base for the value to a base other than the default of 16. For example, withBase(8) assigns an octal base to the value.

Syntax

1
2
3
4
<doSetBitsMatch Boolean> = checkBitsSet(<value Number|String>, <mask Number>)
// Applies a base to checkBitsSet
<doSetBitsMatch Boolean> = withBase(<base Number>)
    .checkBitsSet(<value Number|String>, <mask Number>)

Parameters

  • doSetBitsMatch - true if the bits set's value matches the mask. false otherwise.

  • value - A number, or a string that resolves to a number using the default base. The value will be converted to a binary before it is checked against the mask.

    • Octal numbers must have a leading 0. For example, the decimal number 18 will be encoded in 022 as an octal.
    • Hexadecimal numbers must have a leading 0x. For example, 0x12.
  • mask - A number that will be converted to a binary number to serve as a bit mask. The resulting bit mask is then used to evaluate if the corresponding value bits are set. The base for the mask is always 10.

  • base - An integer number system used as base for converting the value. If the withBase method is not used, the default base for the value will be 16.

Example Without Base

1
2
// Returns false
checkBitsSet("010", 2)

In the example above, the hexadecimal number "010" (decimal value: 16) is converted to a binary number (10000). The decimal number 2 is also converted to a binary number (10). When comparing the two values, the second bit of the value also needs to be set, (which it is not here).

Because the first bit of the mask is not set (0), it will be ignored. The same goes for the value's remaining digits, which do not have a counterpart in the mask. The result will be false because the bits do not match.

Example With Base

1
2
// Returns true
withBase(8).checkBitsSet("74", 0x3C)

In the example above, "74" is converted into a binary number using the octal number system, as specified by withBase(8). The bit mask "0x3C" is encoded as a hexadecimal number.

The value and bit mask would be represented as follows:

1
2
3
4
// Value, Octal: 074; Decimal: 60
111100
// Mask, Hexadecimal: 0x3C; Decimal: 60
111100

The binary results are 111100, meaning the set bits match and the result will be true.

Check Bits Clear

This method checks if all clear bits (bits with value 0) instead of clear bits (0) in the mask have a corresponding clear bit in the value. An additional withBase method can be prepended and specifies a base value instead of the default hexadecimal base 16. For example, withBase(8) assigns an octal base value.

Syntax

1
2
3
4
<doClearBitsMatch Boolean> = checkBitsClear(<value Number|String>, <mask Number>)
// Applies a base to checkBitsClear
<doClearBitsMatch Boolean> = withBase(<base Number>)
    .checkBitsClear(<value Number|String>, <mask Number>)

Parameters

  • doClearBitsMatch - true if the clear bits match the mask. false otherwise.

  • value - A number, or a string that resolves to a number using the default base. The value will be converted to a binary before it is checked against the mask.

    • Octal numbers must have a leading 0. For example, the decimal number 18 will be encoded in 022 as an octal.
    • Hexadecimal numbers must have a leading 0x. For example, 0x12.
  • mask - A number that will be converted to a binary number to serve as a bit mask. The resulting bit mask is then used to evaluate if the corresponding value bits are set. The base for the mask is always 10.

  • base - An integer number system used as base for converting the value. If the withBase method is not used, the default base for the value will be 16.

Example Without Base

1
2
// Returns true
checkBitsClear(22, 17)

In the example above, the value (22) is treated as a hexadecimal number. It will be converted with the default base 16 to 100010. The mask will resolve to 10001. The mask, 17, (or as binary 10001) shows that the first and the fifth bits of the value 22 (100010) will be checked against zero 0 (clear bits). Because these bits are 0, the result is true.

Example With Base

1
2
// Returns false
withBase(8).checkBitsClear(22, 18)

In the example above, 22 is treated as an octal number. It will be converted to 10010. The mask will also resolve to 10010. It will return false because the bits are not clear.

Rounding Built-ins

The rounding built-ins expect either a value or both a value and scale. This allows any number or variable resolving to a number to be rounded according to the specified method and scale.

Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Rounds away from zero
<roundedValue Number> = roundUp(<value Number|String>)
// Rounds away from zero with scaling
<roundedValue Number> = roundUp(<value Number|String>, <scale Number>)
// Rounds toward zero
<roundedValue Number> = roundDown(<value Number|String>)
// Rounds toward zero with scaling
<roundedValue Number> = roundDown(<value Number|String>, <scale Number>)
// Rounds towards "nearest neighbor" unless both neighbors
// are equidistant, in which case round up
<roundedValue Number> = roundHalfUp(<value Number|String>)
// Rounding towards "nearest neighbor" unless both neighbors
// are equidistant, in which case round up with scaling
<roundedValue Number> = roundHalfUp(<value Number|String>, <scale Number>)
// Rounds towards "nearest neighbor" unless both neighbors are
// equidistant, in which case round down.
<roundedValue Number> = roundHalfDown(<value Number|String>)
// Rounds towards "nearest neighbor" unless both neighbors are
// equidistant, in which case round down with scaling
<roundedValue Number> = roundHalfDown(<value Number|String>, <scale Number>)
// Rounds towards positive infinity
<roundedValue Number> = roundCeiling(<value Number|String>)
// Rounds towards positive infinity with scaling
<roundedValue Number> = roundCeiling(<value Number|String>, <scale Number>)
// Rounds towards negative infinity
<roundedValue Number> = roundFloor(<value Number|String>)
// Rounds towards negative infinity with scaling
<roundedValue Number> = roundFloor(<value Number|String>, <scale Number>)

Parameters

  • roundedValue - The resulting number after rounding.

  • value - Describes the value that will be rounded (for example, the call duration). May be a number, string or context object that resolves to a number.

  • scale - The scale to round by. May be used with the following methods:

    • roundUp - Rounds away from zero. For example rounding 20.1 and 20.7 to 21, while -20.1 and -20.7 become -21.
    • roundDown - Rounds towards zero. For example, rounding 20.1 and 20.7 to 20, while -20.1 and -20.7 become -20.
    • roundHalfUp - Rounds up. If the digit at position 10^(-(SCALE + 1) is 5 or higher. For example, 20.1 will become 20. 20.5 will become 21.
    • roundHalfDown - Rounds down. If the digit at position 10^(-(SCALE + 1) is 5 or lower. For example, 20.1 as well as 20.5 will become 20. 20.7 will become 21.
    • roundCeiling Rounds up towards positive infinity. For example, 20.1 and 29.7 will become 21. -20.1 and -20.7 will become -20.
    • roundFloor - Rounds down towards negative infinity. For example, 20.1 and 20.7 will become 20.. -20.1 and -20.7 will become -21.

Example

1
2
3
4
5
6
CdrVerificationVariables {
    cdrSelectionA {
         "moc" = "check(A_Party).against('CC.NDC.NUMBER').basedOn(ctx.A.number)
            && roundUp(Call_Duration) == '5'"
    }
}

Date Creation Built-ins

The Date Creation Built-ins create dates, with an optional date format specification. If no format is specified, ISO8601 will be applied.

Syntax

1
2
3
4
// Without specified format
<result Date> = dateTime(<dateTime String>)
// With specified format
<result Date> = withFormat(<pattern String>).dateTime(<dateTime String>)

Returns
The dateTime object.

Parameters

  • dateTime - The string representation of date and time in ISO8601 format

  • pattern (Optional) - The date and time format to apply

Example

1
2
3
variables
    COC =Tickets("propertyA == dateTime('2017-10-12') && propertyB == withFormat('yyyy').dateTime('2017')")
end