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

Skip to content

Commit 6193ff3

Browse files
committed
Adding negated matcher
1 parent 314b998 commit 6193ff3

6 files changed

Lines changed: 28 additions & 13 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,6 @@ create or replace package body ut_compound_data_helper is
606606
tmp';
607607
return l_sql;
608608
end;
609-
610-
function get_inclusion_matcher_not_sql(a_owner in varchar2) return varchar2 is
611-
begin
612-
null;
613-
end;
614609

615610
function get_refcursor_matcher_sql(a_owner in varchar2,a_inclusion_matcher boolean := false, a_negated_match boolean := false) return varchar2 is
616611
l_sql varchar2(32767);

source/expectations/matchers/ut_include.tpb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ create or replace type body ut_include as
3636
return true;
3737
end;
3838

39+
member function negated return ut_include is
40+
l_result ut_include := self;
41+
begin
42+
l_result.is_negated := ut_utils.boolean_to_int(true);
43+
return l_result;
44+
end;
45+
3946
overriding member function run_matcher(self in out nocopy ut_include, a_actual ut_data_value) return boolean is
4047
l_result boolean;
4148
begin
4249
if self.expected.data_type = a_actual.data_type then
43-
l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, self.get_exclude_xpath(), self.get_include_xpath(), self.get_join_by_xpath(),
44-
true,get_inclusion_compare());
50+
if nvl(self.is_negated,0) = 0 then
51+
l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, self.get_exclude_xpath(), self.get_include_xpath(), self.get_join_by_xpath(),
52+
true,get_inclusion_compare());
53+
else
54+
l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, self.get_exclude_xpath(), self.get_include_xpath(), self.get_join_by_xpath(),
55+
true,get_inclusion_compare());
56+
end if;
4557
else
4658
l_result := (self as ut_matcher).run_matcher(a_actual);
4759
end if;

source/expectations/matchers/ut_include.tps

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ create or replace type ut_include under ut_equal(
1616
limitations under the License.
1717
*/
1818

19+
/**
20+
* Due to nature of inclusion compare the not is bit diffrente than standard.
21+
* Result is false when even one element belongs which can cause overlap.
22+
* e.g. set can fail at same time not_include and include. By that we mean
23+
* that false include not necessary mean true not include.
24+
*/
25+
is_negated number(1,0),
26+
1927
member procedure init(self in out nocopy ut_include, a_expected ut_data_value),
2028
constructor function ut_include(self in out nocopy ut_include, a_expected sys_refcursor) return self as result,
2129
member function get_inclusion_compare return boolean,
30+
member function negated return ut_include,
2231
overriding member function run_matcher(self in out nocopy ut_include, a_actual ut_data_value) return boolean,
2332
overriding member function failure_message(a_actual ut_data_value) return varchar2
2433
)

source/expectations/ut_expectation.tpb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ create or replace type body ut_expectation as
3232
l_matcher ut_matcher := a_matcher;
3333
l_message varchar2(32767);
3434
begin
35-
3635
l_expectation_result := l_matcher.run_matcher_negated( self.actual_data );
3736
l_expectation_result := coalesce(l_expectation_result,false);
3837
l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) );
@@ -691,12 +690,12 @@ create or replace type body ut_expectation as
691690

692691
member procedure not_to_include(self in ut_expectation, a_expected sys_refcursor) is
693692
begin
694-
self.not_to( ut_include(a_expected) );
693+
self.not_to( ut_include(a_expected).negated );
695694
end;
696695

697696
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is
698697
begin
699-
self.not_to( ut_include(a_expected) );
698+
self.not_to( ut_include(a_expected).negated );
700699
end;
701700

702701
end;

source/expectations/ut_expectation_compound.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ create or replace type body ut_expectation_compound as
9292
member function not_to_include(a_expected sys_refcursor) return ut_expectation_compound is
9393
l_result ut_expectation_compound := self;
9494
begin
95-
l_result.matcher := ut_include(a_expected);
95+
l_result.matcher := ut_include(a_expected).negated;
9696
l_result.negated := ut_utils.boolean_to_int(true);
9797
return l_result;
9898
end;
9999

100100
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound is
101101
l_result ut_expectation_compound := self;
102102
begin
103-
l_result.matcher := ut_include(a_expected);
103+
l_result.matcher := ut_include(a_expected).negated;
104104
l_result.negated := ut_utils.boolean_to_int(true);
105105
return l_result;
106106
end;

source/expectations/ut_expectation_compound.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ create or replace type ut_expectation_compound under ut_expectation(
5151
member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list)
5252
)
5353
final
54-
/
54+
/

0 commit comments

Comments
 (0)