|
| 1 | +create or replace package body test_ut_utils as |
| 2 | + |
| 3 | + procedure clob_to_table_test( |
| 4 | + a_clob clob, a_expected ut_varchar2_list, |
| 5 | + a_delimiter varchar2 := ',', |
| 6 | + a_overflow_limit integer := 1000 |
| 7 | + ) is |
| 8 | + l_result ut_varchar2_list; |
| 9 | + begin |
| 10 | + --Act |
| 11 | + l_result := ut3.ut_utils.clob_to_table(a_clob, a_overflow_limit, a_delimiter); |
| 12 | + --Assert |
| 13 | + ut.expect(anydata.convertCollection(l_result)).to_( equal(anydata.convertCollection(a_expected)) ); |
| 14 | + end; |
| 15 | + |
| 16 | + procedure clob_to_table_by_delim is |
| 17 | + begin |
| 18 | + clob_to_table_test( a_clob => 'a,b,c,d', a_expected => ut_varchar2_list('a','b','c','d') ); |
| 19 | + end; |
| 20 | + |
| 21 | + --%test(clob_to_table returns empty table for null clob) |
| 22 | + procedure clob_to_table_null_data is |
| 23 | + begin |
| 24 | + clob_to_table_test( a_clob => null, a_expected => ut_varchar2_list() ); |
| 25 | + end; |
| 26 | + |
| 27 | + --%test(clob_to_table splits table by char limit when no delimiter) |
| 28 | + procedure clob_to_table_char_limit is |
| 29 | + begin |
| 30 | + clob_to_table_test( |
| 31 | + a_clob => '1,2,3,4', |
| 32 | + a_expected => ut_varchar2_list('1,2,','3,4'), |
| 33 | + a_delimiter => '', |
| 34 | + a_overflow_limit => 4 |
| 35 | + ); |
| 36 | + end; |
| 37 | + |
| 38 | + --%test(clob_to_table splits table by char limit on overflow and continues by delimiter) |
| 39 | + procedure clob_to_table_char_limit_delim is |
| 40 | + begin |
| 41 | + clob_to_table_test( |
| 42 | + a_clob => 'abcdefg,hijk,axa,a', |
| 43 | + a_expected => ut_varchar2_list('abc','def','g','hij','k','axa','a'), |
| 44 | + a_overflow_limit => 3 |
| 45 | + ); |
| 46 | + end; |
| 47 | + |
| 48 | + --%test(clob_to_table returns empty lines for null data between delimiter) |
| 49 | + procedure clob_to_table_empty_lines is |
| 50 | + begin |
| 51 | + clob_to_table_test( |
| 52 | + a_clob => ',a,,c,d,', |
| 53 | + a_expected => ut_varchar2_list('','a','','c','d','') |
| 54 | + ); |
| 55 | + end; |
| 56 | + |
| 57 | + --%test(test_result_to_char) |
| 58 | + procedure test_result_to_char is |
| 59 | + begin |
| 60 | + ut.expect( ut_utils.test_result_to_char(NULL)).to_equal('Unknown(NULL)'); |
| 61 | + ut.expect( ut_utils.test_result_to_char(-1)).to_equal('Unknown(-1)'); |
| 62 | + ut.expect( ut_utils.test_result_to_char(ut_utils.tr_disabled)).to_equal(ut_utils.tr_disabled_char); |
| 63 | + ut.expect( ut_utils.test_result_to_char(ut_utils.tr_success)).to_equal(ut_utils.tr_success_char); |
| 64 | + ut.expect( ut_utils.test_result_to_char(ut_utils.tr_failure)).to_equal(ut_utils.tr_failure_char); |
| 65 | + ut.expect( ut_utils.test_result_to_char(ut_utils.tr_error)).to_equal(ut_utils.tr_error_char); |
| 66 | + end; |
| 67 | + |
| 68 | + --%test(to_test_result converts boolean value to test result integer) |
| 69 | + procedure to_test_result is |
| 70 | + begin |
| 71 | + ut.expect( ut_utils.to_test_result(true)).to_equal(ut_utils.tr_success); |
| 72 | + ut.expect( ut_utils.to_test_result(false)).to_equal(ut_utils.tr_failure); |
| 73 | + ut.expect( ut_utils.to_test_result(null)).to_equal(ut_utils.tr_failure); |
| 74 | + end; |
| 75 | + |
| 76 | + --%test(to_string on null blob) |
| 77 | + procedure to_string_null_blob is |
| 78 | + begin |
| 79 | + ut.expect( ut_utils.to_string(to_blob(null)) ).to_equal('NULL'); |
| 80 | + end; |
| 81 | + |
| 82 | + --%test(to_string on blob) |
| 83 | + procedure to_string_blob is |
| 84 | + l_text varchar2(32767) := 'A test char'; |
| 85 | + l_value blob := utl_raw.cast_to_raw(l_text); |
| 86 | + l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; |
| 87 | + begin |
| 88 | + ut.expect( ut_utils.to_string(l_value) ).to_equal(l_expected); |
| 89 | + end; |
| 90 | + |
| 91 | +-- --%test(to_string on null clob) |
| 92 | +-- procedure to_string_null_clob; |
| 93 | +-- --%test(to_string on clob) |
| 94 | +-- procedure to_string_clob; |
| 95 | +-- --%test(to_string on clob no surrounding quotes) |
| 96 | +-- procedure to_string_clob_no_quotes; |
| 97 | +-- --%test(to_string on clob other surrounding quotes) |
| 98 | +-- procedure to_string_clob_other_quotes; |
| 99 | +-- |
| 100 | +-- --%test(to_string on null number) |
| 101 | +-- procedure to_string_null_number; |
| 102 | +-- --%test(to_string on number) |
| 103 | +-- procedure to_string_number; |
| 104 | +-- |
| 105 | +-- --%test(to_string on null timestamp) |
| 106 | +-- procedure to_string_null_timestamp; |
| 107 | +-- --%test(to_string on timestamp) |
| 108 | +-- procedure to_string_timestamp; |
| 109 | +-- |
| 110 | +-- --%test(to_string on null timestamp with time zone) |
| 111 | +-- procedure to_string_null_timestamp_tz; |
| 112 | +-- --%test(to_string on timestamp with time zone) |
| 113 | +-- procedure to_string_timestamp_tz; |
| 114 | +-- |
| 115 | +-- --%test(to_string on null timestamp with local time zone) |
| 116 | +-- procedure to_string_null_timestamp_ltz; |
| 117 | +-- --%test(to_string on timestamp with local time zone) |
| 118 | +-- procedure to_string_timestamp_ltz; |
| 119 | +-- |
| 120 | +-- --%test(to_string on null varchar) |
| 121 | +-- procedure to_string_null_varchar; |
| 122 | +-- --%test(to_string on varchar) |
| 123 | +-- procedure to_string_varchar; |
| 124 | +-- --%test(to_string on varchar no surrounding quotes) |
| 125 | +-- procedure to_string_varchar_no_quotes; |
| 126 | +-- --%test(to_string on varchar non default surrounding quotes) |
| 127 | +-- procedure to_string_varchar_other_quotes; |
| 128 | + |
| 129 | +end; |
| 130 | +/ |
0 commit comments