Skip to content

Commit dd7e868

Browse files
committed
Renamed ut_include to ut_contain.
1 parent 7676a9a commit dd7e868

17 files changed

Lines changed: 104 additions & 456 deletions

docs/userguide/advanced_data_comparison.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
1515
ut.expect( a_actual {data-type} ).not_to( equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]) );
1616
ut.expect( a_actual {data-type} ).to_equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
1717
ut.expect( a_actual {data-type} ).not_to_equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]] );
18+
ut.expect( a_actual {data-type} ).to_( contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
19+
ut.expect( a_actual {data-type} ).not_to( contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]) );
1820
ut.expect( a_actual {data-type} ).to_contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
19-
ut.expect( a_actual {data-type} ).to_include( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
20-
ut.expect( a_actual {data-type} ).not_to_include( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
2121
ut.expect( a_actual {data-type} ).not_to_contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]);
2222
```
2323

@@ -61,7 +61,7 @@ procedure test_cur_skip_columns_cn is
6161
begin
6262
open l_expected for select 'text' ignore_me, d.* from user_tables d where rownum = 1;
6363
open l_actual for select sysdate "ADate", d.* from user_tables d;
64-
ut.expect( l_actual ).to_include( l_expected ).exclude( 'IGNORE_ME,ADate' );
64+
ut.expect( l_actual ).to_contain( l_expected ).exclude( 'IGNORE_ME,ADate' );
6565
end;
6666
```
6767

@@ -230,7 +230,7 @@ end;
230230
Above test will indicate that in actual data-set
231231

232232
```sql
233-
Actual: refcursor [ count = 43 ] was expected to include: refcursor [ count = 44 ]
233+
Actual: refcursor [ count = 43 ] was expected to contain: refcursor [ count = 44 ]
234234
Diff:
235235
Rows: [ 1 differences ]
236236
PK <USERNAME>TEST</USERNAME> - Missing <USER_ID>-610</USER_ID>
@@ -404,7 +404,7 @@ create or replace package body test_unordered_columns as
404404
and rownum < 20;
405405

406406
--Assert
407-
ut.expect(l_actual).to_include(l_expected).unordered_columns();
407+
ut.expect(l_actual).to_contain(l_expected).unordered_columns();
408408
end;
409409
end;
410410
/

docs/userguide/expectations.md

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ utPLSQL provides the following matchers to perform checks on the expected and ac
145145
- `be_null`
146146
- `be_true`
147147
- `equal`
148-
- `include ` / `contain`
148+
- `contain`
149149
- `have_count`
150150
- `match`
151151

@@ -433,17 +433,17 @@ end;
433433
The `a_nulls_are_equal` parameter controls the behavior of a `null = null` comparison.
434434
To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher.
435435

436-
## include / contain
436+
## contain
437437

438438
This matcher supports only cursor comparison. It check if the give set contain all values from given subset.
439439

440-
when comparing data using `include / contain` matcher, the data-types of columns for compared cursors must be exactly the same.
440+
When comparing data using `contain` matcher, the data-types of columns for compared cursors must be exactly the same.
441441

442-
The matcher supports all advanced comparison options as `equal` e.g. include , exclude, join_by.
442+
The matcher supports all advanced comparison options as `equal` like: `include` , `exclude`, `join_by` etc..
443443

444-
The matcher is successful when all of the values from expected results are included in actual data set.
444+
The matcher is successful when actual data set contains all of the values from expected results.
445445

446-
The matcher will cause a test to fail if any of expected values are not included in actual data set.
446+
The matcher will cause a test to fail if actual data set does not contain any of expected values.
447447

448448
![included_set](../images/venn21.gif)
449449

@@ -460,23 +460,23 @@ The matcher will cause a test to fail if any of expected values are not included
460460
union all select rownum as rn from dual a connect by level < 4;
461461

462462
--Act
463-
ut.expect(l_actual).to_include(l_expected);
463+
ut.expect(l_actual).to_contain(l_expected);
464464
end;
465465
```
466466

467467
Will result in failure message
468468

469469
```sql
470470
1) ut_refcursors
471-
Actual: refcursor [ count = 9 ] was expected to include: refcursor [ count = 6 ]
471+
Actual: refcursor [ count = 9 ] was expected to contain: refcursor [ count = 6 ]
472472
Diff:
473473
Rows: [ 3 differences ]
474474
Missing: <ROW><RN>3</RN></ROW>
475475
Missing: <ROW><RN>2</RN></ROW>
476476
Missing: <ROW><RN>1</RN></ROW>
477477
```
478478

479-
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicate.
479+
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicates.
480480

481481
*Example 2.*
482482

@@ -488,19 +488,19 @@ create or replace package ut_duplicate_test is
488488
--%suite(Sample Test Suite)
489489

490490
--%test(Ref Cursor contain duplicates)
491-
procedure ut_duplicate_include;
491+
procedure ut_duplicate_contain;
492492

493493
end ut_duplicate_test;
494494
/
495495

496496
create or replace package body ut_duplicate_test is
497-
procedure ut_duplicate_include is
497+
procedure ut_duplicate_contain is
498498
l_actual sys_refcursor;
499499
l_expected sys_refcursor;
500500
begin
501501
open l_expected for select mod(level,2) as rn from dual connect by level < 5;
502502
open l_actual for select mod(level,8) as rn from dual connect by level < 9;
503-
ut.expect(l_actual).to_include(l_expected);
503+
ut.expect(l_actual).to_contain(l_expected);
504504
end;
505505

506506
end ut_duplicate_test;
@@ -509,8 +509,8 @@ end ut_duplicate_test;
509509
Will result in failure test message
510510

511511
```sql
512-
1) ut_duplicate_include
513-
Actual: refcursor [ count = 8 ] was expected to include: refcursor [ count = 4 ]
512+
1) ut_duplicate_contain
513+
Actual: refcursor [ count = 8 ] was expected to contain: refcursor [ count = 4 ]
514514
Diff:
515515
Rows: [ 2 differences ]
516516
Missing: <RN>0</RN>
@@ -519,7 +519,7 @@ Will result in failure test message
519519

520520

521521

522-
The negated version of `include / contain` ( `not_to_include`/ `not_to_contain` ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap).
522+
The negated version of `contain` ( `not_to_contain` ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap).
523523

524524

525525

@@ -531,7 +531,7 @@ Set 1 is defined as [ A , B , C ]
531531

532532
*Set 2 is defined as [A , D , E ]*
533533

534-
*Result : This will fail both of options to`to_include` and `not_to_include`*
534+
*Result : This will fail both of options to `to_contain` and `not_to_contain`*
535535

536536

537537

@@ -541,7 +541,7 @@ Set 1 is defined as [ A , B , C , D ]
541541

542542
*Set 2 is defined as [A , B , D ]*
543543

544-
*Result : This will be success on option `to_include` and fail `not_to_include`*
544+
*Result : This will be success on option `to_contain` and fail `not_to_contain`*
545545

546546

547547

@@ -551,33 +551,33 @@ Set 1 is defined as [ A , B , C ]
551551

552552
*Set 2 is defined as [D, E , F ]*
553553

554-
*Result : This will be success on options `not_to_include` and fail `to_include`*
554+
*Result : This will be success on options `not_to_contain` and fail `to_contain`*
555555

556556

557557

558558
Example usage
559559

560560
```sql
561-
create or replace package example_include is
562-
--%suite(Include test)
561+
create or replace package example_contain is
562+
--%suite(Contain test)
563563

564-
--%test( Cursor include data from another cursor)
565-
procedure cursor_to_include;
564+
--%test( Cursor contains data from another cursor)
565+
procedure cursor_to_contain;
566566

567-
--%test( Cursor include data from another cursor)
568-
procedure cursor_not_to_include;
567+
--%test( Cursor contains data from another cursor)
568+
procedure cursor_not_to_contain;
569569

570-
--%test( Cursor fail include)
571-
procedure cursor_fail_include;
570+
--%test( Cursor fail on to_contain)
571+
procedure cursor_fail_contain;
572572

573-
--%test( Cursor fail not include)
574-
procedure cursor_fail_not_include;
573+
--%test( Cursor fail not_to_contain)
574+
procedure cursor_fail_not_contain;
575575
end;
576576
/
577577

578-
create or replace package body example_include is
578+
create or replace package body example_contain is
579579

580-
procedure cursor_to_include is
580+
procedure cursor_to_contain is
581581
l_actual SYS_REFCURSOR;
582582
l_expected SYS_REFCURSOR;
583583
begin
@@ -594,10 +594,10 @@ create or replace package body example_include is
594594
select 'c' as name from dual;
595595

596596
--Act
597-
ut.expect(l_actual).to_include(l_expected);
597+
ut.expect(l_actual).to_contain(l_expected);
598598
end;
599599

600-
procedure cursor_not_to_include is
600+
procedure cursor_not_to_contain is
601601
l_actual SYS_REFCURSOR;
602602
l_expected SYS_REFCURSOR;
603603
begin
@@ -613,10 +613,10 @@ create or replace package body example_include is
613613
select 'f' as name from dual;
614614

615615
--Act
616-
ut.expect(l_actual).not_to_include(l_expected);
616+
ut.expect(l_actual).not_to_contain(l_expected);
617617
end;
618618

619-
procedure cursor_fail_include is
619+
procedure cursor_fail_contain is
620620
l_actual SYS_REFCURSOR;
621621
l_expected SYS_REFCURSOR;
622622
begin
@@ -632,10 +632,10 @@ create or replace package body example_include is
632632
select 'e' as name from dual;
633633

634634
--Act
635-
ut.expect(l_actual).to_include(l_expected);
635+
ut.expect(l_actual).to_contain(l_expected);
636636
end;
637637

638-
procedure cursor_fail_not_include is
638+
procedure cursor_fail_not_contain is
639639
l_actual SYS_REFCURSOR;
640640
l_expected SYS_REFCURSOR;
641641
begin
@@ -651,7 +651,7 @@ create or replace package body example_include is
651651
select 'e' as name from dual;
652652

653653
--Act
654-
ut.expect(l_actual).not_to_include(l_expected);
654+
ut.expect(l_actual).not_to_contain(l_expected);
655655
end;
656656
end;
657657
/
@@ -660,26 +660,30 @@ end;
660660

661661

662662
Above execution will provide results as follow:
663+
Cursor contains data from another cursor
664+
Cursor contains data from another cursor
665+
Cursor fail on to_contain
666+
Cursor fail not_to_contain
663667

664668
```sql
665-
Include test
666-
Cursor include data from another cursor [.045 sec]
667-
Cursor include data from another cursor [.039 sec]
668-
Cursor fail include [.046 sec] (FAILED - 1)
669-
Cursor fail not include [.043 sec] (FAILED - 2)
669+
Contain test
670+
Cursor contains data from another cursor [.045 sec]
671+
Cursor contains data from another cursor [.039 sec]
672+
Cursor fail on to_contain [.046 sec] (FAILED - 1)
673+
Cursor fail not_to_contain [.043 sec] (FAILED - 2)
670674

671675
Failures:
672676

673-
1) cursor_fail_include
674-
Actual: refcursor [ count = 3 ] was expected to include: refcursor [ count = 3 ]
677+
1) cursor_fail_contain
678+
Actual: refcursor [ count = 3 ] was expected to contain: refcursor [ count = 3 ]
675679
Diff:
676680
Rows: [ 2 differences ]
677681
Missing: <ROW><NAME>d</NAME></ROW>
678682
Missing: <ROW><NAME>e</NAME></ROW>
679-
at "UT3.EXAMPLE_INCLUDE.CURSOR_FAIL_INCLUDE", line 71 ut.expect(l_actual).to_include(l_expected);
683+
at "UT3.EXAMPLE_CONTAIN.CURSOR_FAIL_CONTAIN", line 71 ut.expect(l_actual).to_contain(l_expected);
680684

681685

682-
2) cursor_fail_not_include
686+
2) cursor_fail_not_contain
683687
Actual: (refcursor [ count = 3 ])
684688
Data-types:
685689
<ROW><NAME xml_valid_name="NAME">CHAR</NAME>
@@ -688,15 +692,15 @@ Failures:
688692
<ROW><NAME>a</NAME></ROW>
689693
<ROW><NAME>b</NAME></ROW>
690694
<ROW><NAME>c</NAME></ROW>
691-
was expected not to include:(refcursor [ count = 3 ])
695+
was expected not to contain:(refcursor [ count = 3 ])
692696
Data-types:
693697
<ROW><NAME xml_valid_name="NAME">CHAR</NAME>
694698
</ROW>
695699
Data:
696700
<ROW><NAME>a</NAME></ROW>
697701
<ROW><NAME>d</NAME></ROW>
698702
<ROW><NAME>e</NAME></ROW>
699-
at "UT3.EXAMPLE_INCLUDE.CURSOR_FAIL_NOT_INCLUDE", line 94 ut.expect(l_actual).not_to_include(l_expected);
703+
at "UT3.EXAMPLE_CONTAIN.CURSOR_FAIL_NOT_CONTAIN", line 94 ut.expect(l_actual).not_to_contain(l_expected);
700704
```
701705

702706

@@ -1161,7 +1165,7 @@ The matrix below illustrates the data types supported by different matchers.
11611165
| **be_less_than** | | | | X | X | X | X | X | | X | X | | | |
11621166
| **be_between** | | | | X | X | X | X | X | X | X | X | | | |
11631167
| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
1164-
| **include / contain** | | | | | | | | | | | | X | X | X |
1168+
| **contain** | | | | | | | | | | | | X | X | X |
11651169
| **match** | | | X | | | | | | X | | | | | |
11661170
| **be_like** | | | X | | | | | | X | | | | | |
11671171
| **be_empty** | X | | X | | | | | | | | | X | X | |

source/api/contain.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
create synonym contain for ut_include;
1+
create synonym contain for ut_contain;

source/api/include.syn

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/create_synonyms_and_grants_for_public.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ create public synonym be_like for &&ut3_owner..be_like;
124124
create public synonym be_not_null for &&ut3_owner..be_not_null;
125125
create public synonym be_null for &&ut3_owner..be_null;
126126
create public synonym be_true for &&ut3_owner..be_true;
127-
create public synonym contain for &&ut3_owner..include;
127+
create public synonym contain for &&ut3_owner..contain;
128128
create public synonym equal for &&ut3_owner..equal;
129129
create public synonym have_count for &&ut3_owner..have_count;
130-
create public synonym include for &&ut3_owner..include;
131130
create public synonym match for &&ut3_owner..match;
132131

133132
create public synonym ut for &&ut3_owner..ut;

source/create_user_synonyms.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ create or replace synonym &ut3_user..be_like for &&ut3_owner..be_like;
6868
create or replace synonym &ut3_user..be_not_null for &&ut3_owner..be_not_null;
6969
create or replace synonym &ut3_user..be_null for &&ut3_owner..be_null;
7070
create or replace synonym &ut3_user..be_true for &&ut3_owner..be_true;
71+
create or replace synonym &ut3_user..contain for &&ut3_owner..contain;
7172
create or replace synonym &ut3_user..equal for &&ut3_owner..equal;
7273
create or replace synonym &ut3_user..have_count for &&ut3_owner..have_count;
7374
create or replace synonym &ut3_user..match for &&ut3_owner..match;

source/expectations/matchers/ut_include.tpb renamed to source/expectations/matchers/ut_contain.tpb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace type body ut_include as
1+
create or replace type body ut_contain as
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2018 utPLSQL Project
@@ -16,14 +16,14 @@ create or replace type body ut_include as
1616
limitations under the License.
1717
*/
1818

19-
constructor function ut_include(self in out nocopy ut_include, a_expected sys_refcursor) return self as result is
19+
constructor function ut_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result is
2020
begin
2121
self.init(ut_data_value_refcursor(a_expected), null, $$plsql_unit);
2222
self.options.unordered();
2323
return;
2424
end;
2525

26-
overriding member function run_matcher(self in out nocopy ut_include, a_actual ut_data_value) return boolean is
26+
overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is
2727
l_result boolean;
2828
begin
2929
if self.expected.data_type = a_actual.data_type then
@@ -38,7 +38,7 @@ create or replace type body ut_include as
3838
return l_result;
3939
end;
4040

41-
overriding member function run_matcher_negated(self in out nocopy ut_include, a_actual ut_data_value) return boolean is
41+
overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is
4242
begin
4343
return run_matcher(a_actual);
4444
end;

source/expectations/matchers/ut_include.tps renamed to source/expectations/matchers/ut_contain.tps

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace type ut_include under ut_equal(
1+
create or replace type ut_contain under ut_equal(
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2018 utPLSQL Project
@@ -23,9 +23,9 @@ create or replace type ut_include under ut_equal(
2323
* that false include not necessary mean true not include.
2424
*/
2525

26-
constructor function ut_include(self in out nocopy ut_include, a_expected sys_refcursor) return self as result,
27-
overriding member function run_matcher(self in out nocopy ut_include, a_actual ut_data_value) return boolean,
28-
overriding member function run_matcher_negated(self in out nocopy ut_include, a_actual ut_data_value) return boolean,
26+
constructor function ut_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result,
27+
overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean,
28+
overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean,
2929
overriding member function failure_message(a_actual ut_data_value) return varchar2,
3030
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
3131
)

0 commit comments

Comments
 (0)