mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 11:46:38 +08:00
hash class, add unit tests (#1226)
This commit is contained in:
parent
597b1a234a
commit
80010875f7
|
@ -3,21 +3,27 @@ CLASS zcl_abapgit_hash DEFINITION
|
|||
CREATE PUBLIC .
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
CLASS-METHODS adler32
|
||||
IMPORTING iv_xstring TYPE xstring
|
||||
RETURNING VALUE(rv_checksum) TYPE zif_abapgit_definitions=>ty_adler32.
|
||||
|
||||
IMPORTING
|
||||
!iv_xstring TYPE xstring
|
||||
RETURNING
|
||||
VALUE(rv_checksum) TYPE zif_abapgit_definitions=>ty_adler32 .
|
||||
CLASS-METHODS sha1
|
||||
IMPORTING iv_type TYPE zif_abapgit_definitions=>ty_type
|
||||
iv_data TYPE xstring
|
||||
RETURNING VALUE(rv_sha1) TYPE zif_abapgit_definitions=>ty_sha1
|
||||
RAISING zcx_abapgit_exception.
|
||||
|
||||
IMPORTING
|
||||
!iv_type TYPE zif_abapgit_definitions=>ty_type
|
||||
!iv_data TYPE xstring
|
||||
RETURNING
|
||||
VALUE(rv_sha1) TYPE zif_abapgit_definitions=>ty_sha1
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS sha1_raw
|
||||
IMPORTING iv_data TYPE xstring
|
||||
RETURNING VALUE(rv_sha1) TYPE zif_abapgit_definitions=>ty_sha1
|
||||
RAISING zcx_abapgit_exception.
|
||||
|
||||
IMPORTING
|
||||
!iv_data TYPE xstring
|
||||
RETURNING
|
||||
VALUE(rv_sha1) TYPE zif_abapgit_definitions=>ty_sha1
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
|
42
src/utils/zcl_abapgit_hash.clas.testclasses.abap
Normal file
42
src/utils/zcl_abapgit_hash.clas.testclasses.abap
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
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.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltcl_test IMPLEMENTATION.
|
||||
|
||||
METHOD adler32.
|
||||
|
||||
DATA: lv_adler TYPE zif_abapgit_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_definitions=>ty_sha1.
|
||||
|
||||
lv_sha1 = zcl_abapgit_hash=>sha1(
|
||||
iv_type = zif_abapgit_definitions=>gc_type-commit
|
||||
iv_data = '112211221122' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_sha1
|
||||
exp = 'af2261a340c5188baf86a64a581d22012303023c' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
|
@ -12,6 +12,7 @@
|
|||
<CLSCCINCL>X</CLSCCINCL>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UNICODE>X</UNICODE>
|
||||
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
|
||||
</VSEOCLASS>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
|
|
Loading…
Reference in New Issue
Block a user