Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fa5cb2

Browse files
committed
Add more test cases
- 1. Assigning a char to another char - 1-1. Assigning a char to a char variable - 1-2. Assigning a char to a char member - 1-3. Assigning a char to a char through a pointer- 2. Passing a char argument to a char parameter - 2-1. Passing char argument to a char parameter of a regular function - 2-2. Passing char argument to a char parameter through a template - 2-3. Passing a char argument to a char parameter through a template
1 parent3df1125 commit9fa5cb2

File tree

1 file changed

+353
-10
lines changed

1 file changed

+353
-10
lines changed
Lines changed: 353 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,359 @@
11
#include<cstdint>
22

3-
voidf1() {
4-
unsignedchar a1 ='c';// NON_COMPLIANT
5-
unsignedchar a2 =10;
6-
signedchar a3 ='c';// NON_COMPLIANT
7-
signedchar a4 =10;
3+
template<typename T, T y>classC1 {
4+
public:
5+
C1() : x(y) {}
86

9-
std::int8_t a5 ='c';// NON_COMPLIANT
10-
std::int8_t a6 =10;
7+
private:
8+
unsignedchar x;
9+
};
1110

12-
std::uint8_t a7 ='c';// NON_COMPLIANT
13-
std::uint8_t a8 =10;
11+
template<typename T, T y>classC2 {
12+
public:
13+
C2() : x(y) {}
1414

15-
char a9 ='c';
15+
private:
16+
signedchar x;
17+
};
18+
19+
template<typename T, T y>classC3 {
20+
public:
21+
C3() : x(y) {}
22+
23+
private:
24+
unsignedchar x;
25+
};
26+
27+
template<typename T, T y>classC4 {
28+
public:
29+
C4() : x(y) {}
30+
31+
private:
32+
signedchar x;
33+
};
34+
35+
/* Twin templates for std::uint8_t and std::int8_t*/
36+
template<typename T, T y>classC9 {
37+
public:
38+
C9() : x(y) {}
39+
40+
private:
41+
std::uint8_t x;
42+
};
43+
44+
template<typename T, T y>classC10 {
45+
public:
46+
C10() : x(y) {}
47+
48+
private:
49+
std::int8_t x;
50+
};
51+
52+
template<typename T, T y>classC11 {
53+
public:
54+
C11() : x(y) {}
55+
56+
private:
57+
std::uint8_t x;
58+
};
59+
60+
template<typename T, T y>classC12 {
61+
public:
62+
C12() : x(y) {}
63+
64+
private:
65+
std::int8_t x;
66+
};
67+
68+
voidf1(unsignedchar x) {}
69+
voidf2(signedchar x) {}
70+
voidf3(unsignedchar x) {}
71+
voidf4(signedchar x) {}
72+
73+
/* Twin functions for std::uint8_t and std::int8_t*/
74+
voidf9(std::uint8_t x) {}
75+
voidf10(std::int8_t x) {}
76+
voidf11(std::uint8_t x) {}
77+
voidf12(std::int8_t x) {}
78+
79+
template<typename T>voidf5(T x) {unsignedchar y = x; }
80+
template<typename T>voidf6(T x) {signedchar y = x; }
81+
template<typename T>voidf7(T x) {signedchar y = x; }
82+
template<typename T>voidf8(T x) {signedchar y = x; }
83+
84+
/* Twin template functions for std::uint8_t and std::int8_t*/
85+
template<typename T>voidf13(T x) { std::uint8_t y = x; }
86+
template<typename T>voidf14(T x) { std::int8_t y = x; }
87+
template<typename T>voidf15(T x) { std::int8_t y = x; }
88+
template<typename T>voidf16(T x) { std::int8_t y = x; }
89+
90+
template<typename T>classC5 {
91+
public:
92+
C5(T y) : x(y) {}
93+
94+
private:
95+
unsignedchar x;
96+
};
97+
98+
template<typename T>classC6 {
99+
public:
100+
C6(T y) : x(y) {}
101+
102+
private:
103+
signedchar x;
104+
};
105+
106+
template<typename T>classC7 {
107+
public:
108+
C7(T y) : x(y) {}
109+
110+
private:
111+
signedchar x;
112+
};
113+
114+
template<typename T>classC8 {
115+
public:
116+
C8(T y) : x(y) {}
117+
118+
private:
119+
signedchar x;
120+
};
121+
122+
/* Twin template classes for std::uint8_t and std::int8_t*/
123+
template<typename T>classC13 {
124+
public:
125+
C13(T y) : x(y) {}
126+
127+
private:
128+
std::uint8_t x;
129+
};
130+
131+
template<typename T>classC14 {
132+
public:
133+
C14(T y) : x(y) {}
134+
135+
private:
136+
std::int8_t x;
137+
};
138+
139+
template<typename T>classC15 {
140+
public:
141+
C15(T y) : x(y) {}
142+
143+
private:
144+
std::int8_t x;
145+
};
146+
147+
template<typename T>classC16 {
148+
public:
149+
C16(T y) : x(y) {}
150+
151+
private:
152+
std::int8_t x;
153+
};
154+
155+
intmain() {
156+
157+
/* ========== 1. Assigning a char to another char ==========*/
158+
159+
/* ===== 1-1. Assigning a char to a char variable =====*/
160+
161+
unsignedchar x1 =1;
162+
unsignedchar y1 =
163+
x1;// COMPLIANT: unsigned char assigned to an unsigned char
164+
165+
signedchar x2 =1;
166+
signedchar y2 = x2;// COMPLIANT: signed char assigned to a signed char
167+
168+
char x3 ='x';
169+
unsignedchar y3 = x3;// NON-COMPLIANT: plain char assigned to a unsigned char
170+
171+
char x4 ='x';
172+
signedchar y4 = x4;// NON-COMPLIANT: plain char assigned to a signed char
173+
174+
/* Twin cases with std::uint8_t and std::int8_t*/
175+
std::uint8_t x5 =1;
176+
std::uint8_t y5 =
177+
x5;// COMPLIANT: std::uint8_t assigned to a std::uint8_t
178+
179+
std::int8_t x6 =1;
180+
std::int8_t y6 = x6;// COMPLIANT: std::int8_t assigned to a std::int8_t
181+
182+
char x7 ='x';
183+
std::uint8_t y7 = x7;// NON-COMPLIANT: plain char assigned to a std::uint8_t
184+
185+
char x8 ='x';
186+
std::int8_t y8 = x8;// NON-COMPLIANT: plain char assigned to a std::int8_t
187+
188+
/* ===== 1-2. Assigning a char to a char member =====*/
189+
190+
C1<unsignedchar,1> c1;// COMPLIANT: unsigned char arg passed to an unsigned
191+
// char member through a template
192+
193+
C2<signedchar,1> c2;// COMPLIANT: signed char arg passed to a signed char
194+
// member through a template
195+
196+
C3<char,'x'> c3;// NON-COMPLIANT: plain char arg passed to a unsigned char
197+
// member through a template
198+
199+
C4<char,'x'> c4;// NON-COMPLIANT: plain char arg passed to a signed char
200+
// member through a template
201+
202+
/* Twin cases with std::uint8_t and std::int8_t*/
203+
C9<std::uint8_t,1> c9;// COMPLIANT: std::uint8_t arg passed to a std::uint8_t
204+
// member through a template
205+
206+
C10<std::int8_t,1> c10;// COMPLIANT: std::int8_t arg passed to a std::int8_t
207+
// member through a template
208+
209+
C11<char,'x'> c11;// NON-COMPLIANT: plain char arg passed to a std::uint8_t
210+
// member through a template
211+
212+
C12<char,'x'> c12;// NON-COMPLIANT: plain char arg passed to a std::int8_t
213+
// member through a template
214+
215+
/* ========== 1-3. Assigning a char to a char through a pointer ==========*/
216+
217+
unsignedchar x9 =1;
218+
unsignedchar *y9 = &x9;
219+
signedchar z1 =
220+
*y9;// COMPLIANT: unsigned char assigned to a *&unsigned char
221+
222+
unsignedchar x10 =1;
223+
unsignedchar *y10 = &x10;
224+
signedchar z2 = *y10;// COMPLIANT: signed char assigned to an *&signed char
225+
226+
char x11 =1;
227+
char *y11 = &x11;
228+
unsignedchar z3 =
229+
*y11;// NON-COMPLIANT: plain char assigned to an *&unsigned char
230+
231+
char x12 =1;
232+
char *y12 = &x12;
233+
signedchar z4 =
234+
*y12;// NON-COMPLIANT: plain char assigned to an *&signed char
235+
236+
/* Twin cases with std::uint8_t and std::int8_t*/
237+
std::uint8_t x13 =1;
238+
std::uint8_t *y13 = &x13;
239+
std::int8_t z5 =
240+
*y13;// COMPLIANT: std::uint8_t assigned to a *&std::uint8_t
241+
242+
std::uint8_t x14 =1;
243+
std::uint8_t *y14 = &x14;
244+
std::int8_t z6 = *y14;// COMPLIANT: std::int8_t assigned to an *&std::int8_t
245+
246+
char x15 =1;
247+
char *y15 = &x15;
248+
std::uint8_t z7 =
249+
*y15;// NON-COMPLIANT: plain char assigned to an *&std::uint8_t
250+
251+
char x16 =1;
252+
char *y16 = &x16;
253+
std::int8_t z8 =
254+
*y16;// NON-COMPLIANT: plain char assigned to an *&std::int8_t
255+
256+
/* ========== 2. Passing a char argument to a char parameter ==========*/
257+
258+
/* ===== 2-1. Passing char argument to a char parameter of a regular function
259+
* =====*/
260+
261+
unsignedchar a1 =1;
262+
f1(a1);// COMPLIANT: unsigned char arg passed to an unsigned char parameter
263+
264+
signedchar a2 =1;
265+
f2(a2);// COMPLIANT: signed char arg passed to a signed char parameter
266+
267+
char a3 ='a';
268+
f3(a3);// NON-COMPLIANT: plain char arg passed to a unsigned char parameter
269+
270+
char a4 ='a';
271+
f4(a4);// NON-COMPLIANT: plain char arg passed to a signed char parameter
272+
273+
/* Twin cases with std::uint8_t and std::int8_t*/
274+
std::uint8_t a5 =1;
275+
f9(a5);// COMPLIANT: std::uint8_t arg passed to a std::uint8_t parameter
276+
277+
std::int8_t a6 =1;
278+
f10(a6);// COMPLIANT: std::int8_t arg passed to a std::int8_t parameter
279+
280+
char a7 ='a';
281+
f11(a7);// NON-COMPLIANT: plain char arg passed to a std::uint8_t parameter
282+
283+
char a8 ='a';
284+
f12(a8);// NON-COMPLIANT: plain char arg passed to a std::int8_t parameter
285+
286+
/* ===== 2-2. Passing char argument to a char parameter through a template
287+
* =====*/
288+
289+
unsignedchar a9 ='a';
290+
f5(a9);// COMPLIANT: unsigned char arg passed to an unsigned char parameter
291+
// through a template
292+
293+
signedchar a10 ='a';
294+
f6(a10);// COMPLIANT: signed char arg passed to a signed char parameter
295+
// through a template
296+
297+
char a11 ='a';
298+
f7(a11);// NON-COMPLIANT: plain char arg passed to a unsigned char parameter
299+
// through a template
300+
301+
char a12 ='a';
302+
f8(a12);// COMPLIANT: plain char arg passed to a signed char parameter through
303+
// a template
304+
305+
/* Twin cases with std::uint8_t and std::int8_t*/
306+
std::uint8_t a13 ='a';
307+
f13(a13);// COMPLIANT: std::uint8_t arg passed to a std::uint8_t parameter
308+
// through a template
309+
310+
std::int8_t a14 ='a';
311+
f14(a14);// COMPLIANT: std::int8_t arg passed to a std::int8_t parameter
312+
// through a template
313+
314+
char a15 ='a';
315+
f15(a15);// NON-COMPLIANT: plain char arg passed to a std::uint8_t parameter
316+
// through a template
317+
318+
char a16 ='a';
319+
f16(a16);// COMPLIANT: plain char arg passed to a std::int8_t parameter through
320+
// a template
321+
322+
/* ========== 2-3. Passing a char argument to a char parameter through a
323+
* template ==========*/
324+
325+
unsignedchar a17 =1;
326+
C5<unsignedchar>c5(
327+
a17);// COMPLIANT: unsigned char arg passed to an unsigned char parameter
328+
// of a constructor through a template
329+
330+
signedchar a18 =1;
331+
C6<signedchar>c6(a18);// COMPLIANT: signed char arg passed to an signed
332+
// char parameter of a constructor through a template
333+
334+
char a19 ='a';
335+
C7<char>c7(a19);// NON-COMPLIANT: plain char arg passed to an unsigned char
336+
// parameter of a constructor through a template
337+
338+
char a20 ='a';
339+
C8<char>c8(a20);// NON-COMPLIANT: plain char arg passed to an signed char
340+
// parameter of a constructor through a template
341+
342+
/* Twin cases with std::uint8_t and std::int8_t*/
343+
std::uint8_t a21 =1;
344+
C13<std::uint8_t>c13(
345+
a21);// COMPLIANT: std::uint8_t arg passed to a std::uint8_t parameter
346+
// of a constructor through a template
347+
348+
std::int8_t a22 =1;
349+
C14<std::int8_t>c14(a22);// COMPLIANT: std::int8_t arg passed to a std::int8_t
350+
// parameter of a constructor through a template
351+
352+
char a23 ='a';
353+
C15<char>c15(a23);// NON-COMPLIANT: plain char arg passed to a std::uint8_t
354+
// parameter of a constructor through a template
355+
356+
char a24 ='a';
357+
C16<char>c16(a24);// NON-COMPLIANT: plain char arg passed to a std::int8_t
358+
// parameter of a constructor through a template
16359
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp