Skip to content

Commit 4480120

Browse files
authored
Add passing and failing tests for IncludeGuardsNotUsed exclusion check feedback (#1195)
* Add passing/failing tests for IncludeGuardsNotUsed exclusion behavior
1 parent c81f117 commit 4480120

12 files changed

Lines changed: 46 additions & 2 deletions

File tree

c/common/test/rules/includeguardsnotused/IncludeGuardsNotUsed.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| headers/test4.h:0:0:0:0 | headers/test4.h | Header file test4.h is missing expected include guard. | headers/test4.h:0:0:0:0 | headers/test4.h | |
33
| headers/test5.h:0:0:0:0 | headers/test5.h | Header file test5.h is missing expected include guard. | headers/test5.h:0:0:0:0 | headers/test5.h | |
44
| headers/test7.h:0:0:0:0 | headers/test7.h | Header file test7.h is never included by reusing the include guard used by $@. | headers/test6.h:0:0:0:0 | headers/test6.h | include guard |
5+
| headers/test8.h:0:0:0:0 | headers/test8.h | Header file test8.h is missing expected include guard. | headers/test8.h:0:0:0:0 | headers/test8.h | |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<codingstandards>
3+
<!--GENERATED: DO NOT MODIFY. Changes should be made to coding-standards.yml instead.-->
4+
<deviations>
5+
<deviations-entry>
6+
<rule-id>cpp-test-dummy</rule-id>
7+
<justification>This header is deliberately excluded to test the exclusion mechanism.</justification>
8+
</deviations-entry>
9+
</deviations>
10+
</codingstandards>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
deviations:
2+
- rule-id: cpp-test-dummy
3+
justification: This header is deliberately excluded to test the exclusion mechanism.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// COMPLIANT - excluded via deviation
2+
int g7;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// NON_COMPLIANT
2+
int g6;

c/common/test/rules/includeguardsnotused/test.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111

1212
#include "headers/test6.h" //NON_COMPLIANT - non unique and reported in alert for the next
1313

14-
#include "headers/test7.h" //NON_COMPLIANT - non unique
14+
#include "headers/test7.h" //NON_COMPLIANT - non unique
15+
16+
#include "headers/test8.h" //NON_COMPLIANT - missing include guard, not excluded
17+
18+
#include "headers/excluded/test8.h" //COMPLIANT - missing include guard, but excluded via deviation

cpp/common/test/rules/includeguardsnotused/IncludeGuardsNotUsed.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| headers/test4.hpp:0:0:0:0 | headers/test4.hpp | Header file test4.hpp is missing expected include guard. | headers/test4.hpp:0:0:0:0 | headers/test4.hpp | |
33
| headers/test5.hpp:0:0:0:0 | headers/test5.hpp | Header file test5.hpp is missing expected include guard. | headers/test5.hpp:0:0:0:0 | headers/test5.hpp | |
44
| headers/test6.hpp:0:0:0:0 | headers/test6.hpp | Header file test6.hpp is missing expected include guard. | headers/test6.hpp:0:0:0:0 | headers/test6.hpp | |
5+
| headers/test7.hpp:0:0:0:0 | headers/test7.hpp | Header file test7.hpp is missing expected include guard. | headers/test7.hpp:0:0:0:0 | headers/test7.hpp | |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<codingstandards>
3+
<!--GENERATED: DO NOT MODIFY. Changes should be made to coding-standards.yml instead.-->
4+
<deviations>
5+
<deviations-entry>
6+
<rule-id>cpp-test-dummy</rule-id>
7+
<justification>This header is deliberately excluded to test the exclusion mechanism.</justification>
8+
</deviations-entry>
9+
</deviations>
10+
</codingstandards>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
deviations:
2+
- rule-id: cpp-test-dummy
3+
justification: This header is deliberately excluded to test the exclusion mechanism.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// COMPLIANT - excluded via deviation
2+
int g7;

0 commit comments

Comments
 (0)