You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Determines wheter expected value is within range (tolerance) from another value.
1100
+
1101
+
The logical formual used for calcuating the matcher is:
1102
+
```
1103
+
result := ( abs( expected - actual ) <= distance )
1104
+
```
1105
+
The actual formula used for calculation is more complex to handle different data-types of expected/actual values as well as differnet types of distance value.
1106
+
The matcher will fail if the `expected` and `actual` are more than `distance` apart from each other.
1107
+
The matcher will fail if the dataypes of `expected` and `actual` are not the same.
1108
+
1109
+
The matcher works with data-types: `number`, `date`, `timestamp`, `timestamp with time zone`, `timestamp with local time zone`
1110
+
The data-types of compared values must match exactly and if type does not match, the expectation will fail.
| timestamp with time zone | interval day to second |
1120
+
| timestamp with time zone | interval year to month |
1121
+
| timestamp with local time zone | interval day to second |
1122
+
| timestamp with local time zone | interval year to month |
1123
+
1124
+
1125
+
The distance must be expressed as a non-negative number or non-negative interval.
1126
+
1127
+
>Note:
1128
+
> Interval year-to-moth as a distance is giving sucess if the distance between the given dates/timestamps evaluates to value less or equal of the specified interval
1129
+
> Keep in mind that a checking for distance of `interval '0-1' year to month` will actuall be successful if the distance is less than a month and 15 days.
1130
+
> This is due to how oracle evaluates conversion between timestamp difference converted to `year to month interval`.
1131
+
> The behavior is similar to a call to `months_between()` function with results rounded to full monts ie. round(months_between(date, date))
1132
+
1133
+
**Example 1.**
1134
+
```sql
1135
+
begin
1136
+
ut.expect(3).to_be_within(1).of_(4);
1137
+
end;
1138
+
/
1139
+
```
1140
+
1141
+
**Example 2.**
1142
+
```sql
1143
+
begin
1144
+
ut.expect(3).to_be_within(1).of_(5);
1145
+
end;
1146
+
/
1147
+
```
1148
+
1149
+
Returns following output via DBMS_OUTPUT:
1150
+
```
1151
+
Failures:
1152
+
1153
+
1) wihtin_test
1154
+
Actual: 3 (number) was expected to be within 1 of 5 (number)
1155
+
at "UT3_DEVELOP.UT_BE_WITHIN.OF_", line 48 l_result.expectation.to_(l_result );
1156
+
at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5
0 commit comments