Skip to content

Commit 4d55a70

Browse files
committed
Modify/Add test cases to 21-13
1 parent 71f4dc4 commit 4d55a70

File tree

1 file changed

+17
-6
lines changed
  • c/misra/test/rules/RULE-21-13

1 file changed

+17
-6
lines changed

c/misra/test/rules/RULE-21-13/test.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,33 @@ void sample() {
55
unsigned char c1 = 'c';
66
int r1 = isalnum(
77
c1); // COMPLIANT: ASCII 99 is within unsigned char range of [0, 255]
8-
unsigned char x1 = EOF;
9-
unsigned char x2 = x1;
10-
unsigned char c2 = x2;
11-
int r2 = isdigit(c2); // COMPLIANT: EOF (-1)
8+
int r2 = isdigit(EOF); // COMPLIANT: EOF (-1)
129

1310
int x3 = 256;
1411
int x4 = x3;
1512
int c3 = x4;
1613
int r3 =
17-
islower(c3); // NON_COMPLIANT: is outside unsigned char range of[0, 255]
14+
islower(c3); // NON_COMPLIANT: is outside unsigned char range of [0, 255]
1815

1916
unsigned char x5 = EOF;
2017
unsigned char x6 = x5;
2118
int c4 = x6 + 10000;
2219
int r4 =
23-
isdigit(c4); // NON_COMPLIANT: is outside unsigned char range of[0, 255]
20+
isdigit(c4); // NON_COMPLIANT: is outside unsigned char range of [0, 255]
21+
22+
int c5 = getchar();
23+
int r5 = isdigit(c5); // COMPLIANT[FALSE_POSITIVE]: library functions like
24+
// getchar needs to be modelled
25+
26+
unsigned char x7 = 1;
27+
char c6;
28+
if (x7 == 1) {
29+
c6 = EOF;
30+
} else {
31+
c6 = 'c';
32+
}
33+
int r6 =
34+
isdigit(c6); // COMPLIANT: either control branch make this call compliant.
2435
}
2536

2637
int main() { return 0; }

0 commit comments

Comments
 (0)