Update tests to account for recent ORCALib changes.

These involve recent standards-conformance patches for printf and scanf, which changed some (non-standard) behaviors that the test cases were expecting.

I also fixed a couple things that clang flagged as undefined behavior, even though they weren't really causing problems under ORCA/C.
This commit is contained in:
Stephen Heumann 2021-02-09 23:18:36 -06:00
parent 4a95dbc597
commit 52f512370f
8 changed files with 41 additions and 41 deletions

View File

@ -30,17 +30,17 @@ main ()
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
@ -53,7 +53,7 @@ main ()
if (i != 1)
goto Fail3;
string [55] = '\0';
if (strcmp (string, " +000032767 000032767 -00032767\
if (strcmp (string, " +00032767 00032767 -00032767\
-32767 M"))
goto Fail;
@ -62,11 +62,11 @@ main ()
if (i != 1)
goto Fail3;
string [55] = '\0';
if (strcmp (string, " +000032767 000032767 -00032767\
if (strcmp (string, " +00032767 00032767 -00032767\
-32767 M"))
goto Fail;
if (strcmp (sstring, " +000032767 000032767 -00032767\
if (strcmp (sstring, " +00032767 00032767 -00032767\
-32767 M\n"))
goto Fail;

View File

@ -29,17 +29,17 @@ main ()
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
i = fprintf (f1, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = printf (" %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
i = printf (" %-11.10hu % +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = sprintf (sstring, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
i = sprintf (sstring, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
@ -52,9 +52,9 @@ main ()
if (i != 1)
goto Fail3;
string [44] = '\0';
i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
i = fprintf (f1, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (strcmp (string, " 0000065535 +065535 0000004294967295 A"))
if (strcmp (string, " 0000065535 +65535 0000004294967295 A"))
goto Fail;
rewind (stdout);
@ -62,10 +62,10 @@ main ()
if (i != 1)
goto Fail3;
string [44] = '\0';
if (strcmp (string, " 0000065535 +065535 0000004294967295 A"))
if (strcmp (string, " 0000065535 +65535 0000004294967295 A"))
goto Fail;
if (strcmp (sstring, " 0000065535 +065535 0000004294967295 A\n"))
if (strcmp (sstring, " 0000065535 +65535 0000004294967295 A\n"))
goto Fail;

View File

@ -5,9 +5,9 @@
main ()
{
FILE *f1;
short i1;
short i1, i3;
int i;
int i2, i3;
int i2;
long L1;
char ch;
@ -15,25 +15,25 @@ main ()
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r");
fprintf(f1, " -327678 -0 -002147483647A 327677-22 123*\r");
rewind(f1);
i1 = 0; /* test format string of no */
i = fscanf (f1, "%*05hd8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
i = fscanf (f1, "%*06hd8"); /* assignment, max. field */
if (i != 0) /* width of 6, h ignored, */
goto Fail; /* character 8 must appear*/
if (i1 != 0) /* after 5 digits read */
goto Fail;
i2 = 15; /* test "plain vanilla" fmt */
i = fscanf (f1, "%d", &i2); /* string; data contains */
if (i != 1) /* a single minus sign */
if (i != 1) /* "-0" */
goto Fail;
if (i2 != 0)
goto Fail;
L1 = 0; /* test format string of */
i = fscanf (f1, "%12ldA", &L1); /* max. field width of 12,*/
i = fscanf (f1, "%13ldA", &L1); /* max. field width of 13,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character A must appear*/
if (L1 != -2147483647) /* after digits read */

View File

@ -4,7 +4,7 @@
main ()
{
char string [] = " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10 ";
char string [] = " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10 ";
int i;
unsigned short us1;
unsigned int ui1;
@ -20,12 +20,12 @@ main ()
i = sscanf (&string [8], "%X", &ui1); /* test "plain vanilla" fmt */
if (i != 1) /* string; data contains */
goto Fail; /* the characters 0x */
goto Fail; /* the characters 0x0 */
if (ui1 != 0)
goto Fail;
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [12], " D %12lxm", &ul1); /* field width of 12,*/
i = sscanf (&string [13], " D %12lxm", &ul1); /* field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */

View File

@ -4,9 +4,9 @@
main ()
{
short i1;
short i1, i3;
int i;
int i2, i3;
int i2;
long L1;
char ch;
FILE *f1;
@ -17,7 +17,7 @@ main ()
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r");
fprintf(f1, " +327678 -0 -002147483647A 327677-22 123*\r");
fclose(f1);
stdin = freopen ("3/tmp", "r", stdin);
@ -25,21 +25,21 @@ main ()
goto Fail1;
i1 = 0; /* test format string of no */
i = scanf ("%*05hd8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
i = scanf ("%*06hd8"); /* assignment, max. field */
if (i != 0) /* width of 6, h ignored, */
goto Fail; /* character 8 must appear*/
if (i1 != 0) /* after 5 digits read */
goto Fail;
i2 = 15; /* test "plain vanilla" fmt */
i = scanf ("%d", &i2); /* string; data contains */
if (i != 1) /* a single minus sign */
if (i != 1) /* "-0" */
goto Fail;
if (i2 != 0)
goto Fail;
L1 = 0; /* test format string of */
i = scanf ("%12ldA", &L1); /* max. field width of 12,*/
i = scanf ("%13ldA", &L1); /* max. field width of 13,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character A must appear*/
if (L1 != -2147483647) /* after digits read */

View File

@ -16,7 +16,7 @@ main ()
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10");
fprintf(f1, " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10");
fclose(f1);
stdin = freopen ("3/tmp", "r", stdin);
@ -32,7 +32,7 @@ main ()
i = scanf ("%X", &ui1); /* test "plain vanilla" fmt */
if (i != 1) /* string; data contains */
goto Fail; /* the characters 0x */
goto Fail; /* the characters 0x0 */
if (ui1 != 0)
goto Fail;

View File

@ -14,7 +14,7 @@ main ()
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10");
fprintf(f1, " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10");
rewind(f1);
us1 = 2; /* test format string of no */
@ -26,7 +26,7 @@ main ()
i = fscanf (f1, "%X", &ui1); /* test "plain vanilla" fmt */
if (i != 1) /* string; data contains */
goto Fail; /* the characters 0x */
goto Fail; /* the characters 0x0 */
if (ui1 != 0)
goto Fail;

View File

@ -4,30 +4,30 @@
main ()
{
char string [] = " +327678 - -002147483647A 327677-22 123*";
short i1;
char string [] = " +327678 -0 -002147483647A 327677-22 123*";
short i1, i3;
int i;
int i2, i3;
int i2;
long L1;
char ch;
i1 = 0; /* test format string of no */
i = sscanf (string, "%*05hd8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
i = sscanf (string, "%*06hd8"); /* assignment, max. field */
if (i != 0) /* width of 6, h ignored, */
goto Fail; /* character 8 must appear*/
if (i1 != 0) /* after 5 digits read */
goto Fail;
i2 = 15; /* test "plain vanilla" fmt */
i = sscanf (&string [9], "%d", &i2); /* string; data contains */
if (i != 1) /* a single minus sign */
if (i != 1) /* "-0" */
goto Fail;
if (i2 != 0)
goto Fail;
L1 = 0; /* test format string of */
i = sscanf (&string [15], "%12ldA", &L1); /* max. field width of 12,*/
i = sscanf (&string [15], "%13ldA", &L1); /* max. field width of 13,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character A must appear*/
if (L1 != -2147483647) /* after digits read */