QiTASC.com / intaQt Built-ins /
Fuzz Built-ins
/ .. /
Fuzz Built-ins

# Fuzz Built-ins¶

Fuzz Built-ins provide functions for generating random values, including number ranges, date ranges, strings and making boundary checks. Potential use cases include:

• Selecting a random dataset from a given list of datasets

• Randomizing customer data, including name, date of birth, address, phone numbers or passwords

## Fuzzy Number Ranges Built-ins ¶

Fuzzy Number Ranges Built-ins provide random integer or floating values within the given lower and upper boundaries (inclusive). In other words, if the range is from `0` to `10`, the lowest randomly-generated value would be `0` and the highest would be `10`.

### Create Fuzzy Number Range ¶

This function creates the instance of the fuzzy number range generator.

Syntax

 `1` ``` := Fuzz.forNumberRange(, ) ```

Returns

The instance of the fuzzy number range generator.

Parameters

• lowerBound - The smallest possible value that can be generated

• upperBound - The largest possible value that can be generated

Example

 `1` ```fuzz := Fuzz.forNumberRange(1, 10) ```

### Fuzzy Number Lower Boundary ¶

Returns the lower boundary of the fuzzy number range generator.

Syntax

 `1` ``` := .getLowerBound() ```

Returns

The lower boundary of the fuzzy number range generator.

Parameter

• fuzzyNumberRange - The instance of the fuzzy number range generator

Example

 ```1 2 3``` ```lower := 0 upper := 10 lowerBound := Fuzz.forNumberRange(lower, upper).getLowerBound() ```

### Fuzzy Number Upper Boundary ¶

Returns the upper boundary of the fuzzy number range generator.

Syntax

 `1` ``` := .getUpperBound() ```

Returns

The upper boundary of the fuzzy number range generator.

Parameter

• fuzzyNumberRange - The instance of the fuzzy number range generator

Example

 ```1 2 3``` ```lower := 0 upper := 10 upperBound := Fuzz.forNumberRange(lower, upper).getUpperBound() ```

### Random Integer Number ¶

Generates a random integer value from the specified range.

Syntax

 `1` ``` := .nextInt() ```

Returns

The randomly-generated integer.

Parameter

• fuzzyNumberRange - The instance of fuzzy number range generator

Example

 ```1 2``` ```fuzz := Fuzz.forNumberRange(1, 10) randomInt := fuzz.nextInt() ```

### Random Integer Boundary Checks ¶

The random integer boundary check enables testing potentially problematic values by further limiting the possible range of values. This is done by specifying a `delta`, in other words, the size and width of a subrange, where subranges are located near the edge values.

Syntax

 `1` ``` := .nextInt() ```

Returns

The randomly-generated integer number within one of the calculated boundary ranges.

Parameters

• fuzzyNumberRange - The instance of fuzzy number range generator

• delta - The size of the desired boundary subranges

Example

 ```1 2``` ```fuzz := Fuzz.createNumberRange(1, 10) randomInt := fuzz.nextInt(1) ```

The example above shows that:

• The first line creates a range with lower and upper boundaries of `1` and `10`, respectively.

• The second line calculates a number within the boundary ranges, where the possible return values are `1`, `2`, `9` and `10`.

• Delta indicates a width of `1`, meaning the lower boundary range spans from the lower boundary (`1`) to `2` (lower boundary + delta) and the upper boundary range spans from the upper boundary (`10`) to `9` (upper boundary - delta).

• Similar to the upper and lower boundary values, the boundary subrange values are inclusive.

### Random Floating Number ¶

Generates a random floating number value from the specified range.

Syntax

 `1` ``` := .nextFloat() ```

Returns

The randomly-generated floating number.

Parameters

• fuzzyNumberRange - The instance of fuzzy number range generator

Example

 ```1 2``` ```fuzz := Fuzz.forNumberRange(1, 10) randomFloat := fuzz.nextFloat() ```

### Random Floating Number Boundary Check ¶

The random floating number `boundary` function enables testing potentially problematic values by further limiting the possible range of values. This is done by specifying a `delta`, in other words, the size and width of a subrange, where subranges are located near the edge values.

Syntax

 `1` ``` := .nextFloat() ```

Returns

The randomly-generated number within one of the calculated boundary ranges.

Parameters

• fuzzyNumberRange - The instance of fuzzy number range generator

• delta - The size of the desired boundary subranges

Example

 ```1 2``` ```fuzz := Fuzz.createNumberRange(1, 10) randomFloat := fuzz.nextFloat(2.0) ```

The example above shows that:

• The first line creates a range with lower and upper boundaries of `1` and `10`, respectively.

• The second line calculates a number within the boundary ranges, where the possible return values are `1`, `2`, `9` and `10`.

• Delta indicates a width of `1`, meaning the lower boundary range spans from the lower boundary (`1`) to `2` (lower boundary + delta) and the upper boundary range spans from the upper boundary (`10`) to `9` (upper boundary - delta).

• Similar to the upper and lower boundary values, the boundary subrange values are inclusive.

## Fuzzy Date Ranges Built-ins ¶

Fuzzy Date Ranges Built-ins provide random dates within the given lower and upper boundaries (inclusive). In other words, if the range is from `now("Europe/Vienna")` to `now("Europe/Vienna").plusMinutes(30)`, the lowest randomly-generated value would be `now("Europe/Vienna")` and the highest would be `now("Europe/Vienna").plusMinutes(30)`.

### Create Fuzzy Date Range ¶

This function creates the instance of the fuzzy date range generator.

Syntax

 `1` ``` := Fuzz.forDateRange(, ) ```

Returns

The instance of fuzzy date range for random date generation.

Parameters

• lowerBound - The lower bound of the date range

• upperBound - The upper bound of the date range (must be greater than or equal to lower bound)

Example

 `1` ```fuzz := Fuzz.forDateRange(now("Europe/Vienna"), now("Europe/Vienna").plusMinutes(30)) ```

### Fuzzy Date Range Lower Boundary ¶

Returns the lower boundary of the fuzzy date range generator.

Syntax

 `1` ``` := .getLowerBound() ```

Returns

The lower boundary of the fuzzy date range generator.

Parameter

• fuzzyDateRange - The instance of the fuzzy date range generator

Example

 ```1 2 3``` ```lower := now("Europe/Vienna") upper := now("Europe/Vienna").plusMinutes(30) lowerBound := Fuzz.forDateRange(lower, upper).getLowerBound() ```

### Fuzzy Date Range Upper Boundary ¶

Returns the upper boundary of the fuzzy date range generator.

Syntax

 `1` ``` := .getUpperBound() ```

Returns

The upper boundary of the fuzzy date range generator.

Parameter

• fuzzyDateRange - The instance of the fuzzy date range generator

Example

 ```1 2 3``` ```lower := now("Europe/Vienna") upper := now("Europe/Vienna").plusMinutes(30) upperBound := Fuzz.forDateRange(lower, upper).getUpperBound() ```

### Random Date ¶

Generates a random date from the specified range.

Syntax

 `1` ``` := .next() ```

Returns

The random date within the rage specified for FuzzyDateRange.

Parameter

• fuzzyDateRange - The instance of the fuzzy date range generator

Example

 ```1 2``` ```fuzz := Fuzz.forDateRange(now("Europe/Vienna"), now("Europe/Vienna").plusMinutes(30)) date := fuzz.next() ```

## Fuzzy Regex Built-ins ¶

Fuzzy Regex Built-ins provide methods for randomly-generated strings that match the specified Regex or length.

### Create Fuzzy Regex String ¶

This function creates the instance of the fuzzy Regex string generator.

Syntax

 `1` ``` := Fuzz.forRegex() ```

Returns

The instance of fuzzy regex string generator.

Parameter

• regex - The regex that randomly-generated strings should match to

Example

 `1` ```fuzz := Fuzz.forRegex("M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") ```

### Fuzzy Regex String Length ¶

Specifies the length of the randomly-generated strings and returns an instance of the fuzzy Regex string generator.

Syntax

 `1` ``` := Fuzz.forStringOfLength() ```

Returns

The instance of fuzzy regex string generator.

Parameter

• length - The length of the randomly-generated stings (between 0 and 100000)

Example

 ```1 2``` ```fuzzForRegex := Fuzz.forRegex("M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") fuzForStringsOfLengthTen := Fuzz.forStringOfLength(10) ```

### Random Regex String ¶

Generates a randomly-generated string based on the Regex or length pattern.

Syntax

 `1` ``` := .next() ```

Returns

The randomly-generated string.

Parameter

• fuzzyRegex - The instance of fuzzy Regex string generator

Example

 ```1 2``` ```fuzz := Fuzz.forRegex("M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") randomRomanNumber := fuzz.next() // e.g. IX, C, MXCV ```

## Fuzzy Random Elements from List Built-ins ¶

Fuzzy Random Elements from List Built-ins provide methods for getting random elements from a list.

### Create Fuzzy List ¶

This function creates the instance of the fuzzy list.

Syntax

 `1` ``` := Fuzz.forList(>) ```

Returns

The instance of fuzzy list, which is used for getting random elements from the list.

Parameter

• values - The list of possible values

Example

 `1` ```fuzz := Fuzz.forList([1, 5, 12]) ```

### Get Random Element from List ¶

Gets the random element from the list.

Syntax

 `1` ``` := .next() ```

Returns

The random element from the list specified for `FuzzyList`.

Parameter

• fuzzyList - The instance of generated fuzzy list

Example

 ```1 2``` ```fuzz := Fuzz.forList([1, 5, 12]) randomElementFromList := fuzz.next() ```

### Fuzzy List Boundary Check ¶

The random fuzzy list `boundary` function enables testing potentially problematic values by further limiting the possible range of values. This is done by specifying a `delta`, in other words, the size and width of a subrange, where subranges are located near the edge values.

Syntax

 `1` ``` := .next() ```

Returns

The random element from the list specified for `FuzzyList` from one of the boundary subranges.

Parameters

• fuzzyList - The instance of generated fuzzy list

• delta - The size of the desired boundary subranges

Example

 ```1 2``` ```fuzz := Fuzz.forList([1, 5, 12, 15, 17]) randomElementFromList := fuzz.next(1) ```

In the above example, only `1`, `5`, `15` and `17` are possible return values.