Skip to content

Commit c330ed6

Browse files
committed
EssentialTypes: Add test cases for library
1 parent 2c106bc commit c330ed6

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
| test.c:4:20:4:20 | 1 | signed char | signed char | essentially Signed type |
2+
| test.c:4:20:4:20 | (unsigned int)... | unsigned int | unsigned int | essentially Unsigned type |
3+
| test.c:5:23:5:23 | 1 | signed char | signed char | essentially Signed type |
4+
| test.c:5:23:5:23 | (unsigned short)... | unsigned short | unsigned short | essentially Unsigned type |
5+
| test.c:6:17:6:18 | 1 | signed char | signed char | essentially Signed type |
6+
| test.c:7:21:7:21 | 1 | signed char | signed char | essentially Signed type |
7+
| test.c:7:21:7:21 | (signed short)... | signed short | signed short | essentially Signed type |
8+
| test.c:8:13:8:16 | 1 | bool | bool | essentially Boolean type |
9+
| test.c:8:13:8:16 | (bool)... | bool | bool | essentially Boolean type |
10+
| test.c:10:3:10:3 | b | bool | bool | essentially Boolean type |
11+
| test.c:10:3:10:11 | ... ? ... : ... | unsigned int | unsigned int | essentially Unsigned type |
12+
| test.c:10:7:10:7 | u | unsigned int | unsigned int | essentially Unsigned type |
13+
| test.c:10:11:10:11 | u | unsigned int | unsigned int | essentially Unsigned type |
14+
| test.c:11:3:11:3 | b | bool | bool | essentially Boolean type |
15+
| test.c:11:3:11:11 | ... ? ... : ... | signed int | signed int | essentially Signed type |
16+
| test.c:11:7:11:7 | s | signed int | signed int | essentially Signed type |
17+
| test.c:11:11:11:11 | s | signed int | signed int | essentially Signed type |
18+
| test.c:12:3:12:3 | b | bool | bool | essentially Boolean type |
19+
| test.c:12:3:12:12 | ... ? ... : ... | signed int | signed int | essentially Signed type |
20+
| test.c:12:7:12:7 | s | signed int | signed int | essentially Signed type |
21+
| test.c:12:11:12:12 | (int)... | int | int | essentially Signed type |
22+
| test.c:12:11:12:12 | ss | signed short | signed short | essentially Signed type |
23+
| test.c:13:3:13:3 | b | bool | bool | essentially Boolean type |
24+
| test.c:13:3:13:12 | ... ? ... : ... | signed int | signed int | essentially Signed type |
25+
| test.c:13:7:13:8 | (int)... | int | int | essentially Signed type |
26+
| test.c:13:7:13:8 | ss | signed short | signed short | essentially Signed type |
27+
| test.c:13:12:13:12 | s | signed int | signed int | essentially Signed type |
28+
| test.c:14:3:14:3 | b | bool | bool | essentially Boolean type |
29+
| test.c:14:3:14:12 | ... ? ... : ... | unsigned int | unsigned int | essentially Unsigned type |
30+
| test.c:14:7:14:8 | (unsigned int)... | unsigned int | unsigned int | essentially Unsigned type |
31+
| test.c:14:7:14:8 | us | unsigned short | unsigned short | essentially Unsigned type |
32+
| test.c:14:12:14:12 | u | unsigned int | unsigned int | essentially Unsigned type |
33+
| test.c:16:3:16:3 | b | bool | bool | essentially Boolean type |
34+
| test.c:16:3:16:11 | ... ? ... : ... | unsigned int | unsigned int | essentially Unsigned type |
35+
| test.c:16:7:16:7 | (unsigned int)... | unsigned int | unsigned int | essentially Unsigned type |
36+
| test.c:16:7:16:7 | s | signed int | signed int | essentially Signed type |
37+
| test.c:16:11:16:11 | u | unsigned int | unsigned int | essentially Unsigned type |
38+
| test.c:26:3:26:3 | f | float | float | essentially Floating type |
39+
| test.c:27:3:27:5 | f32 | float32_t | float32_t | essentially Floating type |
40+
| test.c:28:3:28:6 | cf32 | float | float | essentially Floating type |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import codingstandards.c.misra.EssentialTypes
22

3-
from Expr e
4-
select e, getEssentialType(e) as et, getEssentialTypeBeforeConversions(e),
5-
getEssentialTypeCategory(et)
3+
from Expr e, Type et
4+
where et = getEssentialType(e)
5+
select e, et.getName(), getEssentialTypeBeforeConversions(e).getName(), getEssentialTypeCategory(et)

c/misra/test/c/misra/test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@ void testConditional() {
1414
b ? us : u; // unsigned int
1515

1616
b ? s : u; // unsigned int
17+
}
18+
19+
void testCategoriesForComplexTypes() {
20+
typedef float float32_t;
21+
typedef const float cfloat32_t;
22+
const float f;
23+
const float32_t f32;
24+
cfloat32_t cf32;
25+
26+
f; // Should be essentially Floating type
27+
f32; // Should be essentially Floating type
28+
cf32; // Should be essentially Floating type
1729
}

0 commit comments

Comments
 (0)