Created attachment 166 [details] Test case for index out of bound exception when input smaller than -1 Some functions in the system allow user to select multiple items before doing action to them, so that the user do not need to repeat a function to do actions on multiple items, the UI handle this interaction by using -1 as indicator to stop, however, if the user enter a value smaller than -1, exception occur. -------------------------------------------------------------------------------- Welcome to CMS! ============================================== Login =============================================== Please enter your staff ID: d Please enter your password: d ============================================ Main Menu ============================================= Login as [Doctor] Dr. dummer dr one | d | 0. Patient Mangement 1. Appointment Management 2. MedRecord Management 3. Medicine Management 4. Admin 5. Logoff Please select a function: 2 ======================================= MedRecord Management ======================================= 0. Diagnose & Prescribe 1. Dispense 2. Edit Prescription Please select a function: 0 ========================================== Select Patient ========================================== Please input patient's HKID: a123456 [Patient] Dummy patient | M | a123456 | 2020-06-29 | ============================================= Diagnose ============================================= Diagnosis content: flu New diagnosis added successfully. Prescribe? (Y/N): Y ======================================= Patient's Allergies ======================================== None Enter any key to continue. ========================================== Medicine List =========================================== -1. Enter -1 to finish. 0. [Medicine] m1 | $:100.0/tab | Stock: 2 1. [Medicine] m2 | $:100.0/10mg | Stock: 2 Please select the drugs: 0 Please select the drugs: -2 ============================================== ERROR =============================================== java.lang.IndexOutOfBoundsException: Index -2 out of bounds for length 2