![]() |
public String custdel(String[]
args){//to del customer record from Customer_Record table String message=""; String retvalue = args[0]; StringBuffer hold = new StringBuffer(); char c; for ( int i = 0; i < retvalue.length(); i++ ) { //1 if ( (c=retvalue.charAt(i)) != '|' ) //2 hold.append(c); //3 else break; //4 } retvalue = hold.toString(); //5 try{ recUpdate("DELETE FROM Customer_Record WHERE Name ='"+retvalue+"'"); //6 message="The record "+retvalue+" is deleted."; } catch (Exception e){ return message; } // end catch return message; } |
Test case (1): for path 1
Variable values: i< retvalue.length() && c!= ¡®|¡¯
Expected results:
(1) Append I character to a string
(2) Counter incremented
Test case (2): for path 2
Variable values: i > retvalue.length() && c!= ¡®|¡¯
Expected results:
(1) Append 1 character to whole string and goes out of the loop
(2) Find customer record then delete them
(3) Show message
Test case (3): for path 3
Variable values: c== i
Expected result:
(1) Return empty string