Skip to content

Commit 303e974

Browse files
committed
Finish demo web pages and source
1 parent fd52bad commit 303e974

14 files changed

+909
-245
lines changed

docs/demo/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ More interesting examples actually test database objects. Here are some examples
8888
## utPLSQL 2.3 Examples
8989
wtPLSQL was built with the utPLSQL "ut_assert" API. These examples were created from the original utPLSQL 2.3 examples without modifying the "ut_assert" calls
9090

91-
* [ut_betwnstr](https://utplsql.org/utPLSQL/v2.3.1/fourstep.html) - Choose a program to test
92-
* [ut_calc_secs_between](https://utplsql.org/utPLSQL/v2.3.1/testproc.html) - Test a Simple Procedure
93-
* [ut_truncit](https://utplsql.org/utPLSQL/v2.3.1/testproc.html) - Test a Table Modification Procedure
94-
* [ut_str](https://utplsql.org/utPLSQL/v2.3.1/testfunc.html) - Test a Simple Function
91+
* [ut_betwnstr](ut_betwnstr.md) - Choose a program to test
92+
* [ut_calc_secs_between](ut_calc_secs_between.md) - Test a Simple Procedure
93+
* [ut_truncit](ut_truncit.md) - Test a Table Modification Procedure
94+
* [ut_str](ut_str.md) - Test a Simple Function
9595

9696
---
9797
[Website Home Page](../README.md)

docs/demo/ut_betwnstr.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
[Demos and Examples](README.md)
2+
3+
# utPLSQL 2.3 ut_betwnstr Example
4+
5+
---
6+
7+
## Original Example
8+
9+
The [original "ut_betwnstr" example](https://utplsql.org/utPLSQL/v2.3.1/fourstep.html) is in the utPLSQL documentation. The PL/SQL source for the function that will be tested is in Step 2. The PL/SQL source for the package specification and body of the utPLSQL test package are in Step 3.
10+
11+
## Test Package Conversion
12+
13+
Conversion of this test package into a test runner package requires the addition of the "wtPLSQL_run" procedure in the package specification.
14+
15+
Run this:
16+
17+
```
18+
CREATE OR REPLACE PACKAGE ut_betwnstr
19+
IS
20+
PROCEDURE ut_setup;
21+
PROCEDURE ut_teardown;
22+
23+
PROCEDURE ut_betwnstr;
24+
PROCEDURE wtplsql_run;
25+
END ut_betwnstr;
26+
/
27+
```
28+
29+
Likewise, the package body needs the wtPLSQL_run procedure.
30+
31+
Run this:
32+
33+
```
34+
CREATE OR REPLACE PACKAGE BODY ut_betwnstr
35+
IS
36+
PROCEDURE ut_setup IS
37+
BEGIN
38+
NULL;
39+
END;
40+
41+
PROCEDURE ut_teardown
42+
IS
43+
BEGIN
44+
NULL;
45+
END;
46+
47+
PROCEDURE ut_betwnstr IS
48+
BEGIN
49+
utAssert.eq (
50+
'Typical valid usage',
51+
BETWNSTR(
52+
STRING_IN => 'abcdefg',
53+
START_IN => 3,
54+
END_IN => 5
55+
),
56+
'cde'
57+
);
58+
59+
utAssert.isnull (
60+
'NULL start',
61+
BETWNSTR(
62+
STRING_IN => 'abcdefg',
63+
START_IN => NULL,
64+
END_IN => 5
65+
)
66+
);
67+
68+
utAssert.isnull (
69+
'NULL end',
70+
BETWNSTR(
71+
STRING_IN => 'abcdefg',
72+
START_IN => 2,
73+
END_IN => NULL
74+
)
75+
);
76+
77+
utAssert.isnull (
78+
'End smaller than start',
79+
BETWNSTR(
80+
STRING_IN => 'abcdefg',
81+
START_IN => 5,
82+
END_IN => 2
83+
)
84+
);
85+
86+
utAssert.eq (
87+
'End larger than string length',
88+
BETWNSTR(
89+
STRING_IN => 'abcdefg',
90+
START_IN => 3,
91+
END_IN => 200
92+
),
93+
'cdefg'
94+
);
95+
96+
END ut_BETWNSTR;
97+
98+
--% WTPLSQL SET DBOUT "BETWNSTR:FUNCTION" %--
99+
PROCEDURE wtPLSQL_run IS
100+
BEGIN
101+
ut_setup;
102+
ut_betwnstr;
103+
ut_teardown;
104+
END wtPLSQL_run;
105+
106+
END ut_betwnstr;
107+
/
108+
```
109+
110+
It is not necessary to keep the ut_setup and ut_teardown procedures. These were kept to indicate how to incorporate those procedures into a test runner package. The SET DBOUT annotation was also added to gather code coverage data.
111+
112+
113+
## Check the Results
114+
115+
Run this:
116+
117+
```
118+
set serveroutput on size unlimited format word_wrapped
119+
120+
begin
121+
wtplsql.test_run('UT_BETWNSTR');
122+
wt_text_report.dbms_out(USER,'UT_BETWNSTR',30);
123+
end;
124+
/
125+
```
126+
127+
And Get This:
128+
129+
```
130+
Code Coverage for FUNCTION WTP_DEMO.BETWNSTR
131+
Ignored Lines: 0 Total Profiled Lines: 3
132+
Excluded Lines: 0 Total Executed Lines: 2
133+
Minimum LineExec usec: 0 Not Executed Lines: 0
134+
Average LineExec usec: 2 Unknown Lines: 1
135+
Maximum LineExec usec: 12 Code Coverage: 100.00%
136+
Trigger Source Offset: 0
137+
138+
- WTP_DEMO.UT_BETWNSTR Test Result Details (Test Run ID 78)
139+
-----------------------------------------------------------
140+
PASS 155ms Typical valid usage. EQ - Expected "cde" and got "cde"
141+
PASS 0ms NULL start. ISNULL - Expected NULL and got ""
142+
PASS 0ms NULL end. ISNULL - Expected NULL and got ""
143+
PASS 0ms End smaller than start. ISNULL - Expected NULL and got ""
144+
PASS 0ms End larger than string length. EQ - Expected "cdefg" and got "cdefg"
145+
146+
- WTP_DEMO.BETWNSTR FUNCTION Code Coverage Details (Test Run ID 78)
147+
Source TotTime MinTime MaxTime
148+
Line Stat Occurs (usec) (usec) (usec) Text
149+
------ ---- ------ --------- ------- --------- ------------
150+
1 UNKN 0 5 1 2 function betwnstr
151+
8 EXEC 5 19 1 12 return (
152+
15 EXEC 5 1 0 1 end;
153+
```
154+
155+
---
156+
[Demos and Examples](README.md)

docs/demo/ut_calc_secs_between.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
[Demos and Examples](README.md)
2+
3+
# utPLSQL 2.3 ut_ut_calc_secs_between Example
4+
5+
---
6+
7+
## Original Example
8+
9+
The [original "ut_ut_calc_secs_between" example](https://utplsql.org/utPLSQL/v2.3.1/testproc.html) is in the utPLSQL documentation. The PL/SQL source for the procedure that will be tested is under the section "Test Success Through Parameters". The PL/SQL source for the package specification and body of the utPLSQL test package are in the same section.
10+
11+
## Test Package Conversion
12+
13+
Conversion of this test package into a test runner package requires the addition of the "wtPLSQL_run" procedure in the package specification.
14+
15+
Run this:
16+
17+
```
18+
CREATE OR REPLACE PACKAGE ut_calc_secs_between
19+
IS
20+
PROCEDURE ut_setup;
21+
PROCEDURE ut_teardown;
22+
23+
-- For each program to test...
24+
PROCEDURE ut_CALC_SECS_BETWEEN;
25+
PROCEDURE wtplsql_run;
26+
END ut_calc_secs_between;
27+
/
28+
```
29+
30+
Likewise, the package body needs the wtPLSQL_run procedure.
31+
32+
Run this:
33+
34+
```
35+
CREATE OR REPLACE PACKAGE BODY ut_calc_secs_between
36+
IS
37+
PROCEDURE ut_setup
38+
IS
39+
BEGIN
40+
NULL;
41+
END;
42+
43+
PROCEDURE ut_teardown
44+
IS
45+
BEGIN
46+
NULL;
47+
END;
48+
49+
-- For each program to test...
50+
PROCEDURE ut_CALC_SECS_BETWEEN
51+
IS
52+
secs PLS_INTEGER;
53+
BEGIN
54+
CALC_SECS_BETWEEN (
55+
DATE1 => SYSDATE
56+
,
57+
DATE2 => SYSDATE
58+
,
59+
SECS => secs
60+
);
61+
62+
utAssert.eq (
63+
'Same dates',
64+
secs,
65+
0
66+
);
67+
68+
CALC_SECS_BETWEEN (
69+
DATE1 => SYSDATE
70+
,
71+
DATE2 => SYSDATE+1
72+
,
73+
SECS => secs
74+
);
75+
76+
utAssert.eq (
77+
'Exactly one day',
78+
secs,
79+
24 * 60 * 60
80+
);
81+
82+
END ut_CALC_SECS_BETWEEN;
83+
84+
--% WTPLSQL SET DBOUT "CALC_SECS_BETWEEN:PROCEDURE" %--
85+
PROCEDURE wtPLSQL_run IS
86+
BEGIN
87+
ut_setup;
88+
ut_CALC_SECS_BETWEEN;
89+
ut_teardown;
90+
END wtPLSQL_run;
91+
92+
END ut_calc_secs_between;
93+
/
94+
```
95+
96+
It is not necessary to keep the ut_setup and ut_teardown procedures. These were kept to indicate how to incorporate those procedures into a test runner package. The SET DBOUT annotation was also added to gather code coverage data.
97+
98+
99+
## Check the Results
100+
101+
Run this:
102+
103+
```
104+
set serveroutput on size unlimited format word_wrapped
105+
106+
begin
107+
wtplsql.test_run('UT_CALC_SECS_BETWEEN');
108+
wt_text_report.dbms_out(in_runner_name => 'UT_CALC_SECS_BETWEEN'
109+
,in_detail_level => 30);
110+
end;
111+
/
112+
```
113+
114+
And Get This:
115+
116+
```
117+
Code Coverage for PROCEDURE WTP_DEMO.CALC_SECS_BETWEEN
118+
Ignored Lines: 0 Total Profiled Lines: 3
119+
Excluded Lines: 0 Total Executed Lines: 2
120+
Minimum LineExec usec: 1 Not Executed Lines: 0
121+
Average LineExec usec: 2 Unknown Lines: 1
122+
Maximum LineExec usec: 8 Code Coverage: 100.00%
123+
Trigger Source Offset: 0
124+
125+
- WTP_DEMO.UT_CALC_SECS_BETWEEN Test Result Details (Test Run ID 80)
126+
-----------------------------------------------------------
127+
PASS 103ms Same dates. EQ - Expected "0" and got "0"
128+
PASS 0ms Exactly one day. EQ - Expected "86400" and got "86400"
129+
130+
- WTP_DEMO.CALC_SECS_BETWEEN PROCEDURE Code Coverage Details (Test Run ID 80)
131+
Source TotTime MinTime MaxTime
132+
Line Stat Occurs (usec) (usec) (usec) Text
133+
------ ---- ------ --------- ------- --------- ------------
134+
1 UNKN 0 2 0 2 PROCEDURE calc_secs_between (
135+
10 EXEC 2 9 1 8 secs := (date2 - date1) * 24 * 60 * 60;
136+
11 EXEC 2 1 1 1 END;
137+
```
138+
139+
---
140+
[Demos and Examples](README.md)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy