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 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_diff DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. DATA: mt_new TYPE TABLE OF string, mt_old TYPE TABLE OF string, mt_beacons TYPE zif_abapgit_definitions=>ty_string_tt, mt_expected TYPE zif_abapgit_definitions=>ty_diffs_tt. METHODS: add_new IMPORTING iv_new TYPE string, add_old IMPORTING iv_old TYPE string, add_beacon IMPORTING iv_beacon TYPE string, add_expected IMPORTING iv_new_num TYPE zif_abapgit_definitions=>ty_diff-new_num iv_new TYPE zif_abapgit_definitions=>ty_diff-new iv_result TYPE zif_abapgit_definitions=>ty_diff-result iv_old_num TYPE zif_abapgit_definitions=>ty_diff-old_num iv_old TYPE zif_abapgit_definitions=>ty_diff-old iv_beacon TYPE zif_abapgit_definitions=>ty_diff-beacon DEFAULT zcl_abapgit_diff=>c_starting_beacon. METHODS: setup. METHODS: test IMPORTING !iv_ignore_indentation TYPE abap_bool DEFAULT abap_false !iv_ignore_comments TYPE abap_bool DEFAULT abap_false !iv_ignore_case TYPE abap_bool DEFAULT abap_false !iv_check_beacons TYPE abap_bool DEFAULT abap_false RAISING zcx_abapgit_exception. METHODS: diff01 FOR TESTING RAISING zcx_abapgit_exception, diff02 FOR TESTING RAISING zcx_abapgit_exception, diff03 FOR TESTING RAISING zcx_abapgit_exception, diff04 FOR TESTING RAISING zcx_abapgit_exception, diff05 FOR TESTING RAISING zcx_abapgit_exception, diff06 FOR TESTING RAISING zcx_abapgit_exception, diff07 FOR TESTING RAISING zcx_abapgit_exception, diff08 FOR TESTING RAISING zcx_abapgit_exception, diff09 FOR TESTING RAISING zcx_abapgit_exception, diff10 FOR TESTING RAISING zcx_abapgit_exception, diff11 FOR TESTING RAISING zcx_abapgit_exception, diff12 FOR TESTING RAISING zcx_abapgit_exception, diff13 FOR TESTING RAISING zcx_abapgit_exception, diff14 FOR TESTING RAISING zcx_abapgit_exception, diff15 FOR TESTING RAISING zcx_abapgit_exception, diff16 FOR TESTING RAISING zcx_abapgit_exception, map_beacons FOR TESTING RAISING zcx_abapgit_exception. ENDCLASS. CLASS ltcl_diff IMPLEMENTATION. METHOD add_new. APPEND iv_new TO mt_new. ENDMETHOD. METHOD add_old. APPEND iv_old TO mt_old. ENDMETHOD. METHOD add_beacon. APPEND iv_beacon TO mt_beacons. ENDMETHOD. METHOD add_expected. DATA ls_expected LIKE LINE OF mt_expected. ls_expected-new_num = iv_new_num. ls_expected-new = iv_new. ls_expected-result = iv_result. ls_expected-old_num = iv_old_num. ls_expected-old = iv_old. ls_expected-beacon = iv_beacon. APPEND ls_expected TO mt_expected. ENDMETHOD. METHOD setup. CLEAR mt_new. CLEAR mt_old. CLEAR mt_beacons. CLEAR mt_expected. ENDMETHOD. METHOD test. DATA: lv_new TYPE string, lv_xnew TYPE xstring, lv_old TYPE string, lv_xold TYPE xstring, lo_diff TYPE REF TO zcl_abapgit_diff, lt_diff TYPE zif_abapgit_definitions=>ty_diffs_tt. FIELD-SYMBOLS: <ls_diff> LIKE LINE OF lt_diff. CONCATENATE LINES OF mt_new INTO lv_new SEPARATED BY cl_abap_char_utilities=>newline. CONCATENATE LINES OF mt_old INTO lv_old SEPARATED BY cl_abap_char_utilities=>newline. lv_xnew = zcl_abapgit_convert=>string_to_xstring_utf8( lv_new ). lv_xold = zcl_abapgit_convert=>string_to_xstring_utf8( lv_old ). CREATE OBJECT lo_diff EXPORTING iv_new = lv_xnew iv_old = lv_xold iv_ignore_indentation = iv_ignore_indentation iv_ignore_comments = iv_ignore_comments iv_ignore_case = iv_ignore_case. IF iv_check_beacons = abap_true. cl_abap_unit_assert=>assert_equals( act = lo_diff->get_beacons( ) exp = mt_beacons ). RETURN. ENDIF. lt_diff = lo_diff->get( ). LOOP AT lt_diff ASSIGNING <ls_diff>. CLEAR <ls_diff>-short. ENDLOOP. cl_abap_unit_assert=>assert_equals( act = lt_diff exp = mt_expected ). ENDMETHOD. METHOD diff01. "insert add_new( 'A' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-insert iv_old_num = '' iv_old = '' ). test( ). ENDMETHOD. METHOD diff02. " identical add_new( 'A' ). add_old( 'A' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). test( ). ENDMETHOD. METHOD diff03. " delete add_old( 'A' ). add_expected( iv_new_num = '' iv_new = '' iv_result = zif_abapgit_definitions=>c_diff-delete iv_old_num = ' 1' iv_old = 'A' ). test( ). ENDMETHOD. METHOD diff04. " update add_new( 'A+' ). add_old( 'A' ). add_expected( iv_new_num = ' 1' iv_new = 'A+' iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 1' iv_old = 'A' ). test( ). ENDMETHOD. METHOD diff05. " identical add_new( 'A' ). add_new( 'B' ). add_old( 'A' ). add_old( 'B' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = 'B' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = 'B' ). test( ). ENDMETHOD. METHOD diff06. " mixed add_new( 'A' ). add_new( 'B' ). add_new( 'inserted' ). add_new( 'C' ). add_new( 'D update' ). add_old( 'A' ). add_old( 'B' ). add_old( 'C' ). add_old( 'D' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = 'B' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = 'B' ). add_expected( iv_new_num = ' 3' iv_new = 'inserted' iv_result = zif_abapgit_definitions=>c_diff-insert iv_old_num = '' iv_old = '' ). add_expected( iv_new_num = ' 4' iv_new = 'C' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 3' iv_old = 'C' ). add_expected( iv_new_num = ' 5' iv_new = 'D update' iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 4' iv_old = 'D' ). test( ). ENDMETHOD. METHOD diff07. " ignore indentation add_new( 'A' ). add_new( ' B' ). " changed indent add_new( 'C' ). add_new( ' D' ). " changed indent add_old( 'A' ). add_old( 'B' ). add_old( 'C' ). add_old( 'D' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = ' B' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = 'B' ). add_expected( iv_new_num = ' 3' iv_new = 'C' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 3' iv_old = 'C' ). add_expected( iv_new_num = ' 4' iv_new = ' D' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 4' iv_old = 'D' ). test( iv_ignore_indentation = abap_true ). ENDMETHOD. METHOD diff08. " ignore comments add_new( 'A' ). add_new( '* X' ). " changed comment add_new( 'C' ). add_new( 'D " new' ). " changed comment add_old( 'A' ). add_old( '* B' ). add_old( 'C' ). add_old( 'D " old' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = '* X' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = '* B' ). add_expected( iv_new_num = ' 3' iv_new = 'C' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 3' iv_old = 'C' ). add_expected( iv_new_num = ' 4' iv_new = 'D " new' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 4' iv_old = 'D " old' ). test( iv_ignore_comments = abap_true ). ENDMETHOD. METHOD diff09. " ignore case add_new( 'A' ). add_new( 'b' ). " changed case add_new( 'c' ). add_new( 'D' ). " changed case add_old( 'A' ). add_old( 'B' ). add_old( 'c' ). add_old( 'd' ). add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = 'b' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = 'B' ). add_expected( iv_new_num = ' 3' iv_new = 'c' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 3' iv_old = 'c' ). add_expected( iv_new_num = ' 4' iv_new = 'D' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 4' iv_old = 'd' ). test( iv_ignore_case = abap_true ). ENDMETHOD. METHOD diff10. " ignore case should NOT ignore changed literals add_new( `WRITE 'TEST'` ). add_old( `WRITE 'test'` ). add_expected( iv_new_num = ' 1' iv_new = `WRITE 'TEST'` iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 1' iv_old = `WRITE 'test'` ). test( iv_ignore_case = abap_true ). ENDMETHOD. METHOD diff11. " ignore case should ignore changed keywords, variables, types add_new( `write 'test'` ). add_new( `DATA FOO TYPE I.` ). add_old( `WRITE 'test'` ). add_old( `DATA foo TYPE i.` ). add_expected( iv_new_num = ' 1' iv_new = `write 'test'` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = `WRITE 'test'` ). add_expected( iv_new_num = ' 2' iv_new = `DATA FOO TYPE I.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = `DATA foo TYPE i.` ). test( iv_ignore_case = abap_true ). ENDMETHOD. METHOD diff12. " adjusted diffs for insert (workaround for kernel issue) add_new( `REPORT zprog_diff.` ). add_new( `*` ). add_new( `FORM t_1.` ). add_new( `ENDFORM.` ). add_new( `FORM t_2.` ). add_new( `ENDFORM.` ). add_old( `REPORT zprog_diff.` ). add_old( `FORM t_1.` ). add_old( `ENDFORM.` ). add_expected( iv_new_num = ' 1' iv_new = `REPORT zprog_diff.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = `REPORT zprog_diff.` iv_beacon = 1 ). add_expected( iv_new_num = ' 2' iv_new = `*` iv_result = zif_abapgit_definitions=>c_diff-insert iv_old_num = ' ' iv_old = `` iv_beacon = 1 ). add_expected( iv_new_num = ' 3' iv_new = `FORM t_1.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 2' iv_old = `FORM t_1.` iv_beacon = 2 ). add_expected( iv_new_num = ' 4' iv_new = `ENDFORM.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 3' iv_old = `ENDFORM.` iv_beacon = 2 ). add_expected( iv_new_num = ' 5' iv_new = `FORM t_2.` iv_result = zif_abapgit_definitions=>c_diff-insert iv_old_num = ' ' iv_old = `` iv_beacon = 3 ). add_expected( iv_new_num = ' 6' iv_new = `ENDFORM.` iv_result = zif_abapgit_definitions=>c_diff-insert iv_old_num = ' ' iv_old = `` iv_beacon = 3 ). test( ). ENDMETHOD. METHOD diff13. " adjusted diffs for delete (workaround for kernel issue) add_old( `REPORT zprog_diff.` ). add_old( `*` ). add_old( `FORM t_1.` ). add_old( `ENDFORM.` ). add_old( `FORM t_2.` ). add_old( `ENDFORM.` ). add_new( `REPORT zprog_diff.` ). add_new( `FORM t_1.` ). add_new( `ENDFORM.` ). add_expected( iv_old_num = ' 1' iv_old = `REPORT zprog_diff.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_new_num = ' 1' iv_new = `REPORT zprog_diff.` iv_beacon = 1 ). add_expected( iv_old_num = ' 2' iv_old = `*` iv_result = zif_abapgit_definitions=>c_diff-delete iv_new_num = ' ' iv_new = `` iv_beacon = 1 ). add_expected( iv_old_num = ' 3' iv_old = `FORM t_1.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_new_num = ' 2' iv_new = `FORM t_1.` iv_beacon = 2 ). add_expected( iv_old_num = ' 4' iv_old = `ENDFORM.` iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_new_num = ' 3' iv_new = `ENDFORM.` iv_beacon = 2 ). add_expected( iv_old_num = ' 5' iv_old = `FORM t_2.` iv_result = zif_abapgit_definitions=>c_diff-delete iv_new_num = ' ' iv_new = `` iv_beacon = 2 ). add_expected( iv_old_num = ' 6' iv_old = `ENDFORM.` iv_result = zif_abapgit_definitions=>c_diff-delete iv_new_num = ' ' iv_new = `` iv_beacon = 2 ). test( ). ENDMETHOD. METHOD diff14. " lines with different whitespace add_new( 'A' ). add_new( `` ). " empty line add_new( ` ` ). " one space add_new( ` ` ). " some spaces add_new( 'E' ). add_new( 'X' ). " no trailing space add_old( 'A' ). add_old( ` ` ). " some spaces add_old( ` ` ). " two spaces add_old( `` ). " empty line add_old( 'E' ). add_old( `X ` ). " some trailing space add_expected( iv_new_num = ' 1' iv_new = 'A' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = 'A' ). add_expected( iv_new_num = ' 2' iv_new = '' iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 2' iv_old = ` ` ). add_expected( iv_new_num = ' 3' iv_new = ` ` iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 3' iv_old = ` ` ). add_expected( iv_new_num = ' 4' iv_new = ` ` iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 4' iv_old = '' ). add_expected( iv_new_num = ' 5' iv_new = 'E' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 5' iv_old = 'E' ). add_expected( iv_new_num = ' 6' iv_new = 'X' iv_result = zif_abapgit_definitions=>c_diff-update iv_old_num = ' 6' iv_old = `X ` ). test( ). ENDMETHOD. METHOD diff15. " ignore comments - edge case new comment add_new( `*/` ). add_old( '' ). add_expected( iv_new_num = ' 1' iv_new = '*/' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' ' iv_old = '' ). test( iv_ignore_comments = abap_true ). ENDMETHOD. METHOD diff16. " ignore comments - edge case deleted comment add_new( `` ). add_old( `* " problem` ). add_expected( iv_new_num = ' ' iv_new = '' iv_result = zif_abapgit_definitions=>c_diff-unchanged iv_old_num = ' 1' iv_old = `* " problem` ). test( iv_ignore_comments = abap_true ). ENDMETHOD. METHOD map_beacons. add_new( `REPORT ztest_beacon.` ). add_new( `` ). add_new( `DATA report TYPE string.` ). add_new( `report = 'TEST'.` ). add_new( `` ). add_new( `CLASS lcl_test DEFINITION.` ). add_new( ` PUBLIC SECTION.` ). add_new( ` CLASS-METHODS test.` ). add_new( `ENDCLASS.` ). add_new( `` ). add_new( `CLASS lcl_test IMPLEMENTATION.` ). add_new( ` METHOD test.` ). add_new( ` DATA method TYPE i.` ). add_new( ` method = 10.` ). add_new( ` ENDMETHOD.` ). add_new( `ENDCLASS.` ). add_new( `` ). add_new( `TYPE-POOLS abap.` ). add_new( `` ). add_new( `START-OF-SELECTION.` ). add_new( ` CALL METHOD lcl_test=>test.` ). add_new( `` ). add_new( `AT SELECTION-SCREEN.` ). add_new( ` BREAK-POINT.` ). add_old( '' ). add_beacon( `REPORT ztest_beacon` ). add_beacon( `CLASS lcl_test DEFINITION` ). add_beacon( `CLASS lcl_test PUBLIC SECTION` ). add_beacon( `CLASS lcl_test IMPLEMENTATION` ). add_beacon( `CLASS lcl_test => METHOD test` ). add_beacon( `START-OF-SELECTION` ). add_beacon( `AT SELECTION-SCREEN` ). test( iv_check_beacons = abap_true ). ENDMETHOD. ENDCLASS. |