Static code analysis for CONDITION COVERAGE
Condition coverage is a software testing metric that ensures each atomic condition in a decision (e.g., a > 0 , b == 5 ) is evaluated to both true and false at least once, regardless of the overall outcome of the full expression. It helps identify whether all logical components of a conditional statement have been tested individually. This program performs a simple static analysis by counting the number of if statements in the source file and identifying the line numbers where they appear. The goal is to help locate decision points in the code. Each if may contain one or more sub-conditions that need to be tested for condition coverage. By identifying the number and location of if statements, testers can better understand the logical complexity of the code and plan test cases to ensure adequate coverage. Condition Coverage (%) = (Number of conditions evaluated to both true and false) / (Total number of conditions) × 100 #include <iostream> #in...