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
Copy file name to clipboardExpand all lines: docs/userguide/expectations.md
+25-18Lines changed: 25 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1096,13 +1096,17 @@ SUCCESS
1096
1096
1097
1097
## to_be_within of
1098
1098
1099
-
This matcher determines wheter expected value is within range from another value.
1099
+
Determines wheter expected value is within range (tolerance) from another value.
1100
1100
1101
-
The logical formual used for calcuating the matcher is:
1102
-
`abs( expected - actual ) <= distance`
1103
-
The matcher will succeed if the `expected` and `actual` are not more than `distance` apart from each other.
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.
1104
1108
1105
-
The matcher works with data-type number, date, timestamp, timestamp with time zone, timestamp with local time zone.
1109
+
The matcher works with data-types: `number`, `date`, `timestamp`, `timestamp with time zone`, `timestamp with local time zone`
1106
1110
The data-types of compared values must match exactly and if type does not match, the expectation will fail.
@@ -1118,12 +1122,13 @@ The data-types of compared values must match exactly and if type does not match,
1118
1122
| timestamp with local time zone | interval year to month |
1119
1123
1120
1124
1121
-
The distance can be expressed as a postive number or positive interval.
1125
+
The distance must be expressed as a non-negative number or non-negative interval.
1122
1126
1123
1127
>Note:
1124
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
1125
-
> Keep in mind that a distance of `interval '0-1' year to month` will actuall be successful if the distance isnot greater than a month and a half.
1126
-
> This is due to how oracle evaluates conversion between timestamp difference converted to `year to month 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))
1127
1132
1128
1133
**Example 1.**
1129
1134
```sql
@@ -1172,17 +1177,14 @@ Failures:
1172
1177
1173
1178
## to_be_within_pct of
1174
1179
1175
-
This matcher is created to determine wheter expected value is approximately equal or "close" to another value within percentage value of expected.
1176
-
1177
-
Matcher will allow to compare numbers.
1178
-
1179
-
When comparing a number the tolerance / distance can be expressed as another postive number or a percentage.
1180
-
1181
-
When comparing a two dates tolerance can be expressed in interval time either Day-To-Second or Year-To-Month.
1182
-
1183
-
Matcher for numbers will calculate a absolute distance between expected and actual and check whether that value is within a tolerance.
1180
+
Determines wheter actual value is within percentage range of expected value.
1181
+
The matcher only works with `number` data-type.
1184
1182
1185
-
When comparing a date a distance is measured in interval, the check is done that actual value is within date range of expected taking into account interval plus and minus.
1183
+
The percentage deviation (distance) must be expressed as a non-negative number.
1184
+
The formula used for calcuation of expectation is:
1185
+
```
1186
+
result := ( ( distance ) * expected >= abs( expected - actual ) * 100 )
1187
+
```
1186
1188
1187
1189
**Example 1.**
1188
1190
```sql
@@ -1192,6 +1194,11 @@ end;
1192
1194
/
1193
1195
```
1194
1196
1197
+
```
1198
+
SUCCESS
1199
+
Actual: 9 (number) was expected to be within 10 % of 10 (number)
1200
+
```
1201
+
1195
1202
1196
1203
## Comparing cursors, object types, nested tables and varrays
0 commit comments