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

Skip to content

Commit 9fff9d0

Browse files
committed
Improved reporting on usage of incompatible matcher, when using 'to_'
1 parent 97c887f commit 9fff9d0

20 files changed

Lines changed: 47 additions & 35 deletions

examples/demo_expectations.pck

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,16 @@ create or replace package body demo_expectations is
196196
ut.expect( l_null_boolean ).to_( be_true );
197197
ut.expect( l_null_boolean ).to_( be_true() );
198198

199+
ut.expect( 'a string value' ).to_( be_true() );
200+
199201
ut.expect( true ).to_be_false;
200202
ut.expect( true ).to_( be_false );
201203
ut.expect( true ).to_( be_false() );
202204
ut.expect( l_null_boolean ).to_be_false;
203205
ut.expect( l_null_boolean ).to_( be_false );
204206
ut.expect( l_null_boolean ).to_( be_false() );
207+
208+
ut.expect( 'a string value' ).to_( be_false() );
205209
end;
206210

207211
procedure demo_to_be_true_false_success is
@@ -410,6 +414,10 @@ create or replace package body demo_expectations is
410414
ut.expect( l_clob ).to_match('^Stephen$', 'i'); --case insensitive
411415
ut.expect( l_clob ).to_( match('^Stephen$') );
412416
ut.expect( l_clob ).to_( match('^Stephen$', 'i') ); --case insensitive
417+
418+
ut.expect( sysdate ).to_( match('^Stephen$', 'i') ); --case insensitive
419+
ut.expect( 12345 ).to_( match('^Stephen$', 'i') ); --case insensitive
420+
413421
end;
414422

415423
procedure demo_to_matchl_success is

source/assertions/ut_assertion.tpb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
create or replace type body ut_assertion as
22

33
final member procedure add_assert_result( self in ut_assertion, a_assert_result boolean, a_assert_name varchar2,
4-
a_expected_value_string in varchar2 := null, a_expected_data_type varchar2 := null) is
4+
a_assert_info varchar2, a_expected_value_string in varchar2 := null, a_expected_data_type varchar2 := null) is
55
begin
66
ut_utils.debug_log('ut_assertion.add_assert_result :' || ut_utils.to_test_result(a_assert_result) || ':' || message);
77
ut_assert_processor.add_assert_result(
88
ut_assert_result(
9-
a_assert_name, ut_utils.to_test_result(a_assert_result),
9+
a_assert_name, a_assert_info, ut_utils.to_test_result(a_assert_result),
1010
a_expected_data_type, self.actual_data.type, a_expected_value_string, self.actual_data.to_string(), self.message
1111
)
1212
);
@@ -80,16 +80,17 @@ create or replace type body ut_assertion as
8080

8181
member procedure to_(self in ut_assertion, a_expectation ut_expectation) is
8282
l_assert_result boolean;
83-
l_assert_name varchar2(250);
83+
l_assert_name varchar2(4000);
84+
l_expectation ut_expectation := a_expectation;
8485
begin
8586
ut_utils.debug_log('ut_assertion.to_(self in ut_assertion, a_expectation ut_expectation)');
8687

87-
l_assert_result := a_expectation.run_expectation( self.actual_data );
88-
l_assert_name := 'to '||a_expectation.name;
89-
if a_expectation.expected is not null then
90-
add_assert_result( l_assert_result, l_assert_name, a_expectation.expected.to_string(), a_expectation.expected.type);
88+
l_assert_result := l_expectation.run_expectation( self.actual_data );
89+
l_assert_name := 'to '||l_expectation.name;
90+
if l_expectation.expected is not null then
91+
add_assert_result( l_assert_result, l_assert_name, l_expectation.additional_info, l_expectation.expected.to_string(), l_expectation.expected.type);
9192
else
92-
add_assert_result( l_assert_result, l_assert_name );
93+
add_assert_result( l_assert_result, l_assert_name, l_expectation.additional_info );
9394
end if;
9495
end;
9596

source/assertions/ut_assertion.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ create or replace type ut_assertion as object
33
actual_data ut_data_value,
44
message varchar2(4000 char),
55
final member procedure add_assert_result( self in ut_assertion, a_assert_result boolean, a_assert_name varchar2,
6-
a_expected_value_string in varchar2 := null, a_expected_data_type varchar2 := null),
6+
a_assert_info varchar2, a_expected_value_string in varchar2 := null, a_expected_data_type varchar2 := null),
77
member procedure to_equal(self in ut_assertion, a_expected anydata, a_nulls_are_equal boolean := null),
88
member procedure to_equal(self in ut_assertion, a_expected blob, a_nulls_are_equal boolean := null),
99
member procedure to_equal(self in ut_assertion, a_expected boolean, a_nulls_are_equal boolean := null),

source/expectations/be_false.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ create or replace type body be_false as
66
return;
77
end;
88

9-
overriding member function run_expectation(a_actual ut_data_value) return boolean is
9+
overriding member function run_expectation(self in out nocopy be_false, a_actual ut_data_value) return boolean is
1010
begin
1111
return
1212
case

source/expectations/be_false.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
create or replace type be_false under ut_expectation(
22
constructor function be_false(self in out nocopy be_false) return self as result,
3-
overriding member function run_expectation(a_actual ut_data_value) return boolean
3+
overriding member function run_expectation(self in out nocopy be_false, a_actual ut_data_value) return boolean
44
)
55
/

source/expectations/be_not_null.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ create or replace type body be_not_null as
66
return;
77
end;
88

9-
overriding member function run_expectation(a_actual ut_data_value) return boolean is
9+
overriding member function run_expectation(self in out nocopy be_not_null, a_actual ut_data_value) return boolean is
1010
begin
1111
return not a_actual.is_null;
1212
end;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
create or replace type be_not_null under ut_expectation(
22
constructor function be_not_null(self in out nocopy be_not_null) return self as result,
3-
overriding member function run_expectation(a_actual ut_data_value) return boolean
3+
overriding member function run_expectation(self in out nocopy be_not_null, a_actual ut_data_value) return boolean
44
)
55
/

source/expectations/be_null.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ create or replace type body be_null as
66
return;
77
end;
88

9-
overriding member function run_expectation(a_actual ut_data_value) return boolean is
9+
overriding member function run_expectation(self in out nocopy be_null, a_actual ut_data_value) return boolean is
1010
begin
1111
return a_actual.is_null;
1212
end;

source/expectations/be_null.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
create or replace type be_null under ut_expectation(
22
constructor function be_null(self in out nocopy be_null) return self as result,
3-
overriding member function run_expectation(a_actual ut_data_value) return boolean
3+
overriding member function run_expectation(self in out nocopy be_null, a_actual ut_data_value) return boolean
44
)
55
/

source/expectations/be_true.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ create or replace type body be_true as
66
return;
77
end;
88

9-
overriding member function run_expectation(a_actual ut_data_value) return boolean is
9+
overriding member function run_expectation(self in out nocopy be_true, a_actual ut_data_value) return boolean is
1010
begin
1111
return
1212
case

0 commit comments

Comments
 (0)