Here is some guidelines in designing good test cases

1. Must include sample input, the most trivial one, you even have the answer given.
2. Must include boundary cases, what is the maximum n,x,y, or other input variables, try
varying their values to test for out of bound errors.
3. For multiple input test case, try using two identical test case consecutively. Both must
output the same result. This is to check whether you forgot to initialize some variables,
which will be easily identified if the first instance produce correct output but the second
one doesn't.
4. Increase the size of input. Sometimes your program works for small input size, but
behave wrongly when input size increases.
5. Tricky test cases, analyze the problem description and identify parts that are tricky, test
them to your code.
6. Don't assume input will always nicely formatted if the problem description didn't say so. Try inserting white spaces (space, tabs) in your input, check whether your code is able
to read in the values correctly
7. Finally, do random test cases, try random input and check your code's correctness.

你可能感兴趣的:(网络,职场,休闲,交换)