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

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
First code corrections
  • Loading branch information
lwasylow committed Jun 14, 2020
commit a660208acc592faee891a4ca22e7835fdca4224c
18 changes: 1 addition & 17 deletions docs/userguide/expectations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1126,22 +1126,6 @@ end;

**Example 3.**
```sql
begin
ut.expect(sysdate).to_be_within_pct(interval '1' day).of_(sysdate + 1);
end;
/
```

**Example 4.**
```sql
begin
ut.expect(sysdate).to_be_within_pct(interval '1' month).of_(add_months(sysdate,1));
end;
/
```

**Example 5.**
```sql
begin
ut.expect(3).to_be_within(1).of_(5);
end;
Expand All @@ -1158,7 +1142,7 @@ Failures:
at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5
```

**Example 6.**
**Example 4.**
```sql
begin
ut.expect(sysdate).to_be_within(interval '1' day).of_(sysdate+2);
Expand Down
18 changes: 4 additions & 14 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -887,25 +887,18 @@ create or replace package body ut_utils is
l_result := case
when l_day = 1 then l_day ||' day'
when l_day > 1 then l_day ||' days'
else null
end;
l_result := l_result ||
end ||
case
when l_hour = 1 then ' '|| l_hour ||' hour'
when l_hour > 1 then ' '|| l_hour ||' hours'
else null
end;
l_result := l_result ||
end ||
case
when l_minute = 1 then ' '||l_minute ||' minute'
when l_minute > 1 then ' '||l_minute ||' minutes'
else null
end;
l_result := l_result ||
end ||
case
when l_second = 1 then ' '||l_second ||' second'
when l_second > 1 then ' '||l_second ||' seconds'
else null
end;
return trim(leading ' ' from l_result);
end;
Expand All @@ -918,13 +911,10 @@ create or replace package body ut_utils is
l_result := case
when l_year = 1 then l_year ||' year'
when l_year > 1 then l_year ||' years'
else null
end;
l_result := l_result ||
end ||
case
when l_month = 1 then ' '||l_month ||' month'
when l_month > 1 then ' '||l_month ||' months'
else null
end;
return trim(leading ' ' from l_result);
end;
Expand Down
3 changes: 3 additions & 0 deletions source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ create or replace package ut_utils authid definer is
*/
function interval_to_text(a_interval dsinterval_unconstrained) return varchar2;

/*
* Return value of interval in plain english
*/
function interval_to_text(a_interval yminterval_unconstrained) return varchar2;

end ut_utils;
Expand Down
52 changes: 26 additions & 26 deletions source/expectations/matchers/ut_be_within.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ create or replace type body ut_be_within as
limitations under the License.
*/

member procedure init(self in out nocopy ut_be_within, a_dist ut_data_value, a_is_pct number , a_self_type varchar2 := null) is
member procedure init(self in out nocopy ut_be_within, a_distance_from_expected ut_data_value, a_is_pct number , a_self_type varchar2 := null) is
begin
self.dist := a_dist;
self.distance_from_expected := a_distance_from_expected;
self.is_pct := nvl(a_is_pct,0);
self.self_type := nvl( a_self_type, $$plsql_unit );
end;

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

constructor function ut_be_within(self in out nocopy ut_be_within, a_dist dsinterval_unconstrained, a_is_pct number) return self as result is
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained, a_is_pct number) return self as result is
begin
init(ut_data_value_dsinterval(a_dist),a_is_pct);
init(ut_data_value_dsinterval(a_distance_from_expected),a_is_pct);
return;
end;

constructor function ut_be_within(self in out nocopy ut_be_within, a_dist yminterval_unconstrained, a_is_pct number) return self as result is
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained, a_is_pct number) return self as result is
begin
init(ut_data_value_yminterval(a_dist),a_is_pct);
init(ut_data_value_yminterval(a_distance_from_expected),a_is_pct);
return;
end;

Expand All @@ -61,24 +61,24 @@ create or replace type body ut_be_within as
if self.expected.data_type = a_actual.data_type then
if self.expected is of (ut_data_value_number) and self.is_pct = 0 then
l_result := abs((treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value)) <=
treat(self.dist as ut_data_value_number).data_value;
treat(self.distance_from_expected as ut_data_value_number).data_value;
elsif self.expected is of (ut_data_value_number) and self.is_pct = 1 then
l_result := treat(self.dist 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)) ;
elsif self.expected is of (ut_data_value_date) and self.dist is of ( ut_data_value_yminterval) then
elsif self.expected is of (ut_data_value_date) and self.distance_from_expected is of ( ut_data_value_yminterval) then
l_result := treat(a_actual as ut_data_value_date).data_value
between
(treat(self.expected as ut_data_value_date).data_value) - treat(self.dist as ut_data_value_yminterval).data_value
(treat(self.expected as ut_data_value_date).data_value) - treat(self.distance_from_expected as ut_data_value_yminterval).data_value
and
(treat(self.expected as ut_data_value_date).data_value) + treat(self.dist as ut_data_value_yminterval).data_value;
elsif self.expected is of (ut_data_value_date) and self.dist is of ( ut_data_value_dsinterval) then
(treat(self.expected as ut_data_value_date).data_value) + treat(self.distance_from_expected as ut_data_value_yminterval).data_value;
elsif self.expected is of (ut_data_value_date) and self.distance_from_expected is of ( ut_data_value_dsinterval) then
l_result := treat(a_actual as ut_data_value_date).data_value
between
(treat(self.expected as ut_data_value_date).data_value) - treat(self.dist as ut_data_value_dsinterval).data_value
(treat(self.expected as ut_data_value_date).data_value) - treat(self.distance_from_expected as ut_data_value_dsinterval).data_value
and
(treat(self.expected as ut_data_value_date).data_value) + treat(self.dist as ut_data_value_dsinterval).data_value;
(treat(self.expected as ut_data_value_date).data_value) + treat(self.distance_from_expected as ut_data_value_dsinterval).data_value;
end if;
else
l_result := (self as ut_matcher).run_matcher(a_actual);
Expand All @@ -87,20 +87,20 @@ create or replace type body ut_be_within as
end;

overriding member function failure_message(a_actual ut_data_value) return varchar2 is
l_distance varchar2(32767);
l_distance_from_expected varchar2(32767);
begin
l_distance := case
when self.dist is of (ut_data_value_number) then
treat(self.dist as ut_data_value_number).to_string
when self.dist is of (ut_data_value_yminterval) then
treat(self.dist as ut_data_value_yminterval).to_string
when self.dist is of (ut_data_value_dsinterval) then
treat(self.dist as ut_data_value_dsinterval).to_string
l_distance_from_expected := case
when self.distance_from_expected is of (ut_data_value_number) then
treat(self.distance_from_expected as ut_data_value_number).to_string
when self.distance_from_expected is of (ut_data_value_yminterval) then
treat(self.distance_from_expected as ut_data_value_yminterval).to_string
when self.distance_from_expected is of (ut_data_value_dsinterval) then
treat(self.distance_from_expected as ut_data_value_dsinterval).to_string
else
null
end;

return (self as ut_matcher).failure_message(a_actual) || ' '||l_distance ||' of '|| expected.to_string_report();
return (self as ut_matcher).failure_message(a_actual) || ' '||l_distance_from_expected ||' of '|| expected.to_string_report();
end;

overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
Expand All @@ -110,4 +110,4 @@ create or replace type body ut_be_within as
end;

end;
/
/
12 changes: 6 additions & 6 deletions source/expectations/matchers/ut_be_within.tps
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ create or replace type ut_be_within under ut_comparison_matcher(
/**
* Holds information about mather options
*/
dist ut_data_value,
distance_from_expected ut_data_value,
is_pct number(1,0),

member procedure init(self in out nocopy ut_be_within, a_dist ut_data_value, a_is_pct number , a_self_type varchar2 := null),
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist number, a_is_pct number) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist dsinterval_unconstrained, a_is_pct number) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist yminterval_unconstrained, a_is_pct number) return self as result,
member procedure init(self in out nocopy ut_be_within, a_distance_from_expected ut_data_value, a_is_pct number , a_self_type varchar2 := null),
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected number, a_is_pct number) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained, a_is_pct number) return self as result,
constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained, a_is_pct number) 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),

Expand All @@ -35,4 +35,4 @@ create or replace type ut_be_within under ut_comparison_matcher(
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
)
not final
/
/
2 changes: 1 addition & 1 deletion source/expectations/matchers/ut_matcher_base.tps
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ create or replace type ut_matcher_base force authid current_user as object(
self_type varchar2(250)
)
not final not instantiable
/
/
2 changes: 1 addition & 1 deletion source/expectations/ut_expectation_base.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ create or replace type body ut_expectation_base as
ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
end;
end;
/
/
4 changes: 2 additions & 2 deletions source/expectations/ut_expectation_base.tps
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ create or replace type ut_expectation_base force authid current_user as object(
--base matcher executors
member procedure to_(self in ut_expectation_base, a_matcher ut_matcher_base),
member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base)
) not final
/
) not final not instantiable
/