- docs/eval-inceleme.md checklist; harness/review.py - 19 accept, 1 fix pending (G0019), 4 flagged (I/E tasks solvable without legacy code) - generator: categories I and E fix/refactor the seed object in place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
146 lines
5.2 KiB
ABAP
146 lines
5.2 KiB
ABAP
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
CONSTANTS:
|
|
c_fri_05 TYPE d VALUE '20240105',
|
|
c_sat_06 TYPE d VALUE '20240106',
|
|
c_sun_07 TYPE d VALUE '20240107',
|
|
c_mon_08 TYPE d VALUE '20240108',
|
|
c_tue_09 TYPE d VALUE '20240109',
|
|
c_wed_10 TYPE d VALUE '20240110',
|
|
c_thu_11 TYPE d VALUE '20240111',
|
|
c_fri_12 TYPE d VALUE '20240112'.
|
|
|
|
DATA mo_cut TYPE REF TO {{p}}delivery_schedule.
|
|
DATA mt_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
|
|
DATA mt_no_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
|
|
|
|
METHODS setup.
|
|
METHODS weekend_is_not_working FOR TESTING.
|
|
METHODS working_day_is_true FOR TESTING.
|
|
METHODS holiday_is_not_working FOR TESTING.
|
|
METHODS next_day_same_for_workday FOR TESTING.
|
|
METHODS next_day_from_weekend FOR TESTING.
|
|
METHODS next_day_skips_holidays FOR TESTING.
|
|
METHODS add_zero_days FOR TESTING.
|
|
METHODS add_days_forward FOR TESTING.
|
|
METHODS add_forward_skips_holiday FOR TESTING.
|
|
METHODS add_days_backward FOR TESTING.
|
|
METHODS count_working_days_inclusive FOR TESTING.
|
|
METHODS count_reversed_range_is_zero FOR TESTING.
|
|
METHODS count_duplicate_holidays FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
|
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}delivery_schedule( ).
|
|
mt_holidays = VALUE #( ( c_tue_09 ) ( c_wed_10 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD weekend_is_not_working.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = abap_false
|
|
act = mo_cut->is_working_day( iv_date = c_sat_06 it_holidays = mt_no_holidays )
|
|
msg = 'Saturday is not a working day' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = abap_false
|
|
act = mo_cut->is_working_day( iv_date = c_sun_07 it_holidays = mt_no_holidays )
|
|
msg = 'Sunday is not a working day' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD working_day_is_true.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = abap_true
|
|
act = mo_cut->is_working_day( iv_date = c_mon_08 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD holiday_is_not_working.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = abap_false
|
|
act = mo_cut->is_working_day( iv_date = c_tue_09 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD next_day_same_for_workday.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_mon_08
|
|
act = mo_cut->next_working_day( iv_date = c_mon_08 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD next_day_from_weekend.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_mon_08
|
|
act = mo_cut->next_working_day( iv_date = c_sat_06 it_holidays = mt_no_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD next_day_skips_holidays.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_thu_11
|
|
act = mo_cut->next_working_day( iv_date = c_tue_09 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD add_zero_days.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_sat_06
|
|
act = mo_cut->add_working_days( iv_start = c_sat_06 iv_days = 0 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD add_days_forward.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_tue_09
|
|
act = mo_cut->add_working_days( iv_start = c_fri_05 iv_days = 2 it_holidays = mt_no_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD add_forward_skips_holiday.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_thu_11
|
|
act = mo_cut->add_working_days( iv_start = c_fri_05 iv_days = 2 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD add_days_backward.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_fri_05
|
|
act = mo_cut->add_working_days( iv_start = c_mon_08 iv_days = -1 it_holidays = mt_no_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD count_working_days_inclusive.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 5
|
|
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = mt_no_holidays )
|
|
msg = 'Monday to Friday without holidays' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 3
|
|
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = mt_holidays )
|
|
msg = 'Two holidays in the interval' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 1
|
|
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_mon_08 it_holidays = mt_no_holidays )
|
|
msg = 'One working day' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0
|
|
act = mo_cut->count_working_days( iv_from = c_tue_09 iv_to = c_tue_09 it_holidays = mt_holidays )
|
|
msg = 'One holiday' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD count_duplicate_holidays.
|
|
DATA(lt_holidays) = VALUE {{p}}delivery_schedule=>ty_holidays(
|
|
( c_tue_09 ) ( c_tue_09 ) ( CONV d( '20240201' ) ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 4
|
|
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = lt_holidays )
|
|
msg = 'A duplicate holiday counts one time; a holiday outside the interval has no effect' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = abap_false
|
|
act = mo_cut->is_working_day( iv_date = c_tue_09 it_holidays = lt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD count_reversed_range_is_zero.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0
|
|
act = mo_cut->count_working_days( iv_from = c_fri_12 iv_to = c_mon_08 it_holidays = mt_holidays ) ).
|
|
ENDMETHOD.
|
|
|
|
ENDCLASS.
|