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

Skip to content

Commit 271b268

Browse files
committed
Merge remote-tracking branch 'remotes/jgebal/version3' into feature/additional_asserts
# Conflicts: # tests/RunAll.sql
2 parents 77f1296 + 36a7871 commit 271b268

16 files changed

Lines changed: 246 additions & 14 deletions

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "any_data"]
22
path = lib/any_data
33
url = https://github.com/jgebal/any_data.git
4-
branch = 1.0.4
4+
branch = master

.travis/create_utplsql_user.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ create user &ut3_user identified by &ut3_password default tablespace &ut3_tables
1313

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

16+
grant execute on sys.dbms_crypto to &ut3_user;
17+
1618
exit success

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Changes are welcome from all members of the Community.
1010
* Each of the steps below are detailed in the [How to Fork](https://help.github.com/articles/fork-a-repo) article!
1111
* Clone your Fork to your local machine.
1212
* Configure "upstream" remote to the [master utPLSQL repository](https://github.com/utPLSQL/utPLSQL.git).
13+
* Update the git submodules by issuing command: [git submodule update --remote --merge](http://stackoverflow.com/a/21195182)
1314
3. For each change you want to make:
1415
* Create a new branch for your change.
1516
* Make your change in your new branch.

source/ut_assert.pkb

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,116 @@ create or replace package body ut_assert is
177177
is_matching(null, a_checking_string, a_pattern, a_modifier);
178178
end;
179179

180+
procedure is_null(a_actual in number) is
181+
begin
182+
is_null(null, a_actual);
183+
end;
184+
185+
procedure is_null(a_msg in varchar2, a_actual in number) is
186+
begin
187+
build_assert_result((a_actual is null), 'is_null', 'number', 'number', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
188+
end;
189+
190+
procedure is_null(a_actual in varchar2) is
191+
begin
192+
is_null(null, a_actual);
193+
end;
194+
195+
procedure is_null(a_msg in varchar2, a_actual in varchar2) is
196+
begin
197+
build_assert_result((a_actual is null), 'is_null', 'varchar2', 'varchar2', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
198+
end;
199+
200+
201+
procedure is_null(a_actual in date) is
202+
begin
203+
is_null(null, a_actual);
204+
end;
205+
206+
207+
procedure is_null(a_msg in varchar2, a_actual in date) is
208+
begin
209+
build_assert_result((a_actual is null), 'is_null', 'date', 'date', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
210+
end;
211+
212+
213+
procedure is_null(a_actual in timestamp_unconstrained) is
214+
begin
215+
is_null(null, a_actual);
216+
end;
217+
218+
219+
procedure is_null(a_msg in varchar2, a_actual in timestamp_unconstrained) is
220+
begin
221+
build_assert_result((a_actual is null), 'is_null', 'timestamp', 'timestamp', 'NULL', ut_utils.to_string(a_actual), ut_utils.to_string(a_msg));
222+
end;
223+
224+
225+
procedure is_null(a_actual in anydata) is
226+
begin
227+
is_null(null, a_actual);
228+
end;
229+
230+
231+
procedure is_null(a_msg in varchar2, a_actual in anydata) is
232+
l_actual any_data;
233+
begin
234+
l_actual := any_data_builder.build(a_actual);
235+
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));
236+
end;
237+
238+
procedure is_not_null(a_actual in number) is
239+
begin
240+
is_not_null(null, a_actual);
241+
end;
242+
243+
procedure is_not_null(a_msg in varchar2, a_actual in number) is
244+
begin
245+
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));
246+
end;
247+
248+
procedure is_not_null(a_actual in varchar2) is
249+
begin
250+
is_not_null(null, a_actual);
251+
end;
252+
253+
procedure is_not_null(a_msg in varchar2, a_actual in varchar2) is
254+
begin
255+
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));
256+
end;
257+
258+
procedure is_not_null(a_actual in date) is
259+
begin
260+
is_not_null(null, a_actual);
261+
end;
262+
263+
procedure is_not_null(a_msg in varchar2, a_actual in date) is
264+
begin
265+
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));
266+
end;
267+
268+
procedure is_not_null(a_actual in timestamp_unconstrained) is
269+
begin
270+
is_not_null(null, a_actual);
271+
end;
272+
273+
procedure is_not_null(a_msg in varchar2, a_actual in timestamp_unconstrained) is
274+
begin
275+
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));
276+
end;
277+
278+
procedure is_not_null(a_actual in anydata) is
279+
begin
280+
is_not_null(null, a_actual);
281+
end;
282+
283+
procedure is_not_null(a_msg in varchar2, a_actual in anydata) is
284+
l_actual any_data;
285+
begin
286+
l_actual := any_data_builder.build(a_actual);
287+
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));
288+
end;
289+
290+
180291
end ut_assert;
181292
/

source/ut_assert.pks

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,35 @@ create or replace package ut_assert authid current_user as
3636
procedure is_matching(a_msg in varchar2, a_checking_string in varchar2,a_pattern in varchar2, a_modifier in varchar2 default null);
3737
procedure is_matching(a_checking_string in varchar2,a_pattern in varchar2, a_modifier in varchar2 default null);
3838

39+
procedure is_null(a_msg in varchar2, a_actual in number);
40+
procedure is_null(a_actual in number);
41+
42+
procedure is_null(a_msg in varchar2, a_actual in varchar2);
43+
procedure is_null(a_actual in varchar2);
44+
45+
procedure is_null(a_msg in varchar2, a_actual in date);
46+
procedure is_null(a_actual in date);
47+
48+
procedure is_null(a_msg in varchar2, a_actual in timestamp_unconstrained);
49+
procedure is_null(a_actual in timestamp_unconstrained);
50+
51+
procedure is_null(a_msg in varchar2, a_actual in anydata);
52+
procedure is_null(a_actual in anydata);
53+
54+
procedure is_not_null(a_msg in varchar2, a_actual in number);
55+
procedure is_not_null(a_actual in number);
56+
57+
procedure is_not_null(a_msg in varchar2, a_actual in varchar2);
58+
procedure is_not_null(a_actual in varchar2);
59+
60+
procedure is_not_null(a_msg in varchar2, a_actual in date);
61+
procedure is_not_null(a_actual in date);
62+
63+
procedure is_not_null(a_msg in varchar2, a_actual in timestamp_unconstrained);
64+
procedure is_not_null(a_actual in timestamp_unconstrained);
65+
66+
procedure is_not_null(a_msg in varchar2, a_actual in anydata);
67+
procedure is_not_null(a_actual in anydata);
68+
3969
end ut_assert;
4070
/

source/ut_suite_manager.pkb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,12 @@ create or replace package body ut_suite_manager is
257257

258258
end config_schema;
259259

260-
procedure run_schema_suites(a_owner_name varchar2, a_reporter in out nocopy ut_reporter) is
260+
procedure run_schema_suites(a_owner_name varchar2, a_reporter in out nocopy ut_reporter, a_force_parse_again boolean default false) is
261261
l_ind varchar2(4000 char);
262262
l_suite ut_test_suite;
263263
begin
264-
if not g_schema_suites.exists(a_owner_name) or g_schema_suites(a_owner_name).count = 0 then
264+
if not g_schema_suites.exists(a_owner_name) or g_schema_suites(a_owner_name).count = 0 or
265+
nvl(a_force_parse_again, false) then
265266
config_schema(a_owner_name);
266267
end if;
267268

@@ -280,19 +281,19 @@ create or replace package body ut_suite_manager is
280281

281282
end run_schema_suites;
282283

283-
procedure run_schema_suites_static(a_owner_name varchar2, a_reporter in ut_reporter) is
284+
procedure run_schema_suites_static(a_owner_name varchar2, a_reporter in ut_reporter, a_force_parse_again boolean default false) is
284285
l_temp_reported ut_reporter;
285286
begin
286287
l_temp_reported := a_reporter;
287288
run_schema_suites(a_owner_name, l_temp_reported);
288289
end run_schema_suites_static;
289290

290-
procedure run_cur_schema_suites(a_reporter in out nocopy ut_reporter) is
291+
procedure run_cur_schema_suites(a_reporter in out nocopy ut_reporter, a_force_parse_again boolean default false) is
291292
begin
292293
run_schema_suites(sys_context('userenv', 'current_schema'), a_reporter);
293294
end run_cur_schema_suites;
294295

295-
procedure run_cur_schema_suites_static(a_reporter in ut_reporter) is
296+
procedure run_cur_schema_suites_static(a_reporter in ut_reporter, a_force_parse_again boolean default false) is
296297
l_temp_reported ut_reporter;
297298
begin
298299
l_temp_reported := a_reporter;

source/ut_suite_manager.pks

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ create or replace package ut_suite_manager is
44

55
procedure config_schema(a_owner_name varchar2);
66

7-
procedure run_schema_suites(a_owner_name varchar2, a_reporter in out nocopy ut_reporter);
7+
procedure run_schema_suites(a_owner_name varchar2, a_reporter in out nocopy ut_reporter, a_force_parse_again boolean default false);
88

9-
procedure run_schema_suites_static(a_owner_name varchar2, a_reporter in ut_reporter);
9+
procedure run_schema_suites_static(a_owner_name varchar2, a_reporter in ut_reporter, a_force_parse_again boolean default false);
1010

11-
procedure run_cur_schema_suites(a_reporter in out nocopy ut_reporter);
11+
procedure run_cur_schema_suites(a_reporter in out nocopy ut_reporter, a_force_parse_again boolean default false);
1212

13-
procedure run_cur_schema_suites_static(a_reporter in ut_reporter);
13+
procedure run_cur_schema_suites_static(a_reporter in ut_reporter, a_force_parse_again boolean default false);
1414

1515
end ut_suite_manager;
1616
/

tests/RunAll.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ set serveroutput on size unlimited format truncated
7171

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

74+
@@lib/RunTest.sql ut_assert/ut_assert.is_not_null.date.GivesFailureForNullValue.sql
75+
@@lib/RunTest.sql ut_assert/ut_assert.is_not_null.date.GivesSuccessForNotNullValue.sql
76+
77+
@@lib/RunTest.sql ut_assert/ut_assert.is_null.anydata.GivesFailureWhenDataIsNotNull.sql
78+
@@lib/RunTest.sql ut_assert/ut_assert.is_null.anydata.GivesSuccessWhenDataIsNull.sql
79+
80+
@@lib/RunTest.sql ut_assert/ut_assert.is_null.date.GivesFailureForNotNullValue.sql
81+
@@lib/RunTest.sql ut_assert/ut_assert.is_null.date.GivesSuccessForNullValue.sql
82+
7483
@@lib/RunTest.sql ut_assert/ut_assert.is_like.GivesSuccessForLikeString.sql
7584
@@lib/RunTest.sql ut_assert/ut_assert.is_like.GivesSuccessForLikeStringWithEscape.sql
7685
@@lib/RunTest.sql ut_assert/ut_assert.is_like.GivesFailureForLikeString.sql
@@ -79,7 +88,6 @@ set serveroutput on size unlimited format truncated
7988
@@lib/RunTest.sql ut_assert/ut_assert.is_matching.GivesSuccessForMatchingStringWithModifier.sql
8089
@@lib/RunTest.sql ut_assert/ut_assert.is_matching.GivesFailureForMatchingString.sql
8190

82-
8391
@@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql
8492
@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigNumber.sql
8593
@@lib/RunTest.sql ut_utils/ut_utils.to_string.Date.sql
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--Arrange
2+
declare
3+
l_actual &&1 := &&2;
4+
l_result integer;
5+
begin
6+
--Act
7+
ut_assert.&&3(l_actual);
8+
l_result := ut_assert.get_aggregate_asserts_result();
9+
--Assert
10+
if l_result = &&4 then
11+
:test_result := ut_utils.tr_success;
12+
else
13+
dbms_output.put_line('expected: '''||&&4||''', got: '''||l_result||'''' );
14+
end if;
15+
end;
16+
/

tests/ut_assert/ut_assert.are_equal.anydata.PutsObjectStrucureIntoAssert.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ begin
1717
l_assert_result := treat(ut_assert.get_asserts_results()(1) as ut_assert_result);
1818

1919
--Assert
20-
if l_assert_result.expected_value_string like q'[%department(%dept_name => 'HR'%)%]'
21-
and l_assert_result.actual_value_string like q'[%department(%dept_name => 'IT'%)%]'
20+
if l_assert_result.expected_value_string like q'[%DEPARTMENT(%dept_name => 'HR'%)%]'
21+
and l_assert_result.actual_value_string like q'[%DEPARTMENT(%dept_name => 'IT'%)%]'
2222
then
2323
:test_result := ut_utils.tr_success;
2424
else
25-
dbms_output.put_line( 'assert_result.message does not contain the objects' );
25+
dbms_output.put_line( l_assert_result.expected_value_string );
26+
dbms_output.put_line( l_assert_result.actual_value_string );
2627
end if;
2728
end;
2829
/

0 commit comments

Comments
 (0)