|
Software Verification
An Introduction to Code Reviews and Testing |
|
Prof. David Bernstein |
| Computer Science Department |
| bernstdh@jmu.edu |
// An example in pseudocode
a = getNextInt();
b = getNextInt();
c = a/b;
print(c);
b
and not providing a default value for
b or c
b having the value 0Nerd Humor
// An example in pseudocode
int calculate(int x, int y)
{
int a, b;
a = 1; // S1
if (x > y) // S2
a = 2; // S3
x++; // S4
b = y * a; // S5
if (y <= 0) // S6
b++; // S7
return b; // S8
}
// An example in pseudocode
int calculate(int x, int y)
{
int a, b;
a = 1; // S1
if (x > y) // S2
a = 2; // S3
x++; // S4
b = y * a; // S5
if (y <= 0) // S6
b++; // S7
return b; // S8
}
calculate(5, -2) (S1-S2-S3-S4-S5-S6-S7-S8)calculate( 5, 2) (S1-S2-S3-S4-S5-S6-S8)calculate(-2, -1) (S1-S2-S4-S5-S6-S7-S8)calculate( 5, 2) (S1-S2-S3-S4-S5-S6-S8)calculate(-2, 5) (S1-S2-S4-S5-S6-S8)calculate(-1,-2) (S1-S2-S3-S4-S5-S6-S7-S8)calculate(-2,-1) (S1-S2-S4-S5-S6-S7-S8)(x > 0) && (y > 0)
has 4 conditions(x > 0) && (x < 100) really
only has three multiple conditions