If an expression negates a complex expression, it can be simplified by applying the logical not to each term in the expression and then changing each and to an or and each or to an and.
!((score < 0) && (score > 100))
It is difficult to tell because of the negative logic.
(!(score < 0) || !(score > 100))
((score >= 0) || (score <= 100))
Score |
Expected Result |
Notes |
End Result |
Correct? |
95 |
is valid, should evaluate to true |
((95 >= 0) || (95 <= 100)) |
true |
|
0 |
is valid, should evaluate to true |
((0 >= 0) || (0 <= 100)) |
true |
|
100 |
is valid, should evaluate to true |
((100 >= 0) || (100 <= 100)) |
true |
|
101 |
is not valid, should evaluate to false |
((101 >= 0) || (101 <= 100)) |
true |
|
-3 |
is not valid, should evaluate to false |
((-3 >= 0) || (-3 <= 100)) |
true |
|
Quick Review: Which tests are bounds tests? Which are branch tests? Are there any error tests? |
((score >= 0) && (score <= 100))
Score |
Expected Result |
Notes |
End Result |
Correct? |
95 |
is valid, should evaluate to true |
((95 >= 0) && (95 <= 100)) |
true |
|
0 |
is valid, should evaluate to true |
((0 >= 0) && (0 <= 100)) |
true |
|
100 |
is valid, should evaluate to true |
((100 >= 0) && (100 <= 100)) |
true |
|
101 |
is not valid, should evaluate to false |
((101 >= 0) && (101 <= 100)) |
false |
|
-3 |
is not valid, should evaluate to false |
((-3 >= 0) && (-3 <= 100)) |
false |
|