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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "any_data"]
path = lib/any_data
url = https://github.com/jgebal/any_data.git
branch = 1.0.4
branch = master
2 changes: 2 additions & 0 deletions .travis/create_utplsql_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ create user &ut3_user identified by &ut3_password default tablespace &ut3_tables

grant create session, create procedure, create type, create table to &ut3_user;

grant execute on sys.dbms_crypto to &ut3_user;

exit success
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changes are welcome from all members of the Community.
* Each of the steps below are detailed in the [How to Fork](https://help.github.com/articles/fork-a-repo) article!
* Clone your Fork to your local machine.
* Configure "upstream" remote to the [master utPLSQL repository](https://github.com/utPLSQL/utPLSQL.git).
* Update the git submodules by issuing command: [git submodule update --remote --merge](http://stackoverflow.com/a/21195182)
3. For each change you want to make:
* Create a new branch for your change.
* Make your change in your new branch.
Expand Down
2 changes: 1 addition & 1 deletion lib/any_data
Submodule any_data updated 37 files
+1 −1 VERSION.sql
+30 −27 sources/converter/any_data_builder.pkb
+2 −2 sources/converter/any_data_typecode_mapper.pkb
+2 −2 sources/converter/any_data_typecode_mapper.pks
+6 −1 sources/converter/any_type_mapper.tpb
+20 −12 sources/core/any_data.tpb
+7 −4 sources/core/any_data.tps
+2 −0 sources/core/any_data_interval_ds.tpb
+2 −0 sources/core/any_data_interval_ym.tpb
+3 −10 sources/core/compound/any_data_attribute.tpb
+1 −4 sources/core/compound/any_data_attribute.tps
+3 −3 sources/core/compound/any_data_collection.tpb
+26 −11 sources/core/compound/any_data_family_compound.tpb
+1 −2 sources/core/compound/any_data_family_compound.tps
+4 −4 sources/core/compound/any_data_object.tpb
+2 −2 sources/core/compound/any_data_result_row.tpb
+2 −2 sources/core/compound/any_data_result_set.tpb
+2 −0 sources/core/date/any_data_date.tpb
+2 −0 sources/core/date/any_data_timestamp.tpb
+2 −0 sources/core/date/any_data_timestamp_ltz.tpb
+2 −0 sources/core/date/any_data_timestamp_tz.tpb
+2 −0 sources/core/numeric/any_data_bdouble.tpb
+2 −0 sources/core/numeric/any_data_bfloat.tpb
+2 −0 sources/core/numeric/any_data_number.tpb
+4 −0 sources/core/raw/any_data_blob.tpb
+2 −0 sources/core/raw/any_data_raw.tpb
+7 −1 sources/core/string/any_data_char.tpb
+3 −1 sources/core/string/any_data_char.tps
+4 −0 sources/core/string/any_data_clob.tpb
+2 −0 sources/core/string/any_data_varchar.tpb
+2 −0 sources/core/string/any_data_varchar2.tpb
+1 −1 sources/helpers/any_data_const.pks
+57 −18 sources/test.sql
+29 −0 spec/any_data/is_null_spec.rb
+11 −12 spec/any_data/scalar_constructors_spec.rb
+22 −22 spec/any_data_builder/build_from_anydata_spec.rb
+2 −0 support/create_user.sql
111 changes: 111 additions & 0 deletions source/ut_assert.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,116 @@ create or replace package body ut_assert is
build_assert_result(a_condition, 'this', 'boolean', 'boolean', ut_utils.to_string(true), ut_utils.to_string(a_condition), ut_utils.to_string(a_msg));
end;

procedure is_null(a_actual in number) is
begin
is_null(null, a_actual);
end;

procedure is_null(a_msg in varchar2, a_actual in number) is
begin
build_assert_result((a_actual is null), 'is_null', 'number', 'number', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;

procedure is_null(a_actual in varchar2) is
begin
is_null(null, a_actual);
end;

procedure is_null(a_msg in varchar2, a_actual in varchar2) is
begin
build_assert_result((a_actual is null), 'is_null', 'varchar2', 'varchar2', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;


procedure is_null(a_actual in date) is
begin
is_null(null, a_actual);
end;


procedure is_null(a_msg in varchar2, a_actual in date) is
begin
build_assert_result((a_actual is null), 'is_null', 'date', 'date', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;


procedure is_null(a_actual in timestamp_unconstrained) is
begin
is_null(null, a_actual);
end;


procedure is_null(a_msg in varchar2, a_actual in timestamp_unconstrained) is
begin
build_assert_result((a_actual is null), 'is_null', 'timestamp', 'timestamp', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;


procedure is_null(a_actual in anydata) is
begin
is_null(null, a_actual);
end;


procedure is_null(a_msg in varchar2, a_actual in anydata) is
l_actual any_data;
begin
l_actual := any_data_builder.build(a_actual);
build_assert_result( l_actual.is_null(), 'is_null', l_actual.type_name, l_actual.type_name, 'NULL', ut_utils.to_string(l_actual.to_string()), ut_utils.to_string(a_msg));
end;

procedure is_not_null(a_actual in number) is
begin
is_not_null(null, a_actual);
end;

procedure is_not_null(a_msg in varchar2, a_actual in number) is
begin
build_assert_result((a_actual is not null), 'is_not_null', 'number', 'number', 'NOT NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;

procedure is_not_null(a_actual in varchar2) is
begin
is_not_null(null, a_actual);
end;

procedure is_not_null(a_msg in varchar2, a_actual in varchar2) is
begin
build_assert_result((a_actual is not null), 'is_not_null', 'varchar2', 'varchar2', 'NOT NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;

procedure is_not_null(a_actual in date) is
begin
is_not_null(null, a_actual);
end;

procedure is_not_null(a_msg in varchar2, a_actual in date) is
begin
build_assert_result((a_actual is not null), 'is_not_null', 'date', 'date', 'NOT NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;

procedure is_not_null(a_actual in timestamp_unconstrained) is
begin
is_not_null(null, a_actual);
end;

procedure is_not_null(a_msg in varchar2, a_actual in timestamp_unconstrained) is
begin
build_assert_result((a_actual is not null), 'is_not_null', 'timestamp', 'timestamp', 'NOT NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
end;

procedure is_not_null(a_actual in anydata) is
begin
is_not_null(null, a_actual);
end;

procedure is_not_null(a_msg in varchar2, a_actual in anydata) is
l_actual any_data;
begin
l_actual := any_data_builder.build(a_actual);
build_assert_result( not l_actual.is_null(), 'is_not_null', l_actual.type_name, l_actual.type_name, 'NOT NULL', ut_utils.to_string(l_actual.to_string()), ut_utils.to_string(a_msg));
end;


end ut_assert;
/
30 changes: 30 additions & 0 deletions source/ut_assert.pks
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,35 @@ create or replace package ut_assert authid current_user as
procedure this(a_condition in boolean);
procedure this(a_msg in varchar2, a_condition in boolean);

procedure is_null(a_actual in number);
procedure is_null(a_msg in varchar2, a_actual in number);

procedure is_null(a_actual in varchar2);
procedure is_null(a_msg in varchar2, a_actual in varchar2);

procedure is_null(a_actual in date);
procedure is_null(a_msg in varchar2, a_actual in date);

procedure is_null(a_actual in timestamp_unconstrained);
procedure is_null(a_msg in varchar2, a_actual in timestamp_unconstrained);

procedure is_null(a_actual in anydata);
procedure is_null(a_msg in varchar2, a_actual in anydata);

procedure is_not_null(a_actual in number);
procedure is_not_null(a_msg in varchar2, a_actual in number);

procedure is_not_null(a_actual in varchar2);
procedure is_not_null(a_msg in varchar2, a_actual in varchar2);

procedure is_not_null(a_actual in date);
procedure is_not_null(a_msg in varchar2, a_actual in date);

procedure is_not_null(a_actual in timestamp_unconstrained);
procedure is_not_null(a_msg in varchar2, a_actual in timestamp_unconstrained);

procedure is_not_null(a_actual in anydata);
procedure is_not_null(a_msg in varchar2, a_actual in anydata);

end ut_assert;
/
9 changes: 9 additions & 0 deletions tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ set serveroutput on size unlimited format truncated

@@lib/RunTest.sql ut_assert/ut_assert.are_equal.scalar.FailsToExecuteWhenNullsPassedAsParameters.sql

@@lib/RunTest.sql ut_assert/ut_assert.is_not_null.date.GivesFailureForNullValue.sql
@@lib/RunTest.sql ut_assert/ut_assert.is_not_null.date.GivesSuccessForNotNullValue.sql

@@lib/RunTest.sql ut_assert/ut_assert.is_null.anydata.GivesFailureWhenDataIsNotNull.sql
@@lib/RunTest.sql ut_assert/ut_assert.is_null.anydata.GivesSuccessWhenDataIsNull.sql

@@lib/RunTest.sql ut_assert/ut_assert.is_null.date.GivesFailureForNotNullValue.sql
@@lib/RunTest.sql ut_assert/ut_assert.is_null.date.GivesSuccessForNullValue.sql

@@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql
@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigNumber.sql
@@lib/RunTest.sql ut_utils/ut_utils.to_string.Date.sql
Expand Down
16 changes: 16 additions & 0 deletions tests/ut_assert/common/ut_assert.null.scalar.common.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--Arrange
declare
l_actual &&1 := &&2;
l_result integer;
begin
--Act
ut_assert.&&3(l_actual);
l_result := ut_assert.get_aggregate_asserts_result();
--Assert
if l_result = &&4 then
:test_result := ut_utils.tr_success;
else
dbms_output.put_line('expected: '''||&&4||''', got: '''||l_result||'''' );
end if;
end;
/
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ begin
l_assert_result := treat(ut_assert.get_asserts_results()(1) as ut_assert_result);

--Assert
if l_assert_result.expected_value_string like q'[%department(%dept_name => 'HR'%)%]'
and l_assert_result.actual_value_string like q'[%department(%dept_name => 'IT'%)%]'
if l_assert_result.expected_value_string like q'[%DEPARTMENT(%dept_name => 'HR'%)%]'
and l_assert_result.actual_value_string like q'[%DEPARTMENT(%dept_name => 'IT'%)%]'
then
:test_result := ut_utils.tr_success;
else
dbms_output.put_line( 'assert_result.message does not contain the objects' );
dbms_output.put_line( l_assert_result.expected_value_string );
dbms_output.put_line( l_assert_result.actual_value_string );
end if;
end;
/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROMPT Gives a failure when date value is null

@@ut_assert/common/ut_assert.null.scalar.common.sql 'date' 'null' 'is_not_null' 'ut_utils.tr_failure'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROMPT Gives a success when date value is not null

@@ut_assert/common/ut_assert.null.scalar.common.sql 'date' 'sysdate' 'is_not_null' 'ut_utils.tr_success'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PROMPT Gives a falure when oracle object is not null
--Arrange
create or replace type department as object(
dept_name varchar2(30)
);
/

declare
l_actual department := department('IT');
l_result integer;
begin
--Act
ut_assert.is_null( anydata.convertObject(l_actual) );
l_result := ut_assert.get_aggregate_asserts_result();
--Assert
if l_result = ut_utils.tr_failure then
:test_result := ut_utils.tr_success;
else
dbms_output.put_line('expected: '''||ut_utils.tr_failure||''', got: '''||l_result||'''' );
end if;
end;
/

--Cleanup
drop type department;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PROMPT Gives a success when oracle object is null
--Arrange
create or replace type department as object(
dept_name varchar2(30)
);
/

declare
l_actual department;
l_result integer;
begin
--Act
ut_assert.is_null( anydata.convertObject(l_actual) );
l_result := ut_assert.get_aggregate_asserts_result();
--Assert
if l_result = ut_utils.tr_success then
:test_result := ut_utils.tr_success;
else
dbms_output.put_line('expected: '''||ut_utils.tr_success||''', got: '''||l_result||'''' );
end if;
end;
/

--Cleanup
drop type department;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROMPT Gives a failure when date value is not null

@@ut_assert/common/ut_assert.null.scalar.common.sql 'date' 'sysdate' 'is_null' 'ut_utils.tr_failure'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROMPT Gives a success when date value is null

@@ut_assert/common/ut_assert.null.scalar.common.sql 'date' 'null' 'is_null' 'ut_utils.tr_success'