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

Skip to content

Commit 9000d46

Browse files
author
Pablo Roldán Ruíz
committed
Corrected tests and non supported types
1 parent 60002f2 commit 9000d46

3 files changed

Lines changed: 27 additions & 23 deletions

File tree

source/expectations/matchers/ut_be_empty.tpb

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,38 @@ create or replace type body ut_be_empty as
3030
overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is
3131
l_result boolean;
3232
begin
33-
if a_actual is of (ut_data_value_refcursor) then
34-
declare
35-
l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor);
33+
if a_actual is of(ut_data_value_refcursor) then
34+
declare
35+
l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor);
3636
begin
3737
if l_actual.data_value is not null then
3838
l_result := l_actual.is_empty;
3939
else
4040
l_result := false;
4141
end if;
4242
end;
43-
elsif a_actual is of (ut_data_value_anydata) then
43+
elsif a_actual is of(ut_data_value_anydata) then
4444
declare
45-
l_actual ut_data_value_anydata := treat(a_actual as ut_data_value_anydata);
46-
l_type_name VARCHAR2(61);
47-
l_type anytype;
48-
begin
49-
if a_actual.is_null() then
50-
l_result := false;
51-
elsif l_actual.data_value.gettype(l_type) in (dbms_types.typecode_varray,dbms_types.typecode_table,dbms_types.typecode_namedcollection) THEN
52-
ut_assert_processor.set_xml_nls_params();
53-
l_type_name := l_actual.data_value.gettypename();
54-
l_Type_name := substr(l_type_name,instr(l_type_name,'.')+1);
55-
l_result := xmltype(l_actual.data_value).getclobval() = '</'||l_type_name||'>';
56-
ut_assert_processor.reset_nls_params();
57-
ELSE
45+
l_actual ut_data_value_anydata := treat(a_actual as ut_data_value_anydata);
46+
l_type_name varchar2(61);
47+
l_type anytype;
48+
begin
49+
if l_actual.data_value.gettype(l_type) in
50+
(dbms_types.typecode_varray, dbms_types.typecode_table, dbms_types.typecode_namedcollection) then
51+
if a_actual.is_null() then
52+
l_result := false;
53+
else
54+
ut_assert_processor.set_xml_nls_params();
55+
l_type_name := l_actual.data_value.gettypename();
56+
l_type_name := substr(l_type_name, instr(l_type_name, '.') + 1);
57+
l_result := xmltype(l_actual.data_value).getclobval() = '<' || l_type_name || '/>';
58+
ut_assert_processor.reset_nls_params();
59+
end if;
60+
else
5861
ut_utils.debug_log('Failure - ut_be_empty.run_matcher can only be used with collections and cursors');
5962
self.error_message := 'The matcher can only be used with collections and cursors';
60-
end if;
63+
l_result := null;
64+
end if;
6165
end;
6266
else
6367
l_result := (self as ut_matcher).run_matcher(a_actual);

tests/RunAll.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ create table ut$test_table (val varchar2(1));
7878
@@ut_matchers/greater_than.sql
7979
@@ut_matchers/less_or_equal.sql
8080
@@ut_matchers/less_than.sql
81+
@@ut_matchers/be_empty.sql
8182

8283
@@lib/RunTest.sql ut_matchers/timestamp_between.sql
8384
@@lib/RunTest.sql ut_matchers/timestamp_ltz_between.sql
@@ -173,7 +174,6 @@ create table ut$test_table (val varchar2(1));
173174
@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigVarchar2.sql
174175
@@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql
175176

176-
@@ut_matchers/be_empty.sql
177177

178178
--Global cleanup
179179
drop package ut_example_tests;

tests/ut_matchers/be_empty.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt()' 'ut_utils.tr_success'"
88
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt(''a'')' 'ut_utils.tr_failure'"
99

10-
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.not_be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt()' 'ut_utils.tr_success'"
11-
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.not_be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt(''a'')' 'ut_utils.tr_failure'"
10+
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.not_be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt()' 'ut_utils.tr_failure'"
11+
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.collection.not_be_empty.sql 'ora_mining_varchar2_nt' 'ora_mining_varchar2_nt(''a'')' 'ut_utils.tr_success'"
1212

13-
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.be_empty.sql 'varchar2(1)' '''a''' 'ConvertVarchar' 'ut_utils.tr_failure'"
14-
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.not_be_empty.sql 'number' 'NULL' 'ConvertNumber' 'ut_utils.tr_failure'"
13+
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.be_empty.sql 'ut_data_value_number' 'ut_data_value_number(1)' 'ConvertObject' 'ut_utils.tr_failure'"
14+
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.not_be_empty.sql 'ut_data_value_varchar2' 'NULL' 'ConvertObject' 'ut_utils.tr_failure'"

0 commit comments

Comments
 (0)