froglogic / Coco / Function Coverage

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++.

Coverage Levels


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 61508DO-178CEN 50128
A = +1 = ++N/AN/A
B = +2 = ++N/AN/A
C = ++3 = ++N/AN/A
D = ++4 = ++N/AN/A
Tabel 1. Function Coverage. Key: + denotes recommended; ++ denotes highly recommended, or, mandatory.

*architectural level; function coverage is not required at the unit level

Copy link
Powered by Social Snap