1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-26 12:49:21 +00:00

Added a few more printf() error tests.

This commit is contained in:
jespergravgaard 2020-04-25 14:53:14 +02:00
parent 986ad3b77f
commit 4c3b000fbd
3 changed files with 31 additions and 0 deletions

View File

@ -40,6 +40,16 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testPrintfError5() throws IOException, URISyntaxException {
assertError("printf-error-5.c", "Error! printf() format parameter must be a string!");
}
@Test
public void testPrintfError4() throws IOException, URISyntaxException {
assertError("printf-error-4.c", "Error! Only constant printf() format parameter supported!");
}
@Test
public void testPrintfError3() throws IOException, URISyntaxException {
assertError("printf-error-3.c", "Error! If any single printf() placeholder specifies a parameter, all the rest of the placeholders must also specify a parameter!");

View File

@ -0,0 +1,12 @@
// Tests printf function call rewriting
// Non-constant format parameter
#include <printf.h>
void main() {
char* fmt = "%d";
printf(fmt, 1);
fmt = "%hhx";
printf(fmt, 1);
}

View File

@ -0,0 +1,9 @@
// Tests printf function call rewriting
// Non-string format parameter
#include <printf.h>
void main() {
printf(1, 1);
}