Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS ltcl_git_delta_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
PRIVATE SECTION.
METHODS:
test_decode_deltas_empty FOR TESTING RAISING cx_static_check,
test_decode_deltas_no_delta FOR TESTING RAISING cx_static_check,
test_decode_deltas_success FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_stream_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
PRIVATE SECTION.
METHODS:
test_offset_only_1byte FOR TESTING RAISING cx_static_check,
test_offset_only_2bytes FOR TESTING RAISING cx_static_check,
test_offset_only_4bytes FOR TESTING RAISING cx_static_check,
test_length_only_1byte FOR TESTING RAISING cx_static_check,
test_length_only_2bytes FOR TESTING RAISING cx_static_check,
test_length_only_3bytes FOR TESTING RAISING cx_static_check,
test_length_zero_default FOR TESTING RAISING cx_static_check,
test_offset_and_length FOR TESTING RAISING cx_static_check,
test_all_bits_set FOR TESTING RAISING cx_static_check,
test_no_bits_set FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_git_delta_test IMPLEMENTATION.
METHOD test_decode_deltas_empty.
DATA lt_objects TYPE zif_abapgit_definitions=>ty_objects_tt.
zcl_abapgit_git_delta=>decode_deltas(
EXPORTING iv_show_progress = abap_false
CHANGING ct_objects = lt_objects ).
cl_abap_unit_assert=>assert_equals(
act = lines( lt_objects )
exp = 0
msg = 'Empty object table should remain empty' ).
ENDMETHOD.
METHOD test_decode_deltas_no_delta.
DATA lt_objects TYPE zif_abapgit_definitions=>ty_objects_tt.
DATA ls_object TYPE zif_abapgit_definitions=>ty_object.
" Create a non-delta object
ls_object-sha1 = '1234567890123456789012345678901234567890'.
ls_object-type = zif_abapgit_git_definitions=>c_type-blob.
ls_object-data = zcl_abapgit_convert=>string_to_xstring_utf8( `Hello World` ).
ls_object-index = 1.
APPEND ls_object TO lt_objects.
zcl_abapgit_git_delta=>decode_deltas(
EXPORTING iv_show_progress = abap_false
CHANGING ct_objects = lt_objects ).
cl_abap_unit_assert=>assert_equals(
act = lines( lt_objects )
exp = 1
msg = 'Non-delta objects should remain unchanged' ).
READ TABLE lt_objects INTO ls_object INDEX 1.
cl_abap_unit_assert=>assert_equals(
act = ls_object-type
exp = zif_abapgit_git_definitions=>c_type-blob
msg = 'Object type should remain blob' ).
ENDMETHOD.
METHOD test_decode_deltas_success.
DATA lt_objects TYPE zif_abapgit_definitions=>ty_objects_tt.
DATA lv_original_count TYPE i.
DATA ls_object TYPE zif_abapgit_definitions=>ty_object.
" Create a base blob object
ls_object-sha1 = '1234567890123456789012345678901234567890'.
ls_object-type = zif_abapgit_git_definitions=>c_type-blob.
ls_object-data = zcl_abapgit_convert=>string_to_xstring_utf8( `Hello World` ).
ls_object-index = 1.
APPEND ls_object TO lt_objects.
" Create a delta object that references the base blob
CLEAR ls_object.
ls_object-sha1 = '1234567890123456789012345678901234567890'. " same as base for reference
ls_object-type = zif_abapgit_git_definitions=>c_type-ref_d.
ls_object-data = '0B0D900B'.
ls_object-index = 2.
APPEND ls_object TO lt_objects.
" Store original count
lv_original_count = lines( lt_objects ).
zcl_abapgit_git_delta=>decode_deltas(
EXPORTING iv_show_progress = abap_false
CHANGING ct_objects = lt_objects ).
" Should have same number of objects after delta processing
cl_abap_unit_assert=>assert_equals(
act = lines( lt_objects )
exp = lv_original_count
msg = 'Should have same number of objects after delta processing' ).
" Check that no delta objects remain
LOOP AT lt_objects INTO ls_object.
IF ls_object-type = zif_abapgit_git_definitions=>c_type-ref_d.
cl_abap_unit_assert=>fail( 'No delta objects should remain after processing' ).
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
CLASS ltcl_stream_test IMPLEMENTATION.
METHOD test_offset_only_1byte.
" Instruction 01 = offset byte 1 present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = 'FF'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '01'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 255
msg = 'Offset should be 255' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 65536
msg = 'Length should default to 65536' ).
ENDMETHOD.
METHOD test_offset_only_2bytes.
" Instruction 03 = offset bytes 1 and 2 present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '0102'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '03'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
" offset = 1 + 2*256 = 513
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 513
msg = 'Offset should be 513' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 65536
msg = 'Length should default to 65536' ).
ENDMETHOD.
METHOD test_offset_only_4bytes.
" Instruction 0F = all 4 offset bytes present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '01020304'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '0F'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
" offset = 1 + 2*256 + 3*65536 + 4*16777216 = 67305985
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 67305985
msg = 'Offset should be 67305985' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 65536
msg = 'Length should default to 65536' ).
ENDMETHOD.
METHOD test_length_only_1byte.
" Instruction 10 = length byte 1 present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '0A'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '10'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 0
msg = 'Offset should be 0' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 10
msg = 'Length should be 10' ).
ENDMETHOD.
METHOD test_length_only_2bytes.
" Instruction 30 = length bytes 1 and 2 present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '0102'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '30'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
" length = 1 + 2*256 = 513
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 0
msg = 'Offset should be 0' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 513
msg = 'Length should be 513' ).
ENDMETHOD.
METHOD test_length_only_3bytes.
" Instruction 70 = all 3 length bytes present
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '010203'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '70'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
" length = 1 + 2*256 + 3*65536 = 197121
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 0
msg = 'Offset should be 0' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 197121
msg = 'Length should be 197121' ).
ENDMETHOD.
METHOD test_length_zero_default.
" Instruction 00 = no bytes present, length defaults to 65536
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '00'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '00'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 0
msg = 'Offset should be 0' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 65536
msg = 'Length should default to 65536' ).
ENDMETHOD.
METHOD test_offset_and_length.
" Instruction 11 = offset byte 1 + length byte 1
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '0A14'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '11'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 10
msg = 'Offset should be 10' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 20
msg = 'Length should be 20' ).
ENDMETHOD.
METHOD test_all_bits_set.
" Instruction 7F = all 7 bits set (4 offset bytes + 3 length bytes)
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '01020304050607'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '7F'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
" offset = 1 + 2*256 + 3*65536 + 4*16777216 = 67305985
" length = 5 + 6*256 + 7*65536 = 460293
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 67305985
msg = 'Offset should be 67305985' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 460293
msg = 'Length should be 460293' ).
ENDMETHOD.
METHOD test_no_bits_set.
" Instruction 80 = copy instruction with no offset/length bits set
DATA lo_stream TYPE REF TO lcl_stream.
DATA lv_offset TYPE i.
DATA lv_length TYPE i.
CREATE OBJECT lo_stream EXPORTING iv_data = '00'.
lo_stream->eat_offset_and_length(
EXPORTING iv_instruction = '80'
IMPORTING ev_offset = lv_offset
ev_length = lv_length ).
cl_abap_unit_assert=>assert_equals(
act = lv_offset
exp = 0
msg = 'Offset should be 0' ).
cl_abap_unit_assert=>assert_equals(
act = lv_length
exp = 65536
msg = 'Length should default to 65536' ).
ENDMETHOD.
ENDCLASS.
|