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

Skip to content

Commit e9f0cb1

Browse files
committed
Implemented be_between for varchars
fixed mistakes on logging corrected prompts
1 parent 8c1afa2 commit e9f0cb1

11 files changed

Lines changed: 45 additions & 19 deletions

source/expectations/matchers/be_between.tpb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ create or replace type body be_between is
2020
init(ut_data_value_number(a_lower_bound), ut_data_value_number(a_upper_bound));
2121
return;
2222
end;
23+
constructor function be_between(self in out nocopy be_between, a_lower_bound varchar2, a_upper_bound varchar2)
24+
return self as result is
25+
begin
26+
init(ut_data_value_varchar2(a_lower_bound), ut_data_value_varchar2(a_upper_bound));
27+
return;
28+
end;
2329
constructor function be_between(self in out nocopy be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)
2430
return self as result is
2531
begin
@@ -58,6 +64,14 @@ create or replace type body be_between is
5864
begin
5965
l_result := l_actual.datavalue between l_lower.datavalue and l_upper.datavalue;
6066
end;
67+
elsif self.lower_bound is of(ut_data_value_varchar2) and self.lower_bound is of(ut_data_value_varchar2) and a_actual is of(ut_data_value_varchar2) then
68+
declare
69+
l_lower ut_data_value_varchar2 := treat(self.lower_bound as ut_data_value_varchar2);
70+
l_upper ut_data_value_varchar2 := treat(self.upper_bound as ut_data_value_varchar2);
71+
l_actual ut_data_value_varchar2 := treat(a_actual as ut_data_value_varchar2);
72+
begin
73+
l_result := l_actual.datavalue between l_lower.datavalue and l_upper.datavalue;
74+
end;
6175
elsif self.lower_bound is of(ut_data_value_timestamp) and self.lower_bound is of(ut_data_value_timestamp) and a_actual is of(ut_data_value_timestamp) then
6276
declare
6377
l_lower ut_data_value_timestamp := treat(self.lower_bound as ut_data_value_timestamp);

source/expectations/matchers/be_between.tps

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ create or replace type be_between under ut_matcher
99
return self as result,
1010
constructor function be_between(self in out nocopy be_between, a_lower_bound number, a_upper_bound number)
1111
return self as result,
12+
constructor function be_between(self in out nocopy be_between, a_lower_bound varchar2, a_upper_bound varchar2)
13+
return self as result,
1214
constructor function be_between(self in out nocopy be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)
1315
return self as result,
1416
constructor function be_between(self in out nocopy be_between, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained)

source/expectations/ut_expectation_number.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ create or replace type body ut_expectation_number as
88

99
member procedure to_be_between(self in ut_expectation_number, a_lower_bound number, a_higher_bound number) is
1010
begin
11-
ut_utils.debug_log('ut_expectation_date.to_be_between(self in ut_expectation_date, a_lower_bound number, a_higher_bound number)');
11+
ut_utils.debug_log('ut_expectation_number.to_be_between(self in ut_expectation_date, a_lower_bound number, a_higher_bound number)');
1212
self.to_( be_between(a_lower_bound,a_higher_bound) );
1313
end;
1414

source/expectations/ut_expectation_timestamp.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ create or replace type body ut_expectation_timestamp as
88

99
member procedure to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_higher_bound timestamp_unconstrained) is
1010
begin
11-
ut_utils.debug_log('ut_expectation_date.to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_higher_bound timestamp_unconstrained)');
11+
ut_utils.debug_log('ut_expectation_timestamp.to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_higher_bound timestamp_unconstrained)');
1212
self.to_( be_between(a_lower_bound, a_higher_bound) );
1313
end;
1414

source/expectations/ut_expectation_timestamp_ltz.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ create or replace type body ut_expectation_timestamp_ltz as
88

99
member procedure to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_higher_bound timestamp_ltz_unconstrained) is
1010
begin
11-
ut_utils.debug_log('ut_expectation_date.to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_higher_bound timestamp_ltz_unconstrained)');
11+
ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_higher_bound timestamp_ltz_unconstrained)');
1212
self.to_( be_between(a_lower_bound, a_higher_bound) );
1313
end;
1414

source/expectations/ut_expectation_timestamp_tz.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ create or replace type body ut_expectation_timestamp_tz as
88

99
member procedure to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_higher_bound timestamp_tz_unconstrained) is
1010
begin
11-
ut_utils.debug_log('ut_expectation_date.to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_higher_bound timestamp_tz_unconstrained)');
11+
ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_higher_bound timestamp_tz_unconstrained)');
1212
self.to_( be_between(a_lower_bound, a_higher_bound) );
1313
end;
1414

source/expectations/ut_expectation_varchar2.tpb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ create or replace type body ut_expectation_varchar2 as
55
ut_utils.debug_log('ut_expectation_varchar2.to_equal(self in ut_expectation, a_expected varchar2)');
66
self.to_( equal(a_expected, a_nulls_are_equal) );
77
end;
8+
9+
member procedure to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_higher_bound varchar2) is
10+
begin
11+
ut_utils.debug_log('ut_expectation_varchar2.to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_higher_bound varchar2)');
12+
self.to_( be_between(a_lower_bound,a_higher_bound) );
13+
end;
814

915
member procedure to_be_like(self in ut_expectation_varchar2, a_mask in varchar2, a_escape_char in varchar2 := null) is
1016
begin

source/expectations/ut_expectation_varchar2.tps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
create or replace type ut_expectation_varchar2 under ut_expectation
22
(
33
overriding member procedure to_equal(self in ut_expectation_varchar2, a_expected varchar2, a_nulls_are_equal boolean := null),
4+
member procedure to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_higher_bound varchar2),
45
member procedure to_be_like(self in ut_expectation_varchar2, a_mask in varchar2, a_escape_char in varchar2 := null),
56
member procedure to_match(self in ut_expectation_varchar2, a_pattern in varchar2, a_modifiers in varchar2 := null)
67
)

tests/asssertions/common/ut.expect.to_be_between.scalar.different_types.common.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ begin
99
ut.expect(l_actual).to_be_between(l_expected_1,l_expected_2);
1010
l_result := ut_assert_processor.get_aggregate_asserts_result();
1111
--Assert
12-
if nvl(:test_result, ut_utils.tr_success) = ut_utils.tr_success and l_result = ut_utils.tr_success then
12+
if nvl(:test_result, ut_utils.tr_success) = ut_utils.tr_success and l_result = &&6 then
1313
:test_result := ut_utils.tr_success;
1414
else
15-
dbms_output.put_line('expected: '''||ut_utils.tr_success||''', got: '''||l_result||'''' );
15+
dbms_output.put_line('expected: '''||&&6||''', got: '''||l_result||'''' );
1616
end if;
1717
end;
1818
/
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
PROMPT Gives failure when expected are numbers and and actual is varchar
2-
@@asssertions/common/ut.expect.to_be_between.scalar.different_types.common.sql 'varchar2(4000)' 'number' '''1''' '0' '2'
1+
PROMPT Gives success when expected are numbers and and actual is varchar
2+
@@asssertions/common/ut.expect.to_be_between.scalar.different_types.common.sql 'varchar2(4000)' 'number' '''1''' '0' '2' 'ut_utils.tr_success'
33

4-
PROMPT Gives failure when expected are varchars and and actual is number
5-
@@asssertions/common/ut.expect.to_be_between.scalar.different_types.common.sql 'number' 'varchar2(4000)' '1' '''0''' '''2'''
4+
PROMPT Gives success when expected are varchars and and actual is number
5+
@@asssertions/common/ut.expect.to_be_between.scalar.different_types.common.sql 'number' 'varchar2(4000)' '1' '''0''' '''2''' 'ut_utils.tr_success'

0 commit comments

Comments
 (0)