-
Notifications
You must be signed in to change notification settings - Fork 189
Feature/additional asserts #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…reats the installer file as command window. Added two new assertions: str_like and regexp_like Reordered declaration of the assertion procedures to enforce users to use implementation with assert description provided Added tests for the new asserts
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,37 @@ create or replace package body ut_assert is | |
| begin | ||
| 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; | ||
|
|
||
| -- Strings assertions | ||
| procedure str_like(a_msg in varchar2, a_checking_string in varchar2, a_mask in varchar, a_escape_char in varchar2) is | ||
| l_condition boolean; | ||
| begin | ||
| if a_escape_char is not null then | ||
| l_condition := a_checking_string like a_mask escape a_escape_char; | ||
| else | ||
| l_condition := a_checking_string like a_mask; | ||
| end if; | ||
| build_assert_result(l_condition, 'str_like', 'varchar2', 'varchar2', ut_utils.to_string('like ' || a_mask), ut_utils.to_string(l_condition), a_msg); | ||
| end; | ||
| procedure str_like(a_msg in varchar2, a_checking_string in varchar2, a_mask in varchar) is | ||
| begin | ||
| str_like(a_msg, a_checking_string, a_mask, null); | ||
| end; | ||
| procedure str_like(a_checking_string in varchar2, a_mask in varchar2) is | ||
| begin | ||
| str_like(a_msg => null, a_checking_string => a_checking_string, a_mask => a_mask); | ||
| end; | ||
|
|
||
| procedure regexp_like(a_msg in varchar2, a_srcstr in varchar2, a_pattern in varchar2, a_modifier in varchar2 default null) is | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you change the name of |
||
| l_condition boolean := sys.standard.regexp_like(a_srcstr, a_pattern, a_pattern); | ||
| begin | ||
| build_assert_result(l_condition, 'regexp_like', 'varchar2', 'varchar2', ut_utils.to_string('pattern ' || a_pattern), ut_utils.to_string(l_condition), a_msg); | ||
| end; | ||
|
|
||
| procedure regexp_like(a_srcstr in varchar2, a_pattern in varchar2, a_modifier in varchar2 default null) is | ||
| begin | ||
| regexp_like(null, a_srcstr, a_pattern, a_modifier); | ||
| end; | ||
|
|
||
| procedure is_null(a_actual in number) is | ||
| begin | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,27 +5,36 @@ create or replace package ut_assert authid current_user as | |
| procedure report_error(a_message in varchar2); | ||
| function get_asserts_results return ut_objects_list; | ||
|
|
||
| /* Just need something to play with for now */ | ||
| procedure are_equal(a_expected in number, a_actual in number); | ||
| -- General assertion | ||
| procedure this(a_msg in varchar2, a_condition in boolean); | ||
| procedure this(a_condition in boolean); | ||
|
|
||
| -- Equality assertions | ||
| procedure are_equal(a_msg in varchar2, a_expected in number, a_actual in number); | ||
| procedure are_equal(a_expected in number, a_actual in number); | ||
|
|
||
| procedure are_equal(a_expected in varchar2, a_actual in varchar2); | ||
| procedure are_equal(a_msg in varchar2, a_expected in varchar2, a_actual in varchar2); | ||
| procedure are_equal(a_expected in varchar2, a_actual in varchar2); | ||
|
|
||
| procedure are_equal(a_expected in date, a_actual in date); | ||
| procedure are_equal(a_msg in varchar2, a_expected in date, a_actual in date); | ||
| procedure are_equal(a_expected in date, a_actual in date); | ||
|
|
||
| procedure are_equal(a_expected in timestamp_unconstrained, a_actual in timestamp_unconstrained); | ||
| procedure are_equal(a_msg in varchar2, a_expected in timestamp_unconstrained, a_actual in timestamp_unconstrained); | ||
| procedure are_equal(a_expected in timestamp_unconstrained, a_actual in timestamp_unconstrained); | ||
|
|
||
| procedure are_equal(a_expected in anydata, a_actual in anydata); | ||
| procedure are_equal(a_msg in varchar2, a_expected in anydata, a_actual in anydata); | ||
| procedure are_equal(a_expected in anydata, a_actual in anydata); | ||
|
|
||
| procedure are_equal(a_expected in sys_refcursor, a_actual in sys_refcursor); | ||
| procedure are_equal(a_msg in varchar2, a_expected in sys_refcursor, a_actual in sys_refcursor); | ||
| procedure are_equal(a_expected in sys_refcursor, a_actual in sys_refcursor); | ||
|
|
||
| procedure this(a_condition in boolean); | ||
| procedure this(a_msg in varchar2, a_condition in boolean); | ||
| -- Strings assertions | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about. |
||
| procedure str_like(a_msg in varchar2, a_checking_string in varchar2, a_mask in varchar, a_escape_char in varchar2); | ||
| procedure str_like(a_msg in varchar2, a_checking_string in varchar2, a_mask in varchar); | ||
| procedure str_like(a_checking_string in varchar2, a_mask in varchar2); | ||
|
|
||
| procedure regexp_like(a_msg in varchar2, a_srcstr in varchar2,a_pattern in varchar2, a_modifier in varchar2 default null); | ||
| procedure regexp_like(a_srcstr in varchar2,a_pattern in varchar2, a_modifier in varchar2 default null); | ||
|
|
||
| procedure is_null(a_actual in number); | ||
| procedure is_null(a_msg in varchar2, a_actual in number); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,8 @@ set serveroutput on size unlimited format truncated | |
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.GivesFailureWhenBothAreNull.sql | ||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.GivesFailureWhenExpectedIsNull.sql | ||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.GivesSuccessForEqualValues.sql | ||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.GivesSuccessForLikeString.sql | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong file names, should be:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add tests proving that assertions are capable of failing?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add tests for the regexp_like assertion? |
||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.GivesSuccessForLikeStringWithEscape.sql | ||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.varchar2.with_text.GivesTheProvidedTextAsMessage.sql | ||
|
|
||
| @@lib/RunTest.sql ut_assert/ut_assert.are_equal.date.GivesFailureForDifferentValues.sql | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --Arrange | ||
| declare | ||
| l_mask varchar2(10) := 'a%b'; | ||
| l_string varchar2(50) := 'asdfsdfsdfb'; | ||
| l_result integer; | ||
| begin | ||
| --Act | ||
| ut_assert.str_like(l_string, l_mask); | ||
| 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: string like'''||l_mask||''', got: '''||l_result||'''' ); | ||
| end if; | ||
| end; | ||
| / |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --Arrange | ||
| declare | ||
| l_mask varchar2(10) := 'a%/_b'; | ||
| l_string varchar2(50) := 'asdfsdfsdf_b'; | ||
| l_result integer; | ||
| begin | ||
| --Act | ||
| ut_assert.str_like('', l_string, l_mask, '/'); | ||
| 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: string like'''||l_mask||''' with escape ''/'', got: '''||l_result||'''' ); | ||
| end if; | ||
| end; | ||
| / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
is_likeoris_matchinginstead ofstr_likeanda_actualinstead ofa_checking_string, to keep it consistent with the rest of asserts.