-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathut_betwnstr.sql
More file actions
111 lines (96 loc) · 1.9 KB
/
Copy pathut_betwnstr.sql
File metadata and controls
111 lines (96 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
CREATE OR REPLACE FUNCTION betwnStr (
string_in IN VARCHAR2,
start_in IN INTEGER,
end_in IN INTEGER
)
RETURN VARCHAR2
IS
BEGIN
RETURN (
SUBSTR (
string_in,
start_in,
end_in - start_in + 1
)
);
END;
/
CREATE OR REPLACE PACKAGE ut_betwnstr
IS
PROCEDURE ut_setup;
PROCEDURE ut_teardown;
PROCEDURE ut_betwnstr;
PROCEDURE wtplsql_run;
END ut_betwnstr;
/
CREATE OR REPLACE PACKAGE BODY ut_betwnstr
IS
PROCEDURE ut_setup IS
BEGIN
NULL;
END;
PROCEDURE ut_teardown
IS
BEGIN
NULL;
END;
PROCEDURE ut_betwnstr IS
BEGIN
utAssert.eq (
'Typical valid usage',
BETWNSTR(
STRING_IN => 'abcdefg',
START_IN => 3,
END_IN => 5
),
'cde'
);
utAssert.isnull (
'NULL start',
BETWNSTR(
STRING_IN => 'abcdefg',
START_IN => NULL,
END_IN => 5
)
);
utAssert.isnull (
'NULL end',
BETWNSTR(
STRING_IN => 'abcdefg',
START_IN => 2,
END_IN => NULL
)
);
utAssert.isnull (
'End smaller than start',
BETWNSTR(
STRING_IN => 'abcdefg',
START_IN => 5,
END_IN => 2
)
);
utAssert.eq (
'End larger than string length',
BETWNSTR(
STRING_IN => 'abcdefg',
START_IN => 3,
END_IN => 200
),
'cdefg'
);
END ut_BETWNSTR;
--% WTPLSQL SET DBOUT "BETWNSTR:FUNCTION" %--
PROCEDURE wtPLSQL_run IS
BEGIN
ut_setup;
ut_betwnstr;
ut_teardown;
END wtPLSQL_run;
END ut_betwnstr;
/
set serveroutput on size unlimited format word_wrapped
begin
wtplsql.test_run('UT_BETWNSTR');
wt_text_report.dbms_out(USER,'UT_BETWNSTR',30);
end;
/