Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0daab33
Checkpoint
lwasylow Mar 28, 2023
adbc76e
Address too long identified in 11g.
lwasylow Mar 28, 2023
1478b0d
Adding validation for tag expression
lwasylow Mar 29, 2023
b5ad747
Comment out to see why its failing.
lwasylow Mar 29, 2023
06cb054
Revert "Comment out to see why its failing."
lwasylow Mar 29, 2023
e87d39f
Adding validate function, with no calls
lwasylow Mar 29, 2023
97537de
Remove a & from text
lwasylow Mar 29, 2023
2a0f99a
Extra changes and added tests
lwasylow Mar 31, 2023
5b46140
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Mar 31, 2023
b30688c
Address sonar coverage issues.
lwasylow Apr 1, 2023
0c41a0f
Adding tests covering exception of invalid tags
lwasylow Apr 1, 2023
543685d
Removing that , we will not implement that, there is no benefit at th…
lwasylow Apr 1, 2023
0d3cfa1
Removing force
lwasylow Apr 1, 2023
20e3177
Changing to use Dijkstra algorithm to parse infix notation into postf…
lwasylow Apr 10, 2023
f51cc99
Missing slash at end of type
lwasylow Apr 10, 2023
4b8e2ab
Cleanup.
lwasylow Apr 10, 2023
84e8684
Update tests after removed function
lwasylow Apr 10, 2023
2e7a766
Tidy up tests
lwasylow Apr 10, 2023
cbdf83a
Added ut_stack to uninstall
lwasylow Apr 10, 2023
436eb5b
Addressing test failures and sonar smells
lwasylow Apr 11, 2023
3d77514
Update name
lwasylow Apr 11, 2023
bf6959f
Update tests and code
lwasylow Apr 11, 2023
d8233ff
fixing typo in docs
lwasylow Apr 12, 2023
bd860f6
Removed unused variable
lwasylow Apr 12, 2023
313d5e9
Stage 1 Resolving PR comments
lwasylow Apr 13, 2023
02a071c
Separate tag logic.
lwasylow Apr 13, 2023
b8b66ee
Fix uninstall
lwasylow Apr 14, 2023
077fdb1
Various PR fixe
lwasylow Apr 14, 2023
01e5364
Update tests and code
lwasylow Apr 15, 2023
dc0b4a6
Addressing changes via PR review.
lwasylow Apr 18, 2023
ef1c02b
Update docs
lwasylow Apr 18, 2023
1551ea5
Adding any and none
lwasylow Apr 25, 2023
9dee7e0
Update docs
lwasylow Apr 26, 2023
beb9a3a
Resolving PR
lwasylow Apr 27, 2023
46ffe73
Update note
lwasylow Apr 27, 2023
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
Next Next commit
Addressing test failures and sonar smells
  • Loading branch information
lwasylow committed Apr 11, 2023
commit 436eb5bed919df6b512688511a6d121a71c3a320
51 changes: 30 additions & 21 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1011,15 +1011,17 @@ create or replace package body ut_utils is
l_token varchar2(32767);
l_expect_operand boolean := true;
l_expect_operator boolean := false;
l_idx pls_integer;
begin
--Tokenize a string into operators and tags
select regexp_substr(l_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts
bulk collect into l_input_tokens
from dual connect by regexp_substr (l_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null;

l_idx := l_input_tokens.first;
--Exuecute modified shunting algorithm
for token in 1..l_input_tokens.count loop
l_token := l_input_tokens(token);
WHILE (l_idx is not null) loop
l_token := l_input_tokens(l_idx);
if (l_token member of gc_operators and l_token member of gc_binary_operator) then
if not(l_expect_operator) then
raise ex_invalid_tag_expression;
Comment thread
lwasylow marked this conversation as resolved.
Outdated
Expand All @@ -1028,21 +1030,21 @@ create or replace package body ut_utils is
l_rnp_tokens.extend;
l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop;
end loop;
l_operator_stack.push(l_input_tokens(token));
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif (l_token member of gc_operators and l_token member of gc_unary_operator) then
if not(l_expect_operand) then
raise ex_invalid_tag_expression;
end if;
l_operator_stack.push(l_input_tokens(token));
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = '(' then
if not(l_expect_operand) then
raise ex_invalid_tag_expression;
Comment thread
lwasylow marked this conversation as resolved.
Outdated
end if;
l_operator_stack.push(l_input_tokens(token));
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = ')' then
Expand All @@ -1066,6 +1068,7 @@ create or replace package body ut_utils is
l_expect_operand := false;
end if;

l_idx := l_input_tokens.next(l_idx);
end loop;

while l_operator_stack.top > 0 loop
Expand All @@ -1091,25 +1094,28 @@ create or replace package body ut_utils is
l_right_side varchar2(32767);
l_left_side varchar2(32767);
l_infix_exp varchar2(32767);
l_idx pls_integer;
begin
for i in 1..a_postfix_exp.count loop
l_idx := a_postfix_exp.first;
while (l_idx is not null) loop
--If token is operand but also single tag
if a_postfix_exp(i) not member of gc_operators then --its operand
l_infix_stack.push(a_postfix_exp(i));
if a_postfix_exp(l_idx) not member of gc_operators then --its operand
l_infix_stack.push(a_postfix_exp(l_idx));
--If token is unary operator not
elsif a_postfix_exp(i) member of gc_unary_operator then
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
l_right_side := l_infix_stack.pop;
l_infix_exp := '('||a_postfix_exp(i)||l_right_side||')';
l_infix_exp := '('||a_postfix_exp(l_idx)||l_right_side||')';
l_infix_stack.push(l_infix_exp);
--If token is binary operator
elsif a_postfix_exp(i) member of gc_binary_operator then
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
l_right_side := l_infix_stack.pop;
l_left_side := l_infix_stack.pop;
l_infix_exp := '('||l_left_side||a_postfix_exp(i)||l_right_side||')';
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';
l_infix_stack.push(l_infix_exp);
else
null;
end if;
l_idx := a_postfix_exp.next(l_idx);
end loop;

return l_infix_stack.pop;
Expand All @@ -1122,28 +1128,31 @@ create or replace package body ut_utils is
l_left_side varchar2(32767);
l_infix_exp varchar2(32767);
l_member_token varchar2(20) := ' member of tags';
Comment thread
lwasylow marked this conversation as resolved.
Outdated
l_idx pls_integer;
begin
for i in 1..a_postfix_exp.count loop
l_idx := a_postfix_exp.first;
while ( l_idx is not null) loop
--If token is operand but also single tag
if regexp_count(a_postfix_exp(i),'[!()|&]') = 0 then
l_infix_stack.push(q'[']'||a_postfix_exp(i)||q'[']'||l_member_token);
if regexp_count(a_postfix_exp(l_idx),'[!()|&]') = 0 then
l_infix_stack.push(q'[']'||a_postfix_exp(l_idx)||q'[']'||l_member_token);
--If token is operand but containing other expressions
elsif a_postfix_exp(i) not member of gc_operators then
l_infix_stack.push(a_postfix_exp(i));
elsif a_postfix_exp(l_idx) not member of gc_operators then
l_infix_stack.push(a_postfix_exp(l_idx));
Comment thread
lwasylow marked this conversation as resolved.
Outdated
--If token is unary operator not
elsif a_postfix_exp(i) member of gc_unary_operator then
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
l_right_side := l_infix_stack.pop;
l_infix_exp := a_postfix_exp(i)||'('||l_right_side||')';
l_infix_exp := a_postfix_exp(l_idx)||'('||l_right_side||')';
l_infix_stack.push(l_infix_exp);
--If token is binary operator
elsif a_postfix_exp(i) member of gc_binary_operator then
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
l_right_side := l_infix_stack.pop;
l_left_side := l_infix_stack.pop;
l_infix_exp := '('||l_left_side||a_postfix_exp(i)||l_right_side||')';
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';
l_infix_stack.push(l_infix_exp);
else
null;
end if;
l_idx := a_postfix_exp.next(l_idx);
end loop;

return l_infix_stack.pop;
Expand Down
35 changes: 35 additions & 0 deletions test/ut3_tester/core/test_ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,40 @@ end;
ut.expect(l_expected).to_equal(l_actual);
end;


procedure test_conversion_to_rpn is
l_postfix ut3_develop.ut_varchar2_list;
l_postfix_string varchar2(4000);
begin
l_postfix := ut3_develop.ut_utils.shunt_logical_expression('A');
l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,'');
ut.expect(l_postfix_string).to_equal('A');

l_postfix := ut3_develop.ut_utils.shunt_logical_expression('A|B');
l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,'');
ut.expect(l_postfix_string).to_equal('AB|');

l_postfix := ut3_develop.ut_utils.shunt_logical_expression('(a|b)|c&d');
l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,'');
ut.expect(l_postfix_string).to_equal('ab|cd&|');
end;

procedure test_conversion_from_rpn_to_infix is
l_postfix_rpn ut3_develop.ut_varchar2_list;
l_infix_string varchar2(4000);
begin
l_postfix_rpn := ut3_develop.ut_varchar2_list('A');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
Comment thread
lwasylow marked this conversation as resolved.
Outdated
ut.expect(l_infix_string).to_equal('A');

l_postfix_rpn := ut3_develop.ut_varchar2_list('A','B','|');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('(A|B)');

l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','|','c','d','&','|');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('((a|b)|(c&d))');
end;

end test_ut_utils;
/
6 changes: 6 additions & 0 deletions test/ut3_tester/core/test_ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ create or replace package test_ut_utils is


--%endcontext

--%test( Test conversion of expression into Reverse Polish Notation)
procedure test_conversion_to_rpn;

--%test( Test conversion of expression from Reverse Polish Notation into infix)
procedure test_conversion_from_rpn_to_infix;

end test_ut_utils;
/