|
| 1 | +create or replace type body equal as |
| 2 | + constructor function equal(self in out nocopy equal, a_expected varchar2, a_nulls_are_equal boolean := null) return self as result is |
| 3 | + begin |
| 4 | + self.nulls_are_equal := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_assert_processor.nulls_are_equal()) ); |
| 5 | + self.assert_name := lower($$plsql_unit); |
| 6 | + self.expected := ut_data_value_varchar2('varchar2', ut_utils.boolean_to_int(a_expected is null), ut_utils.to_string(a_expected), a_expected); |
| 7 | + return; |
| 8 | + end; |
| 9 | + |
| 10 | + constructor function equal(self in out nocopy equal, a_expected number, a_nulls_are_equal boolean := null) return self as result is |
| 11 | + begin |
| 12 | + self.nulls_are_equal := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_assert_processor.nulls_are_equal()) ); |
| 13 | + self.assert_name := lower($$plsql_unit); |
| 14 | + self.expected := ut_data_value_number('number', ut_utils.boolean_to_int(a_expected is null), ut_utils.to_string(a_expected), a_expected); |
| 15 | + return; |
| 16 | + end; |
| 17 | + |
| 18 | + constructor function equal(self in out nocopy equal, a_expected clob, a_nulls_are_equal boolean := null) return self as result is |
| 19 | + begin |
| 20 | + self.nulls_are_equal := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_assert_processor.nulls_are_equal()) ); |
| 21 | + self.assert_name := lower($$plsql_unit); |
| 22 | + self.expected := ut_data_value_clob('clob', ut_utils.boolean_to_int(a_expected is null), ut_utils.to_string(a_expected), a_expected); |
| 23 | + return; |
| 24 | + end; |
| 25 | + |
| 26 | + constructor function equal(self in out nocopy equal, a_expected blob, a_nulls_are_equal boolean := null) return self as result is |
| 27 | + begin |
| 28 | + self.nulls_are_equal := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_assert_processor.nulls_are_equal()) ); |
| 29 | + self.assert_name := lower($$plsql_unit); |
| 30 | + self.expected := ut_data_value_blob('blob', ut_utils.boolean_to_int(a_expected is null), ut_utils.to_string(a_expected), a_expected); |
| 31 | + return; |
| 32 | + end; |
| 33 | + |
| 34 | + overriding member function run_expectation(self in equal, a_actual ut_data_value_varchar2) return ut_assert_result is |
| 35 | + l_expected varchar2(32767 char); |
| 36 | + begin |
| 37 | + l_expected := |
| 38 | + case |
| 39 | + when self.expected is of (ut_data_value_varchar2) then treat(self.expected as ut_data_value_varchar2).value |
| 40 | + end; |
| 41 | + return |
| 42 | + self.build_assert_result( |
| 43 | + ((l_expected = a_actual.value) or (a_actual.value is null and l_expected is null and ut_utils.int_to_boolean(self.nulls_are_equal))) |
| 44 | + , a_actual |
| 45 | + ); |
| 46 | + end; |
| 47 | + |
| 48 | + overriding member function run_expectation(self in equal, a_actual ut_data_value_number) return ut_assert_result is |
| 49 | + l_expected number; |
| 50 | + begin |
| 51 | + l_expected := |
| 52 | + case |
| 53 | + when self.expected is of (ut_data_value_number) then treat(self.expected as ut_data_value_number).value |
| 54 | + end; |
| 55 | + return |
| 56 | + self.build_assert_result( |
| 57 | + ((l_expected = a_actual.value) or (a_actual.value is null and l_expected is null and ut_utils.int_to_boolean(self.nulls_are_equal)) ) |
| 58 | + , a_actual |
| 59 | + ); |
| 60 | + end; |
| 61 | + |
| 62 | + overriding member function run_expectation(self in equal, a_actual ut_data_value_clob) return ut_assert_result is |
| 63 | + l_expected clob; |
| 64 | + begin |
| 65 | + l_expected := |
| 66 | + case |
| 67 | + when self.expected is of (ut_data_value_clob) then treat(self.expected as ut_data_value_clob).value |
| 68 | + end; |
| 69 | + return |
| 70 | + self.build_assert_result( |
| 71 | + ((l_expected = a_actual.value) or (a_actual.value is null and l_expected is null and ut_utils.int_to_boolean(self.nulls_are_equal)) ) |
| 72 | + , a_actual |
| 73 | + ); |
| 74 | + end; |
| 75 | + |
| 76 | + overriding member function run_expectation(self in equal, a_actual ut_data_value_blob) return ut_assert_result is |
| 77 | + l_expected blob; |
| 78 | + begin |
| 79 | + l_expected := |
| 80 | + case |
| 81 | + when self.expected is of (ut_data_value_blob) then treat(self.expected as ut_data_value_blob).value |
| 82 | + end; |
| 83 | + return |
| 84 | + self.build_assert_result( |
| 85 | + (dbms_lob.compare( l_expected, a_actual.value ) = 0 or (a_actual.value is null and l_expected is null and ut_utils.int_to_boolean(self.nulls_are_equal)) ) |
| 86 | + , a_actual |
| 87 | + ); |
| 88 | + end; |
| 89 | + |
| 90 | +end; |
| 91 | +/ |
0 commit comments