ON AND OFF POINTS
6.5 ON AND OFF POINTS
In domain testing a programmer targets domain errors where test cases are designed with the objective of revealing the domain errors as discussed in Section 6.4. Therefore, it is essential that we consider an important characteristic of domain errors, stated as follows: Data points on or near a boundary are most sensitive to domain errors . In this observation, by sensitive we mean data points falling in the wrong domains. Therefore, the objective is to identify the data points that are most sensitive to domain errors so that errors can be detected by executing the program with those input values. In the following, we define two kinds of data points near domain boundaries, namely, ON point and OFF point:
ON Point : Given a boundary, an ON point is a point on the boundary or “very close” to the boundary. This definition suggests that we can choose an ON point in two ways. Therefore, one must know when to choose an ON point in which way:
• If a point can be chosen to lie exactly on the boundary, then choose such a point as an ON point. If the boundary inequality leads to an exact solution, choose such an exact solution as an ON point.
• If a boundary inequality leads to an approximate solution, choose a point very close to the boundary.
Example: Consider the following boundary inequality. This inequality is not related to our running example of Figure 6.4.
P ON1 :
x + 7y ≥ 6
For x = −1, the predicate P ON1 leads to an exact solution of y = 1. Therefore, the point (−1, 1) lies on the boundary.
However, if we choose x = 0, the predicate P ON1 leads to an approximate solution of y in the form of y = 0.8571428 . . . . Since y does not have an exact solution, we either truncate it to 0.857 or round it off to 0.858. We notice that the point (0, 0.857) does not satisfy the predicate P ON1 , whereas the point (0, 0.858) does. Thus, (0, 0.858) is an ON point which lies very close to the P ON1 boundary.
Example: Consider a domain with the following open boundary:
P ON2 :
x + 7y < 6
Points lying exactly on the boundary defined by the predicate
P ′ ON2 :
x + 7y = 6
are not a part of the domain under consideration. The point (−1, 1) lies exactly on the boundary P ′ ON2 and is an ON point. Note that the point (−1, 1) is not a part of
the domain under consideration. Similarly, the point (0, 0.858), which is almost on the boundary, that is, very close to the boundary, is an ON point and it lies outside the domain of interest.
145 OFF Point : An OFF point of a boundary lies away from the boundary.
6.5 ON AND OFF POINTS
However, while choosing an OFF point, we must consider whether a boundary is open or closed with respect to a domain:
• If the domain is open with respect to the boundary, then an OFF point of that boundary is an interior point inside the domain within an ǫ-distance from the boundary.
• If the domain is closed with respect to the boundary, then an OFF point of that boundary is an exterior point outside the boundary within an ǫ-distance. The symbol ǫ denotes an arbitrarily small value.
Example: Consider a domain D 1 with a closed boundary as follows: P OFF1 :
x + 7y ≥ 6
Since the boundary is closed, an OFF point lies outside the domain; this means that the boundary inequality is not satisfied. Note that the point (−1, 1) lies exactly
on the boundary and it belongs to the domain. Therefore, (−1, 1) is not an OFF point. However, the point (−1, 0.99) lies outside the domain, and it is not a part of the domain under consideration. This is easily verified by substituting x = −1 and y = 0.99 in the above P OFF1 inequality which produces a value of 5.93. Therefore, (−1, 0.99) is an OFF point.
Example: Consider a domain D 2 which is adjacent to domain D 1 in the above example with an open boundary as follows:
P OFF2 :
x + 7y < 6
It may be noted that we have obtained POFF2 from POFF1 by simply reversing the ≥ inequality. Since the P OFF2 boundary is open, an OFF point lies inside the
domain. It can be easily verified that the point (− 1, 0.99) lies inside D 2 , and hence it is an OFF point for domain D 2 with respect to boundary P OFF2 .
Summary The above ideas of ON and OFF points lead to the following conclu- sions:
• While testing a closed boundary, the ON points are in the domain under test, whereas the OFF points are in an adjacent domain.
• While testing an open boundary, the ON points are in an adjacent domain, whereas the OFF points are in the domain being tested.
The above ideas have been further explained in Figure 6.6, which shows two domains D 1 and D 2 defined by predicates x < 4 and x ≥ 4, respectively. Therefore, the actual boundary is defined by the following predicate:
P ON,OFF :
x=4
In the figure, we show two ON points A and B , where A lies exactly on the boundary and B lies “very close” to the boundary. Therefore, we have A = 4 and
146 CHAPTER 6 DOMAIN TESTING
Boundary: Open with respect to D 1 Closed with respect to D 2
Domain D 1 (x < 4)
Domain D 2 (x ≥ 4)
x axix
4 ON point for D 1 and D 2 (very close to boundary)
ON point for D 1 and D 2 (lying exactly on boundary) OFF point for D 1 and D 2 (lying away from boundary)
Figure 6.6 ON and OFF points.
B = 4.00001, for example. We show an OFF point C lying in D 1 away from the boundary. Point C = 3.95 lies inside domain D 1 and outside domain D 2 .