Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
48abf1a
Initial checkin
lwasylow Jun 1, 2020
7041912
added expectation
lwasylow Jun 2, 2020
13d86b6
Adding more methods
lwasylow Jun 2, 2020
caeeb30
Adding contain and not contain
lwasylow Jun 2, 2020
8ff4f6b
Adding code and tests,.
lwasylow Jun 6, 2020
89cb0bc
Fixingtoo long names
lwasylow Jun 6, 2020
a5481ac
fixing issue
lwasylow Jun 6, 2020
9ee0e75
Update documentation and tests
lwasylow Jun 7, 2020
a660208
First code corrections
lwasylow Jun 14, 2020
ada1ea4
Resolving another comment
lwasylow Jun 14, 2020
fe1b0cb
Updating issues
lwasylow Jun 14, 2020
013db74
Update tble
lwasylow Jun 14, 2020
b5c73b4
Separated into two different matchers
jgebal Jun 19, 2020
2e721da
CHECKPOINT
lwasylow Jun 19, 2020
fbc0f26
Merge branch 'feature/rework_matcher' of https://github.com/utPLSQL/u…
lwasylow Jun 19, 2020
f182430
Update uninstall
lwasylow Jun 19, 2020
e3fb2d7
Update progress
lwasylow Jun 19, 2020
322e0a1
Making code a bit more readable
lwasylow Jun 19, 2020
ff15596
Added tests for `be_within_pct`
jgebal Jun 20, 2020
3cae9a2
Fixed test issue
jgebal Jun 20, 2020
22549db
Fixed stacktrace for failed expectations on chained matchers.
jgebal Jun 21, 2020
1d771a5
Update timestamps
lwasylow Jun 25, 2020
363c333
Fixed and simplified matcher
jgebal Jun 27, 2020
0ea8925
Fixed native dynamic SQL types compatibility for 11g
jgebal Jun 28, 2020
7c01afb
Fixed native dynamic SQL types compatibility for 11g
jgebal Jun 28, 2020
66d92fc
Merge branch 'develop' into feature/rework_matcher
jgebal Jan 28, 2022
590fb38
Improving test stability (flaky tests)
jgebal Jan 28, 2022
5e2642a
Removing reference to ut3_develop schema.
jgebal Jan 28, 2022
ed06e33
Relaxed sql-injection check to work with 11g2
jgebal Jan 28, 2022
38f3cbc
Fixed issues with comparison of dates&timestamps using interval year-…
jgebal Jan 30, 2022
86e84c8
Improving code coverage.
jgebal Jan 31, 2022
718ac0d
Improved test stability.
jgebal Jan 31, 2022
6dbef20
Fixing build process to build using develop branch as testing framewo…
jgebal Jan 31, 2022
25b55b4
Improving test coverage.
jgebal Jan 31, 2022
5b5a5c0
Improving matcher documentation
jgebal Jan 31, 2022
7fec0f9
Added tests for 0 value of actual and expected and actual greater tha…
jgebal Feb 2, 2022
fd7ef9c
Fixed issues with precission of distance. `NATURAL` is a subtype of i…
jgebal Feb 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added tests for be_within_pct
Reorganized code so that `be_within_pct` is only supported for `number`
Added tests for non-supported syntax
  • Loading branch information
jgebal committed Jun 20, 2020
commit ff15596a7c8c3b907136ea2e83bb52f33dff00ca
1 change: 1 addition & 0 deletions source/api/be_within_pct.syn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create synonym be_within_pct for ut_be_within_pct;
1 change: 1 addition & 0 deletions source/core/ut_expectation_processor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ create or replace package body ut_expectation_processor as
);
end;
begin
-- dbms_output.put_line(a_call_stack);
l_call_stack := cut_header_and_expectations( a_call_stack );
l_call_stack := cut_address_columns( l_call_stack );
l_call_stack := cut_framework_stack( l_call_stack );
Expand Down
1 change: 1 addition & 0 deletions source/create_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ grant execute on &&ut3_owner..ut_be_not_null to &ut3_user;
grant execute on &&ut3_owner..ut_be_null to &ut3_user;
grant execute on &&ut3_owner..ut_be_true to &ut3_user;
grant execute on &&ut3_owner..ut_be_within to &ut3_user;
grant execute on &&ut3_owner..ut_be_within_pct to &ut3_user;
grant execute on &&ut3_owner..ut_contain to &ut3_user;
grant execute on &&ut3_owner..ut_equal to &ut3_user;
grant execute on &&ut3_owner..ut_have_count to &ut3_user;
Expand Down
1 change: 1 addition & 0 deletions source/create_synonyms.sql
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ create &action_type. synonym &ut3_user.be_not_null for &&ut3_owner..be_not_null;
create &action_type. synonym &ut3_user.be_null for &&ut3_owner..be_null;
create &action_type. synonym &ut3_user.be_true for &&ut3_owner..be_true;
create &action_type. synonym &ut3_user.be_within for &&ut3_owner..be_within;
create &action_type. synonym &ut3_user.be_within_pct for &&ut3_owner..be_within_pct;
create &action_type. synonym &ut3_user.contain for &&ut3_owner..contain;
create &action_type. synonym &ut3_user.equal for &&ut3_owner..equal;
create &action_type. synonym &ut3_user.have_count for &&ut3_owner..have_count;
Expand Down
43 changes: 9 additions & 34 deletions source/expectations/matchers/ut_be_within.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,24 @@ create or replace type body ut_be_within as
limitations under the License.
*/

member procedure init(self in out nocopy ut_be_within, a_distance_from_expected ut_data_value) is
begin
self.distance_from_expected := a_distance_from_expected;
self.self_type := $$plsql_unit;
end;

constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result is
begin
init(ut_data_value_number(a_distance_from_expected));
self.init(ut_data_value_number(a_distance_from_expected), $$plsql_unit);
return;
end;

constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result is
begin
init(ut_data_value_dsinterval(a_distance_from_expected));
self.init(ut_data_value_dsinterval(a_distance_from_expected), $$plsql_unit);
return;
end;

constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result is
begin
init(ut_data_value_yminterval(a_distance_from_expected));
self.init(ut_data_value_yminterval(a_distance_from_expected), $$plsql_unit);
return;
end;

member procedure of_(self in ut_be_within, a_expected number) is
l_result ut_be_within := self;
begin
l_result.expected := ut_data_value_number(a_expected);
if l_result.is_negated_flag = 1 then
l_result.expectation.not_to(l_result );
else
l_result.expectation.to_(l_result );
end if;
end;

member procedure of_(self in ut_be_within, a_expected date) is
l_result ut_be_within := self;
begin
Expand All @@ -62,13 +45,6 @@ create or replace type body ut_be_within as
end if;
end;

member function of_(self in ut_be_within, a_expected number) return ut_be_within is
l_result ut_be_within := self;
begin
l_result.expected := ut_data_value_number(a_expected);
return l_result;
end;

member function of_(self in ut_be_within, a_expected date) return ut_be_within is
l_result ut_be_within := self;
begin
Expand Down Expand Up @@ -96,7 +72,7 @@ create or replace type body ut_be_within as
then treat(self.distance_from_expected as ut_data_value_dsinterval).data_value
end;
begin
return case when l_distance_ym is not null
return case when l_distance_ym is not null
then l_actual between l_expected - l_distance_ym and l_expected + l_distance_ym
else l_actual between l_expected - l_distance_ds and l_expected + l_distance_ds
end;
Expand All @@ -116,15 +92,14 @@ create or replace type body ut_be_within as
end;

overriding member function failure_message(a_actual ut_data_value) return varchar2 is
begin
begin
return (self as ut_matcher).failure_message(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report();
end;

overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
Comment thread
lwasylow marked this conversation as resolved.
l_result varchar2(32767);
begin
begin
return (self as ut_matcher).failure_message_when_negated(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report();
end;
end;

end;
/
10 changes: 1 addition & 9 deletions source/expectations/matchers/ut_be_within.tps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
create or replace type ut_be_within under ut_comparison_matcher(
create or replace type ut_be_within under ut_be_within_pct(
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Expand All @@ -17,19 +17,11 @@ create or replace type ut_be_within under ut_comparison_matcher(
*/


/**
* Holds information about mather options
*/
distance_from_expected ut_data_value,
member procedure init(self in out nocopy ut_be_within, a_distance_from_expected ut_data_value),
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result,
member procedure of_(self in ut_be_within, a_expected number),
member procedure of_(self in ut_be_within, a_expected date),
member function of_(self in ut_be_within, a_expected number) return ut_be_within,
member function of_(self in ut_be_within, a_expected date) return ut_be_within,

overriding member function run_matcher(self in out nocopy ut_be_within, a_actual ut_data_value) return boolean,
overriding member function failure_message(a_actual ut_data_value) return varchar2,
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
Expand Down
46 changes: 40 additions & 6 deletions source/expectations/matchers/ut_be_within_pct.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,61 @@ create or replace type body ut_be_within_pct as
limitations under the License.
*/

constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_distance_from_expected number) return self as result is
constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result is
begin
self.init(ut_data_value_number(a_distance_from_expected));
self.init(ut_data_value_number(a_pct_of_expected), $$plsql_unit);
return;
end;

member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2) is
begin
self.distance_from_expected := a_distance_from_expected;
self.self_type := self_type;
end;

member procedure of_(self in ut_be_within_pct, a_expected number) is
l_result ut_be_within_pct := self;
begin
l_result.expected := ut_data_value_number(a_expected);
if l_result.is_negated_flag = 1 then
l_result.expectation.not_to(l_result );
else
l_result.expectation.to_(l_result );
end if;
end;

member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct is
l_result ut_be_within_pct := self;
begin
l_result.expected := ut_data_value_number(a_expected);
return l_result;
end;

overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean is
l_result boolean;
begin
if self.expected.data_type = a_actual.data_type then
if self.expected is of (ut_data_value_number) then
l_result := treat(self.distance_from_expected as ut_data_value_number).data_value >=
(
((treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value ) * 100 ) /
(treat(self.expected as ut_data_value_number).data_value)) ;
l_result :=
treat(self.distance_from_expected as ut_data_value_number).data_value
>= ( ( treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value ) * 100 ) /
treat(self.expected as ut_data_value_number).data_value;
end if;
else
l_result := (self as ut_matcher).run_matcher(a_actual);
end if;
return l_result;
end;

overriding member function failure_message(a_actual ut_data_value) return varchar2 is
begin
return rtrim( (self as ut_matcher).failure_message(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report();
end;

overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
begin
return rtrim( (self as ut_matcher).failure_message_when_negated(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report();
end;

end;
/
16 changes: 13 additions & 3 deletions source/expectations/matchers/ut_be_within_pct.tps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
create or replace type ut_be_within_pct under ut_be_within(
create or replace type ut_be_within_pct under ut_comparison_matcher(
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Expand All @@ -17,8 +17,18 @@ create or replace type ut_be_within_pct under ut_be_within(
*/


constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_distance_from_expected number) return self as result,
overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean
/**
* Holds information about mather options
*/
distance_from_expected ut_data_value,

constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result,
member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2),
member procedure of_(self in ut_be_within_pct, a_expected number),
member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct,
overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean,
overriding member function failure_message(a_actual ut_data_value) return varchar2,
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
)
not final
/
5 changes: 3 additions & 2 deletions source/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema
@@install_component.sql 'expectations/ut_expectation_base.tps'
@@install_component.sql 'expectations/matchers/ut_matcher.tps'
@@install_component.sql 'expectations/matchers/ut_comparison_matcher.tps'
@@install_component.sql 'expectations/matchers/ut_be_within.tps'
@@install_component.sql 'expectations/matchers/ut_be_within_pct.tps'
@@install_component.sql 'expectations/matchers/ut_be_within.tps'
@@install_component.sql 'expectations/ut_expectation.tps'
@@install_component.sql 'expectations/matchers/ut_be_false.tps'
@@install_component.sql 'expectations/matchers/ut_be_greater_or_equal.tps'
Expand Down Expand Up @@ -297,8 +297,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema
@@install_component.sql 'expectations/matchers/ut_be_null.tpb'
@@install_component.sql 'expectations/matchers/ut_be_true.tpb'
@@install_component.sql 'expectations/matchers/ut_equal.tpb'
@@install_component.sql 'expectations/matchers/ut_be_within.tpb'
@@install_component.sql 'expectations/matchers/ut_be_within_pct.tpb'
@@install_component.sql 'expectations/matchers/ut_be_within.tpb'
@@install_component.sql 'expectations/matchers/ut_contain.tpb'
@@install_component.sql 'expectations/matchers/ut_have_count.tpb'
@@install_component.sql 'expectations/matchers/ut_be_between.tpb'
Expand Down Expand Up @@ -362,6 +362,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema
@@install_component.sql 'api/be_not_null.syn'
@@install_component.sql 'api/be_null.syn'
@@install_component.sql 'api/be_true.syn'
@@install_component.sql 'api/be_within_pct.syn'
@@install_component.sql 'api/be_within.syn'
@@install_component.sql 'api/equal.syn'
@@install_component.sql 'api/have_count.syn'
Expand Down
2 changes: 2 additions & 0 deletions source/uninstall_objects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ drop synonym equal;

drop synonym be_within;

drop synonym be_within_pct;

drop type ut_coveralls_reporter force;

drop type ut_coverage_sonar_reporter force;
Expand Down
2 changes: 2 additions & 0 deletions test/install_ut3_user_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ prompt Install user tests
@@ut3_user/expectations/binary/test_be_greater_or_equal.pks
@@ut3_user/expectations/binary/test_be_greater_than.pks
@@ut3_user/expectations/binary/test_to_be_within.pks
@@ut3_user/expectations/binary/test_to_be_within_pct.pks
@@ut3_user/expectations/test_matchers.pks
@@ut3_user/expectations/test_expectation_anydata.pks
@@ut3_user/expectations/test_expectations_cursor.pks
Expand Down Expand Up @@ -68,6 +69,7 @@ set define off
@@ut3_user/expectations/binary/test_be_greater_or_equal.pkb
@@ut3_user/expectations/binary/test_be_greater_than.pkb
@@ut3_user/expectations/binary/test_to_be_within.pkb
@@ut3_user/expectations/binary/test_to_be_within_pct.pkb
@@ut3_user/expectations/test_matchers.pkb
@@ut3_user/expectations/test_expectation_anydata.pkb
@@ut3_user/expectations/test_expectations_cursor.pkb
Expand Down
Loading