Minjiang College School of the next 2015-2016 years software testing course-Third blog assignment

Source: Internet
Author: User

Minjiang College School of the next 2015-2016 years software testing course-Third blog assignment

Job Submission class: 13 Soft Gold 2 class all students

Deadline for job submission: April 30, 2016 before 24:00 (no results submitted after the deadline)

1, a website management system, the user registration, the phone number is optional input, the input format is: Area code-Telephone number-extension number, in the middle with "-" separated. The following is the design on the JSP page and does not have any control over the input.

The system now needs to take out the middle Phone number section, the code is as follows:

/**

*

* This method takes the middle phone number part according to user input.

* @param strphonenum phone number, such as: "0591-83279988-002"

* @return return number section, e.g. "83279988"

*/

public string Getphonenumber (string strphonenum) {

if ((strphonenum==null) | | | "". Equals (Strphonenum)) {

Return "";

}

String[] Arrphone=strphonenum.split ("-");

return arrphone[1];

}

Use the techniques and methods you have learned to identify the problems in this approach, and analyze the cause of the problem, and give your solution. (Hint: there is more than one problem)

Requirements:

(1) Write the question

(2) Write down the reason why the problem arises

(3) Give the modified code

2, write a paragraph for the integer array sorting code, explain your design ideas, and use the error-guessing method to give a possible error (at least 5), design the test case, and use JUnit to write unit tests to test. (assuming that the passed-in parameter has been determined to be an integer array)

Requirements:

(1) Write code, and conform to code specification (naming to specification, not directly written in the main method, need to have class comments, method comments, and appropriate line comments)

(2) Explain your design ideas

(3) Write a possible error (at least five kinds)

(4) Write JUnit unit tests to put the test data that was previously given in the possible error into the unit test for testing

For:

1.

(1). (1) Problem: There is no limit to the length of the number can be entered, there is no judge whether the input is a number or a string, there is no judge whether it is empty

(2) Insufficient conditions

(3)

public string Getphonenumber (string strphonenum) {
if ((strphonenum==null) | | | "". Equals (Strphonenum)) {
if (strphonenum.lenth==8 &&!pattern.compile ("^\\d{8}$"). Matcher (Phonenumber.trim
()). Matches ())) {
Return "true";
}

}else{

Return "false";
System.out.println ("The number you entered is not in the correct format!!! ");
}
String[] Arrphone=strphonenum.split ("-");
return arrphone[1];
}

2.

(1).

Package Cn.zhuang;

Public class test{

/**

* Simple Sorting

* @author Zhongzhaoqing

*/

Public Static int [] px (int[] a) {

int J;

int temp;

for ( int i=0;i<a.length-1;i++) {

for (j=i+1;j<a.length;j++) {

if (A[i]>a[j]) {

Temp=a[i];

A[I]=A[J];

A[j]=temp;

}

}

}

for (int i:a) {//assigns the value of x to the output after I

System. out. println (i + "");

}

return A;

}

}

Public Static void Main (string[] args) {

TODO auto-generated Method stub

int [] i={1,2,3,5,7};

System. out. println ("The result of sorting is:");

Test (i); Call Sort method

System. out. println ();

}

(2) Design ideas: Using simple sorting algorithm, from small to large sort

(3) A. The input values are already sorted.

B. Some or all of the elements in the array are the same:

C. Array without numbers

D. Array number 0 start

E. Array numbers consist of a number and have negative numbers

Minjiang College School of the second semester of the 2015-2016 software testing course-Third blog job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.