Skip to content

Commit 06e86ac

Browse files
committed
C++: Add a few cases to the formatLiteral test.
1 parent c8bf0d0 commit 06e86ac

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

cpp/ql/test/library-tests/printf/formatLiteral/formatLiteral.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@
3939
| test.c:103:10:103:17 | %%%%%f | 320 |
4040
| test.c:104:10:104:18 | %4.2f%% | |
4141
| test.c:105:10:105:17 | %%%f%% | 320 |
42+
| test.c:112:10:112:13 | %f | 318 |
43+
| test.c:113:10:113:15 | %.1f | |
44+
| test.c:114:10:114:14 | %1f | 318 |
45+
| test.c:115:10:115:16 | %1.1f | |
46+
| test.c:116:10:116:13 | %e | 15 |
47+
| test.c:117:10:117:15 | %.2e | |
48+
| test.c:118:10:118:14 | %3e | 15 |
49+
| test.c:119:10:119:16 | %3.2e | |
50+
| test.c:120:10:120:13 | %g | 15 |
51+
| test.c:121:10:121:15 | %.1g | |
52+
| test.c:122:10:122:14 | %4g | 15 |
53+
| test.c:123:10:123:16 | %4.1g | |

cpp/ql/test/library-tests/printf/formatLiteral/formatType.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@
3737
| test.c:103:10:103:17 | %%%%%f | 0 | | f | | file://:0:0:0:0 | double |
3838
| test.c:104:10:104:18 | %4.2f%% | 0 | | f | | file://:0:0:0:0 | double |
3939
| test.c:105:10:105:17 | %%%f%% | 0 | | f | | file://:0:0:0:0 | double |
40+
| test.c:112:10:112:13 | %f | 0 | | f | | file://:0:0:0:0 | double |
41+
| test.c:113:10:113:15 | %.1f | 0 | | f | | file://:0:0:0:0 | double |
42+
| test.c:114:10:114:14 | %1f | 0 | | f | | file://:0:0:0:0 | double |
43+
| test.c:115:10:115:16 | %1.1f | 0 | | f | | file://:0:0:0:0 | double |
44+
| test.c:116:10:116:13 | %e | 0 | | e | | file://:0:0:0:0 | double |
45+
| test.c:117:10:117:15 | %.2e | 0 | | e | | file://:0:0:0:0 | double |
46+
| test.c:118:10:118:14 | %3e | 0 | | e | | file://:0:0:0:0 | double |
47+
| test.c:119:10:119:16 | %3.2e | 0 | | e | | file://:0:0:0:0 | double |
48+
| test.c:120:10:120:13 | %g | 0 | | g | | file://:0:0:0:0 | double |
49+
| test.c:121:10:121:15 | %.1g | 0 | | g | | file://:0:0:0:0 | double |
50+
| test.c:122:10:122:14 | %4g | 0 | | g | | file://:0:0:0:0 | double |
51+
| test.c:123:10:123:16 | %4.1g | 0 | | g | | file://:0:0:0:0 | double |

cpp/ql/test/library-tests/printf/formatLiteral/test.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,22 @@ void more_cases(int a, int b)
104104
printf("%4.2f%%", num);
105105
printf("%%%f%%", num);
106106
}
107+
108+
// more tests of width and precision
109+
{
110+
float num;
111+
112+
printf("%f", num);
113+
printf("%.1f", num);
114+
printf("%1f", num);
115+
printf("%1.1f", num);
116+
printf("%e", num);
117+
printf("%.2e", num);
118+
printf("%3e", num);
119+
printf("%3.2e", num);
120+
printf("%g", num);
121+
printf("%.1g", num);
122+
printf("%4g", num);
123+
printf("%4.1g", num);
124+
}
107125
}

0 commit comments

Comments
 (0)