Mail Archives: djgpp-workers/2003/11/16/14:38:18
According to Richard Dawe:
> --- /dev/null 2003-11-09 22:46:33.000000000 +0000
> +++ tests/libc/ansi/stdio/sscanf3.c 2003-11-09 22:45:12.000000000 +0000
> @@ -0,0 +1,92 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +
> +typedef struct {
> + const char *input;
> + const char *fmt;
> +
> + const int expected;
> + const char expected_c[2];
> + const char expected_c2[2];
> +
> + char c[2];
> + char c2[2];
> +} sscanf_testcase_t;
> +
> +sscanf_testcase_t sscanf_testcases[] = {
> + /* No assignment */
> + { "", "%*[0123456789]%*c", EOF, "", "" },
> + { "X", "%*[0123456789]%*c", 0, "", "" },
> + { "1", "%*[0123456789]%*c", EOF, "", "" },
> + { "1X2", "%*[0123456789]%*[0123456789]", 1, "", "" },
> + { "1,2", "%*[0123456789],%*[0123456789]", 2, "", "" },
If I'm not mistaken the last two lines are coded to check that
sscanf() returns 1 and 2. That's wrong. There were no
assignments. Thus sscanf() should return 0.
> +
> + /* Assign first */
> + { "", "%[0123456789]%*c", EOF, "", "" },
> + { "X", "%[0123456789]%*c", 0, "", "" },
> + { "1", "%[0123456789]%*c", EOF, "1", "" },
> + { "1X2", "%[0123456789]%*[0123456789]", 1, "1", "" },
> + { "1,2", "%[0123456789],%*[0123456789]", 2, "1", "" },
Similarly, last line should have 1 as result.
> +
> + /* Assign second */
> + { "", "%*[0123456789]%c", EOF, "", "" },
> + { "X", "%*[0123456789]%c", 0, "", "" },
> + { "1", "%*[0123456789]%c", EOF, "", "" },
> + { "1X2", "%*[0123456789]%[0123456789]", 1, "", "" },
> + { "1,2", "%*[0123456789],%[0123456789]", 2, "2", "" },
Here the results of the last two lines should be 0 and 1.
> +
> + /* Assign both */
> + { "", "%[0123456789]%c", EOF, "", "" },
> + { "X", "%[0123456789]%c", 0, "", "" },
> + { "1", "%[0123456789]%c", EOF, "1", "" },
> + { "1X2", "%[0123456789]%[0123456789]", 1, "1", "" },
> + { "1,2", "%[0123456789],%[0123456789]", 2, "1", "2" },
This one is correct.
Anyway, thanks for trying. Keep up the good work!
Right,
MartinS
- Raw text -