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
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
Corrected tests and non supported types
  • Loading branch information
Pablo Roldán Ruíz committed Feb 10, 2017
commit 9000d46498b67866381015ce3b0a46c0e7664f3b
40 changes: 22 additions & 18 deletions source/expectations/matchers/ut_be_empty.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,38 @@ create or replace type body ut_be_empty as
overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is
l_result boolean;
begin
if a_actual is of (ut_data_value_refcursor) then
declare
l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor);
if a_actual is of(ut_data_value_refcursor) then
declare
l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor);
begin
if l_actual.data_value is not null then
l_result := l_actual.is_empty;
else
l_result := false;
end if;
end;
elsif a_actual is of (ut_data_value_anydata) then
elsif a_actual is of(ut_data_value_anydata) then
declare
l_actual ut_data_value_anydata := treat(a_actual as ut_data_value_anydata);
l_type_name VARCHAR2(61);
l_type anytype;
begin
if a_actual.is_null() then
l_result := false;
elsif l_actual.data_value.gettype(l_type) in (dbms_types.typecode_varray,dbms_types.typecode_table,dbms_types.typecode_namedcollection) THEN
ut_assert_processor.set_xml_nls_params();
l_type_name := l_actual.data_value.gettypename();
l_Type_name := substr(l_type_name,instr(l_type_name,'.')+1);
l_result := xmltype(l_actual.data_value).getclobval() = '</'||l_type_name||'>';
ut_assert_processor.reset_nls_params();
ELSE
l_actual ut_data_value_anydata := treat(a_actual as ut_data_value_anydata);
l_type_name varchar2(61);
l_type anytype;
begin
if l_actual.data_value.gettype(l_type) in
(dbms_types.typecode_varray, dbms_types.typecode_table, dbms_types.typecode_namedcollection) then
if a_actual.is_null() then
l_result := false;
else
ut_assert_processor.set_xml_nls_params();
l_type_name := l_actual.data_value.gettypename();
l_type_name := substr(l_type_name, instr(l_type_name, '.') + 1);
l_result := xmltype(l_actual.data_value).getclobval() = '<' || l_type_name || '/>';
ut_assert_processor.reset_nls_params();
end if;
else
ut_utils.debug_log('Failure - ut_be_empty.run_matcher can only be used with collections and cursors');
self.error_message := 'The matcher can only be used with collections and cursors';
end if;
l_result := null;
end if;
end;
else
l_result := (self as ut_matcher).run_matcher(a_actual);
Expand Down
2 changes: 1 addition & 1 deletion tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ create table ut$test_table (val varchar2(1));
@@ut_matchers/greater_than.sql
@@ut_matchers/less_or_equal.sql
@@ut_matchers/less_than.sql
@@ut_matchers/be_empty.sql

@@lib/RunTest.sql ut_matchers/timestamp_between.sql
@@lib/RunTest.sql ut_matchers/timestamp_ltz_between.sql
Expand Down Expand Up @@ -173,7 +174,6 @@ create table ut$test_table (val varchar2(1));
@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigVarchar2.sql
@@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql

@@ut_matchers/be_empty.sql

--Global cleanup
drop package ut_example_tests;
Expand Down
8 changes: 4 additions & 4 deletions tests/ut_matchers/be_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
@@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'"
@@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'"

@@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'"
@@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'"
@@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'"
@@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'"

@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.be_empty.sql 'varchar2(1)' '''a''' 'ConvertVarchar' 'ut_utils.tr_failure'"
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.not_be_empty.sql 'number' 'NULL' 'ConvertNumber' 'ut_utils.tr_failure'"
@@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'"
@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.other.not_be_empty.sql 'ut_data_value_varchar2' 'NULL' 'ConvertObject' 'ut_utils.tr_failure'"