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

Skip to content

Commit a660208

Browse files
committed
First code corrections
1 parent 9ee0e75 commit a660208

8 files changed

Lines changed: 44 additions & 67 deletions

File tree

docs/userguide/expectations.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,22 +1126,6 @@ end;
11261126
11271127
**Example 3.**
11281128
```sql
1129-
begin
1130-
ut.expect(sysdate).to_be_within_pct(interval '1' day).of_(sysdate + 1);
1131-
end;
1132-
/
1133-
```
1134-
1135-
**Example 4.**
1136-
```sql
1137-
begin
1138-
ut.expect(sysdate).to_be_within_pct(interval '1' month).of_(add_months(sysdate,1));
1139-
end;
1140-
/
1141-
```
1142-
1143-
**Example 5.**
1144-
```sql
11451129
begin
11461130
ut.expect(3).to_be_within(1).of_(5);
11471131
end;
@@ -1158,7 +1142,7 @@ Failures:
11581142
at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5
11591143
```
11601144
1161-
**Example 6.**
1145+
**Example 4.**
11621146
```sql
11631147
begin
11641148
ut.expect(sysdate).to_be_within(interval '1' day).of_(sysdate+2);

source/core/ut_utils.pkb

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -887,25 +887,18 @@ create or replace package body ut_utils is
887887
l_result := case
888888
when l_day = 1 then l_day ||' day'
889889
when l_day > 1 then l_day ||' days'
890-
else null
891-
end;
892-
l_result := l_result ||
890+
end ||
893891
case
894892
when l_hour = 1 then ' '|| l_hour ||' hour'
895893
when l_hour > 1 then ' '|| l_hour ||' hours'
896-
else null
897-
end;
898-
l_result := l_result ||
894+
end ||
899895
case
900896
when l_minute = 1 then ' '||l_minute ||' minute'
901897
when l_minute > 1 then ' '||l_minute ||' minutes'
902-
else null
903-
end;
904-
l_result := l_result ||
898+
end ||
905899
case
906900
when l_second = 1 then ' '||l_second ||' second'
907901
when l_second > 1 then ' '||l_second ||' seconds'
908-
else null
909902
end;
910903
return trim(leading ' ' from l_result);
911904
end;
@@ -918,13 +911,10 @@ create or replace package body ut_utils is
918911
l_result := case
919912
when l_year = 1 then l_year ||' year'
920913
when l_year > 1 then l_year ||' years'
921-
else null
922-
end;
923-
l_result := l_result ||
914+
end ||
924915
case
925916
when l_month = 1 then ' '||l_month ||' month'
926917
when l_month > 1 then ' '||l_month ||' months'
927-
else null
928918
end;
929919
return trim(leading ' ' from l_result);
930920
end;

source/core/ut_utils.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ create or replace package ut_utils authid definer is
440440
*/
441441
function interval_to_text(a_interval dsinterval_unconstrained) return varchar2;
442442

443+
/*
444+
* Return value of interval in plain english
445+
*/
443446
function interval_to_text(a_interval yminterval_unconstrained) return varchar2;
444447

445448
end ut_utils;

source/expectations/matchers/ut_be_within.tpb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ create or replace type body ut_be_within as
1616
limitations under the License.
1717
*/
1818

19-
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
19+
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
2020
begin
21-
self.dist := a_dist;
21+
self.distance_from_expected := a_distance_from_expected;
2222
self.is_pct := nvl(a_is_pct,0);
2323
self.self_type := nvl( a_self_type, $$plsql_unit );
2424
end;
2525

26-
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist number, a_is_pct number) return self as result is
26+
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
2727
begin
28-
init(ut_data_value_number(a_dist),a_is_pct);
28+
init(ut_data_value_number(a_distance_from_expected),a_is_pct);
2929
return;
3030
end;
3131

32-
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
32+
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
3333
begin
34-
init(ut_data_value_dsinterval(a_dist),a_is_pct);
34+
init(ut_data_value_dsinterval(a_distance_from_expected),a_is_pct);
3535
return;
3636
end;
3737

38-
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
38+
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
3939
begin
40-
init(ut_data_value_yminterval(a_dist),a_is_pct);
40+
init(ut_data_value_yminterval(a_distance_from_expected),a_is_pct);
4141
return;
4242
end;
4343

@@ -61,24 +61,24 @@ create or replace type body ut_be_within as
6161
if self.expected.data_type = a_actual.data_type then
6262
if self.expected is of (ut_data_value_number) and self.is_pct = 0 then
6363
l_result := abs((treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value)) <=
64-
treat(self.dist as ut_data_value_number).data_value;
64+
treat(self.distance_from_expected as ut_data_value_number).data_value;
6565
elsif self.expected is of (ut_data_value_number) and self.is_pct = 1 then
66-
l_result := treat(self.dist as ut_data_value_number).data_value >=
66+
l_result := treat(self.distance_from_expected as ut_data_value_number).data_value >=
6767
(
6868
((treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value ) * 100 ) /
6969
(treat(self.expected as ut_data_value_number).data_value)) ;
70-
elsif self.expected is of (ut_data_value_date) and self.dist is of ( ut_data_value_yminterval) then
70+
elsif self.expected is of (ut_data_value_date) and self.distance_from_expected is of ( ut_data_value_yminterval) then
7171
l_result := treat(a_actual as ut_data_value_date).data_value
7272
between
73-
(treat(self.expected as ut_data_value_date).data_value) - treat(self.dist as ut_data_value_yminterval).data_value
73+
(treat(self.expected as ut_data_value_date).data_value) - treat(self.distance_from_expected as ut_data_value_yminterval).data_value
7474
and
75-
(treat(self.expected as ut_data_value_date).data_value) + treat(self.dist as ut_data_value_yminterval).data_value;
76-
elsif self.expected is of (ut_data_value_date) and self.dist is of ( ut_data_value_dsinterval) then
75+
(treat(self.expected as ut_data_value_date).data_value) + treat(self.distance_from_expected as ut_data_value_yminterval).data_value;
76+
elsif self.expected is of (ut_data_value_date) and self.distance_from_expected is of ( ut_data_value_dsinterval) then
7777
l_result := treat(a_actual as ut_data_value_date).data_value
7878
between
79-
(treat(self.expected as ut_data_value_date).data_value) - treat(self.dist as ut_data_value_dsinterval).data_value
79+
(treat(self.expected as ut_data_value_date).data_value) - treat(self.distance_from_expected as ut_data_value_dsinterval).data_value
8080
and
81-
(treat(self.expected as ut_data_value_date).data_value) + treat(self.dist as ut_data_value_dsinterval).data_value;
81+
(treat(self.expected as ut_data_value_date).data_value) + treat(self.distance_from_expected as ut_data_value_dsinterval).data_value;
8282
end if;
8383
else
8484
l_result := (self as ut_matcher).run_matcher(a_actual);
@@ -87,20 +87,20 @@ create or replace type body ut_be_within as
8787
end;
8888

8989
overriding member function failure_message(a_actual ut_data_value) return varchar2 is
90-
l_distance varchar2(32767);
90+
l_distance_from_expected varchar2(32767);
9191
begin
92-
l_distance := case
93-
when self.dist is of (ut_data_value_number) then
94-
treat(self.dist as ut_data_value_number).to_string
95-
when self.dist is of (ut_data_value_yminterval) then
96-
treat(self.dist as ut_data_value_yminterval).to_string
97-
when self.dist is of (ut_data_value_dsinterval) then
98-
treat(self.dist as ut_data_value_dsinterval).to_string
92+
l_distance_from_expected := case
93+
when self.distance_from_expected is of (ut_data_value_number) then
94+
treat(self.distance_from_expected as ut_data_value_number).to_string
95+
when self.distance_from_expected is of (ut_data_value_yminterval) then
96+
treat(self.distance_from_expected as ut_data_value_yminterval).to_string
97+
when self.distance_from_expected is of (ut_data_value_dsinterval) then
98+
treat(self.distance_from_expected as ut_data_value_dsinterval).to_string
9999
else
100100
null
101101
end;
102102

103-
return (self as ut_matcher).failure_message(a_actual) || ' '||l_distance ||' of '|| expected.to_string_report();
103+
return (self as ut_matcher).failure_message(a_actual) || ' '||l_distance_from_expected ||' of '|| expected.to_string_report();
104104
end;
105105

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

112112
end;
113-
/
113+
/

source/expectations/matchers/ut_be_within.tps

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ create or replace type ut_be_within under ut_comparison_matcher(
2020
/**
2121
* Holds information about mather options
2222
*/
23-
dist ut_data_value,
23+
distance_from_expected ut_data_value,
2424
is_pct number(1,0),
2525

26-
member procedure init(self in out nocopy ut_be_within, a_dist ut_data_value, a_is_pct number , a_self_type varchar2 := null),
27-
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist number, a_is_pct number) return self as result,
28-
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist dsinterval_unconstrained, a_is_pct number) return self as result,
29-
constructor function ut_be_within(self in out nocopy ut_be_within, a_dist yminterval_unconstrained, a_is_pct number) return self as result,
26+
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),
27+
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,
28+
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,
29+
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,
3030
member procedure of_(self in ut_be_within, a_expected number),
3131
member procedure of_(self in ut_be_within, a_expected date),
3232

@@ -35,4 +35,4 @@ create or replace type ut_be_within under ut_comparison_matcher(
3535
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2
3636
)
3737
not final
38-
/
38+
/

source/expectations/matchers/ut_matcher_base.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ create or replace type ut_matcher_base force authid current_user as object(
22
self_type varchar2(250)
33
)
44
not final not instantiable
5-
/
5+
/

source/expectations/ut_expectation_base.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ create or replace type body ut_expectation_base as
4141
ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
4242
end;
4343
end;
44-
/
44+
/

source/expectations/ut_expectation_base.tps

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ create or replace type ut_expectation_base force authid current_user as object(
2121
--base matcher executors
2222
member procedure to_(self in ut_expectation_base, a_matcher ut_matcher_base),
2323
member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base)
24-
) not final
25-
/
24+
) not final not instantiable
25+
/

0 commit comments

Comments
 (0)