Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b5a5c0

Browse files
committed
Improving matcher documentation
1 parent 25b55b4 commit 5b5a5c0

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

docs/userguide/expectations.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ The matrix below illustrates the data types supported by different matchers.
333333
| **be_like** | | | X | | | | | | X | | | | | | |
334334
| **be_empty** | X | | X | | | | | | | | | X | X | | X |
335335
| **have_count** | | | | | | | | | | | | X | X | | X |
336-
| **be_within().of_()** | | | | x | x | | | | | | | | | | |
337-
| **be_within_pct().of_()** | | | | | x | | | | | | | | | | |
336+
| **be_within().of_()** | | | | X | X | X | X | X | | | | | | | |
337+
| **be_within_pct().of_()** | | | | | X | | | | | | | | | | |
338338

339339
# Expecting exceptions
340340

@@ -1096,17 +1096,34 @@ SUCCESS
10961096
10971097
## to_be_within of
10981098
1099-
This matcher is created to determine wheter expected value is approximately equal or "close" to another value.
1099+
This matcher determines wheter expected value is within range from another value.
11001100
1101-
Matcher will allow to compare numbers as well as dates.
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.
11021104
1103-
When comparing a number the tolerance / distance can be expressed as another postive number or a percentage.
1105+
The matcher works with data-type number, date, timestamp, timestamp with time zone, timestamp with local time zone.
1106+
The data-types of compared values must match exactly and if type does not match, the expectation will fail.
11041107
1105-
When comparing a two dates tolerance can be expressed in interval time either Day-To-Second or Year-To-Month.
1108+
| expected/actual<br>data-type | distance data-type |
1109+
|:------------------------------:|:----------------------:|
1110+
| number | number |
1111+
| date | interval day to second |
1112+
| date | interval year to month |
1113+
| timestamp | interval day to second |
1114+
| timestamp | interval year to month |
1115+
| timestamp with time zone | interval day to second |
1116+
| timestamp with time zone | interval year to month |
1117+
| timestamp with local time zone | interval day to second |
1118+
| timestamp with local time zone | interval year to month |
11061119
1107-
Matcher for numbers will calculate a absolute distance between expected and actual and check whether that value is within a tolerance.
11081120
1109-
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.
1121+
The distance can be expressed as a postive number or positive interval.
1122+
1123+
>Note:
1124+
> 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`.
11101127
11111128
**Example 1.**
11121129
```sql

0 commit comments

Comments
 (0)