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

Skip to content

Commit 40bd352

Browse files
authored
Merge pull request #552 from AlexisGaldamez/new_anydata_test
new tests for anydata added
2 parents c14143a + 52cb9c1 commit 40bd352

2 files changed

Lines changed: 123 additions & 0 deletions

File tree

test/core/expectations/test_expect_not_to_be_null.pkb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
11
create or replace package body test_expect_not_to_be_null
22
is
3+
gc_object_name constant varchar2(30) := 't_not_to_be_null_test';
4+
gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test';
5+
gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test';
6+
37
procedure cleanup_expectations
48
is
59
begin
610
ut3.ut_expectation_processor.clear_expectations();
711
end;
812

13+
procedure create_types
14+
is
15+
pragma autonomous_transaction;
16+
begin
17+
execute immediate 'create type '||gc_object_name||' is object (dummy number)';
18+
execute immediate 'create type '||gc_nested_table_name||' is table of number';
19+
execute immediate 'create type '||gc_varray_name||' is varray(1) of number';
20+
end;
21+
22+
procedure drop_types
23+
is
24+
pragma autonomous_transaction;
25+
begin
26+
execute immediate 'drop type '||gc_object_name;
27+
execute immediate 'drop type '||gc_nested_table_name;
28+
execute immediate 'drop type '||gc_varray_name;
29+
end;
30+
31+
function anydata_expectation_block(a_object_name in varchar2, a_object_value in varchar2,
32+
a_object_type in varchar2)
33+
return varchar2
34+
is
35+
begin
36+
return 'DECLARE
37+
l_object '||a_object_name||' := '||a_object_value||';
38+
BEGIN
39+
ut3.ut.expect(anydata.convert'||a_object_type||'(l_object)).not_to_be_null();
40+
END;';
41+
end;
42+
943
procedure blob_not_null
1044
is
1145
begin
@@ -115,6 +149,32 @@ is
115149
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
116150
end;
117151

152+
procedure initialized_object
153+
is
154+
begin
155+
--Act
156+
execute immediate anydata_expectation_block(gc_object_name, gc_object_name||'(1)', 'object');
157+
--Assert
158+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
159+
end;
160+
161+
procedure initialized_nested_table
162+
is
163+
begin
164+
--Act
165+
execute immediate anydata_expectation_block(gc_nested_table_name, gc_nested_table_name||'()', 'collection');
166+
--Assert
167+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
168+
end;
169+
170+
procedure initialized_varray
171+
is
172+
begin
173+
--Act
174+
execute immediate anydata_expectation_block(gc_varray_name, gc_varray_name||'()', 'collection');
175+
--Assert
176+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
177+
end;
118178

119179
procedure null_boolean
120180
is
@@ -195,5 +255,40 @@ is
195255
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
196256
end;
197257

258+
procedure null_anydata
259+
is
260+
begin
261+
--Act
262+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'anydata', 'null');
263+
--Assert
264+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
265+
end;
266+
267+
procedure uninit_object_in_anydata
268+
is
269+
begin
270+
--Act
271+
execute immediate anydata_expectation_block(gc_object_name, 'null', 'object');
272+
--Assert
273+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
274+
end;
275+
276+
procedure uninit_nested_table_in_anydata
277+
is
278+
begin
279+
--Act
280+
execute immediate anydata_expectation_block(gc_nested_table_name, 'null', 'collection');
281+
--Assert
282+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
283+
end;
284+
285+
procedure uninit_varray_in_anydata
286+
is
287+
begin
288+
--Act
289+
execute immediate anydata_expectation_block(gc_varray_name, 'null', 'collection');
290+
--Assert
291+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
292+
end;
198293
end test_expect_not_to_be_null;
199294
/

test/core/expectations/test_expect_not_to_be_null.pks

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ is
66
--%aftereach
77
procedure cleanup_expectations;
88

9+
--%beforeall
10+
procedure create_types;
11+
12+
--%afterall
13+
procedure drop_types;
14+
915
--%test(Gives success for not null blob)
1016
procedure blob_not_null;
1117

@@ -39,6 +45,15 @@ is
3945
--%test(Gives success for not null varchar2)
4046
procedure varchar2_not_null;
4147

48+
--%test(Gives success for initialized object within anydata)
49+
procedure initialized_object;
50+
51+
--%test(Gives success for initialized nested table within anydata)
52+
procedure initialized_nested_table;
53+
54+
--%test(Gives success for initialized varray within anydata)
55+
procedure initialized_varray;
56+
4257
--%test(Gives failure with null blob)
4358
procedure null_blob;
4459

@@ -65,5 +80,18 @@ is
6580

6681
--%test(Gives failure with null varchar2)
6782
procedure null_varchar2;
83+
84+
--%test(Gives failure with null anydata)
85+
procedure null_anydata;
86+
87+
--%test(Gives failure with uninitialized object within anydata)
88+
procedure uninit_object_in_anydata;
89+
90+
--%test(Gives failure with uninitialized nested table within anydata)
91+
procedure uninit_nested_table_in_anydata;
92+
93+
--%test(Gives failure with uninitialized varray within anydata)
94+
procedure uninit_varray_in_anydata;
95+
6896
end test_expect_not_to_be_null;
6997
/

0 commit comments

Comments
 (0)