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

Skip to content

Commit b861d82

Browse files
committed
enhanced documentation
added not_to_be_true and not_to_be_false matchers
1 parent 83f13b9 commit b861d82

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

docs/userguide/expectations.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Example of unit test procedure body with a single expectation.
77
```sql
88
begin
99
ut.expect( 'the tested value' ).to_equal('the expected value');
10+
ut.expect( 'the tested value' ).to_( equal('the expected value') );
1011
end;
1112
```
1213

@@ -19,13 +20,12 @@ Pseudo-code:
1920
ut.expect( a_actual {data-type} ).not_to( {matcher} );
2021
```
2122

22-
Most of the matchers have shortcuts like:
23+
All matchers have shortcuts like:
2324
```sql
2425
ut.expect( a_actual {data-type} ).to_{matcher};
2526
ut.expect( a_actual {data-type} ).not_to{matcher};
2627
```
2728

28-
2929
# Matchers
3030
utPLSQL provides following matchers to perform checks on the expected and actual values.
3131
- `be_between`
@@ -183,8 +183,6 @@ end;
183183
```
184184
The `a_nulls_are_equal` parameter decides on the behavior of `null=null` comparison (**this comparison by default is true!**)
185185
186-
There are no shortcuts for `not_to_equal`, so use `not_to (equal(...))`
187-
188186
### Comparing cursors
189187
190188
The `equal` matcher accepts additional parameter `a_exclude varchar2` or `a_exclude ut_varchar2_list`, when used to compare `cursor` data.
@@ -270,7 +268,7 @@ create or replace package body test_get_events is
270268
ut.reset_nls();
271269
272270
ut.expect(l_actual).to_equal(l_expected);
273-
ut.expect(l_actual).not_to( equal(l_expected_bad_date) );
271+
ut.expect(l_actual).not_to_equal(l_expected_bad_date);
274272
end;
275273
276274
end;
@@ -385,9 +383,9 @@ end;
385383

386384
Syntax of check for matcher evaluating to false:
387385
```sql
388-
begin
389-
ut.expect( a_actual {data-type} ).not_to( {matcher} );
386+
begin
390387
ut.expect( a_actual {data-type} ).not_to_{matcher};
388+
ut.expect( a_actual {data-type} ).not_to( {matcher} );
391389
end;
392390
```
393391

source/expectations/ut_expectation_boolean.tpb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ create or replace type body ut_expectation_boolean as
3838
ut_utils.debug_log('ut_expectation_boolean.not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)');
3939
self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
4040
end;
41+
42+
member procedure not_to_be_true(self in ut_expectation_boolean) is
43+
begin
44+
ut_utils.debug_log('ut_expectation_boolean.not_to_be_true(self in ut_expectation_boolean)');
45+
self.not_to( ut_be_true() );
46+
end;
47+
48+
member procedure not_to_be_false(self in ut_expectation_boolean) is
49+
begin
50+
ut_utils.debug_log('ut_expectation_boolean.not_to_be_false(self in ut_expectation_boolean)');
51+
self.not_to( ut_be_false() );
52+
end;
4153

4254
end;
4355
/

source/expectations/ut_expectation_boolean.tps

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ create or replace type ut_expectation_boolean under ut_expectation(
1919
member procedure to_be_true(self in ut_expectation_boolean),
2020
member procedure to_be_false(self in ut_expectation_boolean),
2121

22-
overriding member procedure not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)
22+
overriding member procedure not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null),
23+
member procedure not_to_be_true(self in ut_expectation_boolean),
24+
member procedure not_to_be_false(self in ut_expectation_boolean)
2325
)
2426
/

0 commit comments

Comments
 (0)