Function Coverage
Metric Definition
The function coverage of a program counts how many functions were called (and how often). Here, the count includes member functions (or methods) in object-oriented programming languages like C++.
Example
The following code sample checks whether a given credit card number is valid.
For a sample invocation:
validCCN({ 4, 5, 3, 9, 1, 4, 8, 8, 0, 3, 4, 3, 6, 4, 6, 7 });
The code coverage visualization is displayed as:
With 100% function coverage.
Advantages & Disadvantages
This metric reports the call count of a function; it does not pay mind to the execution of the body of the function. It is thus generally useful as an initial assessment of a project’s coverage, but higher-order metrics are generally required for more in-depth analysis.
Relevance for Safety Standards
ISO 26262* | IEC 61508 | DO-178C | EN 50128 |
---|---|---|---|
A = + | 1 = ++ | N/A | N/A |
B = + | 2 = ++ | N/A | N/A |
C = ++ | 3 = ++ | N/A | N/A |
D = ++ | 4 = ++ | N/A | N/A |
Table 1. Function Coverage. Key: + denotes recommended; ++ denotes highly recommended, or, mandatory.
*architectural level; function coverage is not required at the unit level