All files / src/git zcl_abapgit_hash.clas.testclasses.abap

100% Statements 74/74
100% Branches 4/4
100% Functions 4/4
100% Lines 74/74

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 751x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_test DEFINITION FOR TESTING
  DURATION SHORT
  RISK LEVEL HARMLESS FINAL.
 
  PRIVATE SECTION.
    METHODS:
      adler32 FOR TESTING,
      sha1 FOR TESTING RAISING zcx_abapgit_exception,
      sha1_raw_valid FOR TESTING RAISING zcx_abapgit_exception,
      sha1_raw_empty FOR TESTING RAISING zcx_abapgit_exception.
 
ENDCLASS.
 
 
CLASS ltcl_test IMPLEMENTATION.
 
  METHOD adler32.
 
    DATA: lv_adler TYPE zif_abapgit_git_definitions=>ty_adler32.
 
    lv_adler = zcl_abapgit_hash=>adler32( '1122334455667788' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_adler
      exp = '08000265' ).
 
  ENDMETHOD.
 
  METHOD sha1.
 
    DATA: lv_sha1 TYPE zif_abapgit_git_definitions=>ty_sha1.
 
    lv_sha1 = zcl_abapgit_hash=>sha1(
      iv_type = zif_abapgit_git_definitions=>c_type-commit
      iv_data = '112211221122' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_sha1
      exp = 'af2261a340c5188baf86a64a581d22012303023c' ).
 
  ENDMETHOD.
 
 
  METHOD sha1_raw_valid.
 
    DATA: lv_sha1  TYPE zif_abapgit_git_definitions=>ty_sha1,
          lv_input TYPE xstring.
 
    lv_input = 'C5188BAF86A64A581D2201'.
    lv_sha1 = zcl_abapgit_hash=>sha1_raw( lv_input ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_sha1
      exp = '0ec2eba75071f87988ced3237cae5ec7c5efd795' ).
 
  ENDMETHOD.
 
  METHOD sha1_raw_empty.
 
    DATA: lv_sha1  TYPE zif_abapgit_git_definitions=>ty_sha1,
          lv_input TYPE xstring.
 
* a value like 'LOREM_IPSUM' will get an empty xstring,
    lv_input = ''.
    lv_sha1 = zcl_abapgit_hash=>sha1_raw( lv_input ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_sha1
      exp = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' ).
 
  ENDMETHOD.
 
ENDCLASS.