-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathut.pkb
More file actions
168 lines (141 loc) · 6.51 KB
/
ut.pkb
File metadata and controls
168 lines (141 loc) · 6.51 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
create or replace package body ut is
/*
utPLSQL - Version X.X.X.X
Copyright 2016 - 2017 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
function version return varchar2 is
begin
return ut_utils.gc_version;
end;
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_anydata is
begin
return ut_expectation_anydata(ut_data_value_anydata(a_actual), a_message);
end;
function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation_blob is
begin
return ut_expectation_blob(ut_data_value_blob(a_actual), a_message);
end;
function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation_boolean is
begin
return ut_expectation_boolean(ut_data_value_boolean(a_actual), a_message);
end;
function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation_clob is
begin
return ut_expectation_clob(ut_data_value_clob(a_actual), a_message);
end;
function expect(a_actual in date, a_message varchar2 := null) return ut_expectation_date is
begin
return ut_expectation_date(ut_data_value_date(a_actual), a_message);
end;
function expect(a_actual in number, a_message varchar2 := null) return ut_expectation_number is
begin
return ut_expectation_number(ut_data_value_number(a_actual), a_message);
end;
function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp is
begin
return ut_expectation_timestamp(ut_data_value_timestamp(a_actual), a_message);
end;
function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp_ltz is
begin
return ut_expectation_timestamp_ltz(ut_data_value_timestamp_ltz(a_actual), a_message);
end;
function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp_tz is
begin
return ut_expectation_timestamp_tz(ut_data_value_timestamp_tz(a_actual), a_message);
end;
function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation_varchar2 is
begin
return ut_expectation_varchar2(ut_data_value_varchar2(a_actual), a_message);
end;
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor is
begin
return ut_expectation_refcursor(ut_data_value_refcursor(a_actual), a_message);
end;
function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation_yminterval is
begin
return ut_expectation_yminterval(ut_data_value_yminterval(a_actual), a_message);
end;
function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation_dsinterval is
begin
return ut_expectation_dsinterval(ut_data_value_dsinterval(a_actual), a_message);
end;
procedure fail(a_message in varchar2) is
begin
ut_expectation_processor.report_failure(a_message);
end;
procedure run_autonomous(a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer) is
pragma autonomous_transaction;
begin
ut_runner.run(a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console));
rollback;
end;
function run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_list pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema'));
l_lines sys_refcursor;
l_line varchar2(4000);
begin
run_autonomous(l_paths, a_reporter, a_color_console );
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
loop
fetch l_lines into l_line;
exit when l_lines%notfound;
pipe row(l_line);
end loop;
close l_lines;
end;
function run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_list pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
l_lines sys_refcursor;
l_line varchar2(4000);
begin
run_autonomous(a_paths, l_reporter, a_color_console);
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
loop
fetch l_lines into l_line;
exit when l_lines%notfound;
pipe row(l_line);
end loop;
close l_lines;
end;
function run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_list pipelined is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
l_lines sys_refcursor;
l_line varchar2(4000);
begin
run_autonomous(l_paths, a_reporter, a_color_console );
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
loop
fetch l_lines into l_line;
exit when l_lines%notfound;
pipe row(l_line);
end loop;
close l_lines;
end;
procedure run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
begin
ut.run(ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console);
end;
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
begin
ut_runner.run(a_paths, l_reporter, a_color_console);
ut_output_buffer.lines_to_dbms_output(l_reporter.reporter_id);
end;
procedure run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
begin
ut.run(l_paths, a_reporter, a_color_console);
end;
end ut;
/