Relational Boundary Coverage
Percentage of relational operations that are tested by current test cases
Since R2023b
Description
Relational boundary is a metric that records whether a test
examines a relational operation with equal values and values that differ slightly.
Consider an arbitrary relational operation operator(left,right).
Depending on the data type of left and right,
this operation has two or three boundaries.
| Integer | Float |
|---|---|
|
The inclusivity of the limits
|
To obtain 100% relational boundary coverage, add test cases that can examine all the appropriate boundaries. For instance, consider this code:
void foo(int a, int b){
//...
if(a>b){
//...
}
}a>b, test the function
foo with these values of a and
b:
a == ba == b+1a == b-1
Note that in the Polyspace
Platform user interface, you do not see relational boundary coverage in a
separate column on the Results List pane. If you select a
decision containing a relational operator (==,
<=, and so on), the Result Details
pane shows this metric. To see more details on how Polyspace®
Test™ calculates this metric, generate an HTML report from your coverage
results. See Structure of HTML Reports Generated from C/C++ Code Profiling Results.
Polyspace Implementation
To calculate the relational boundary coverage, Polyspace calculates the total number of boundaries (B_total)
in your code and the number of boundaries that are tested
(B_tested) by current test
cases:
Boundary Coverage = 100*B_tested/B_total
B_total. For each floating-point
relational operation, Polyspace adds 2 to B_total.For floating-point boundaries, use either a predefined tolerance or specify your own tolerance. The tolerance value depends on the data type of both the operands. If both operands have the same data type, the tolerance follows these rules.
| Data Type of Operand | Tolerance |
|---|---|
| Floating-point |
|
| Integer | 1 |
| Boolean | N/A |
If the two operands have different types, the tolerance follows the
rules for the stricter type. The float type is the strictest
type, followed by int and bool.
Polyspace
Test checks for different relational boundaries when analyzing different
floating-point relational operations. See this table when checking a relational
operation between two floating-point variables left and
right.
| Relational Operation | Checked Boundaries | Comment |
|---|---|---|
left == right | left-right ∈
[-tolerance..0) | left - right == 0 is
excluded. |
left-right ∈
(0..tolerance] | ||
left != right | left-right ∈
[-tolerance..0) | left - right == 0 is
excluded. |
left-right ∈
(0..tolerance] | ||
left <= right | left-right ∈
[-tolerance..0] | left - right == 0 is included in
the region below the relational boundary. |
left-right ∈
(0..tolerance] | ||
left < right | left-right ∈
[-tolerance..0) | left - right == 0 is included in
the region above the relational boundary. |
left-right ∈
[0..tolerance] | ||
left >= right | left-right ∈
[-tolerance..0) | left - right == 0 is included in
the region above the relational boundary. |
left-right ∈
[0..tolerance] | ||
left > right | left-right ∈
[-tolerance..0] | left - right == 0 is included in
the region below the relational boundary. |
left-right ∈ (0..tol] |
Polyspace includes the boundary left - right == 0 below the
relational boundary for <=, but above the relational boundary
for <. This rule is consistent with decision coverage. For instance:
For the relation
left <= right, the decision is true ifleftis less than or equal toright. Polyspace groups<and=together. Therefore,left - right == 0lies in the region below the relational boundary.For the relation
left < right, the decision is true only ifleftis less thanright. Polyspace groups>and=together. Therefore,left - right == 0lies in the region above the relational boundary.
Examples
Version History
Introduced in R2023b