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

Skip to content

Commit 6717057

Browse files
committed
Failing test to catch and reproduce #143
1 parent 62ba861 commit 6717057

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.utplsql.cli;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.utplsql.api.TestRunner;
5+
6+
import java.util.ArrayList;
7+
8+
public class PathMapperTest {
9+
10+
@Test
11+
void checkPathMapperOutput() {
12+
RunCommand runCmd = TestHelper.createRunCommand(TestHelper.getConnectionString(),
13+
"-f=ut_sonar_test_reporter",
14+
"-o=sonar_result.xml",
15+
"-s",
16+
"-d",
17+
"-source_path=src/test/resources/plsql/source",
18+
"-owner=app",
19+
"-regex_expression=\"*\"",
20+
"-type_mapping=\"sql=PACKAGE BODY\"",
21+
"-test_path=src/test/resources/plsql/test"
22+
);
23+
24+
TestRunner testRunner = runCmd.newTestRunner(new ArrayList<>());;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is
2+
l_start_pos pls_integer := a_start_pos;
3+
begin
4+
if l_start_pos = 0 then
5+
l_start_pos := 1;
6+
end if;
7+
return substr( a_string, l_start_pos, a_end_pos - l_start_pos + 1);
8+
end;
9+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
create or replace package test_betwnstr as
2+
3+
-- %suite(Between string function)
4+
5+
-- %test(Returns substring from start position to end position)
6+
procedure normal_case;
7+
8+
-- %test(Returns substring when start position is zero)
9+
procedure zero_start_position;
10+
11+
-- %test(Returns string until end if end position is greater than string length)
12+
procedure big_end_position;
13+
14+
-- %test(Returns null for null input string value)
15+
procedure null_string;
16+
17+
-- %test(Demo of a disabled test)
18+
-- %disabled
19+
procedure disabled_test;
20+
21+
end;
22+
/
23+
create or replace package body test_betwnstr as
24+
25+
procedure normal_case is
26+
begin
27+
ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345');
28+
end;
29+
30+
procedure zero_start_position is
31+
begin
32+
ut.expect( betwnstr( '1234567', 0, 5 ) ).to_equal('12345');
33+
end;
34+
35+
procedure big_end_position is
36+
begin
37+
ut.expect( betwnstr( '1234567', 0, 500 ) ).to_equal('1234567');
38+
end;
39+
40+
procedure null_string is
41+
begin
42+
ut.expect( betwnstr( null, 2, 5 ) ).to_be_null;
43+
end;
44+
45+
procedure disabled_test is
46+
begin
47+
ut.expect( betwnstr( null, null, null) ).not_to_be_null;
48+
end;
49+
50+
end;
51+
/

0 commit comments

Comments
 (0)