void check_data (void) { static const struct { const char *x; const char *y; const char *want_add; const char *want_sub; } data[] = { { "0", "0", "0", "0" }, { "1", "0", "1", "1" }, { "1", "1", "2", "0" }, { "1/2", "1/2", "1", "0" }, { "5/6", "14/15", "53/30", "-1/10" }, }; mpq_t x, y, want_add, want_sub; int i; mpq_init (x); mpq_init (y); mpq_init (want_add); mpq_init (want_sub); for (i = 0; i < numberof (data); i++) { mpq_set_str_or_abort (x, data[i].x, 0); mpq_set_str_or_abort (y, data[i].y, 0); mpq_set_str_or_abort (want_add, data[i].want_add, 0); mpq_set_str_or_abort (want_sub, data[i].want_sub, 0); check_all (x, y, want_add, want_sub); } mpq_clear (x); mpq_clear (y); mpq_clear (want_add); mpq_clear (want_sub); }
void check_q (void) { static const struct { const char *fmt; const char *input; const char *want; int ret; long ftell; } data[] = { { "%Qd", "0", "0", 1, -1 }, { "%Qd", "1", "1", 1, -1 }, { "%Qd", "123", "123", 1, -1 }, { "%Qd", "+0", "0", 1, -1 }, { "%Qd", "+1", "1", 1, -1 }, { "%Qd", "+123", "123", 1, -1 }, { "%Qd", "-0", "0", 1, -1 }, { "%Qd", "-1", "-1", 1, -1 }, { "%Qd", "-123", "-123", 1, -1 }, { "%Qo", "0", "0", 1, -1 }, { "%Qo", "173", "123", 1, -1 }, { "%Qo", "+0", "0", 1, -1 }, { "%Qo", "+173", "123", 1, -1 }, { "%Qo", "-0", "0", 1, -1 }, { "%Qo", "-173", "-123", 1, -1 }, { "%Qx", "0", "0", 1, -1 }, { "%Qx", "7b", "123", 1, -1 }, { "%Qx", "7b", "123", 1, -1 }, { "%Qx", "+0", "0", 1, -1 }, { "%Qx", "+7b", "123", 1, -1 }, { "%Qx", "+7b", "123", 1, -1 }, { "%Qx", "-0", "-0", 1, -1 }, { "%Qx", "-7b", "-123", 1, -1 }, { "%Qx", "-7b", "-123", 1, -1 }, { "%QX", "0", "0", 1, -1 }, { "%QX", "7b", "123", 1, -1 }, { "%QX", "7b", "123", 1, -1 }, { "%QX", "+0", "0", 1, -1 }, { "%QX", "+7b", "123", 1, -1 }, { "%QX", "+7b", "123", 1, -1 }, { "%QX", "-0", "-0", 1, -1 }, { "%QX", "-7b", "-123", 1, -1 }, { "%QX", "-7b", "-123", 1, -1 }, { "%Qx", "0", "0", 1, -1 }, { "%Qx", "7B", "123", 1, -1 }, { "%Qx", "7B", "123", 1, -1 }, { "%Qx", "+0", "0", 1, -1 }, { "%Qx", "+7B", "123", 1, -1 }, { "%Qx", "+7B", "123", 1, -1 }, { "%Qx", "-0", "-0", 1, -1 }, { "%Qx", "-7B", "-123", 1, -1 }, { "%Qx", "-7B", "-123", 1, -1 }, { "%QX", "0", "0", 1, -1 }, { "%QX", "7B", "123", 1, -1 }, { "%QX", "7B", "123", 1, -1 }, { "%QX", "+0", "0", 1, -1 }, { "%QX", "+7B", "123", 1, -1 }, { "%QX", "+7B", "123", 1, -1 }, { "%QX", "-0", "-0", 1, -1 }, { "%QX", "-7B", "-123", 1, -1 }, { "%QX", "-7B", "-123", 1, -1 }, { "%Qi", "0", "0", 1, -1 }, { "%Qi", "1", "1", 1, -1 }, { "%Qi", "123", "123", 1, -1 }, { "%Qi", "+0", "0", 1, -1 }, { "%Qi", "+1", "1", 1, -1 }, { "%Qi", "+123", "123", 1, -1 }, { "%Qi", "-0", "0", 1, -1 }, { "%Qi", "-1", "-1", 1, -1 }, { "%Qi", "-123", "-123", 1, -1 }, { "%Qi", "00", "0", 1, -1 }, { "%Qi", "0173", "123", 1, -1 }, { "%Qi", "+00", "0", 1, -1 }, { "%Qi", "+0173", "123", 1, -1 }, { "%Qi", "-00", "0", 1, -1 }, { "%Qi", "-0173", "-123", 1, -1 }, { "%Qi", "0x0", "0", 1, -1 }, { "%Qi", "0x7b", "123", 1, -1 }, { "%Qi", "0x7b", "123", 1, -1 }, { "%Qi", "+0x0", "0", 1, -1 }, { "%Qi", "+0x7b", "123", 1, -1 }, { "%Qi", "+0x7b", "123", 1, -1 }, { "%Qi", "-0x0", "-0", 1, -1 }, { "%Qi", "-0x7b", "-123", 1, -1 }, { "%Qi", "-0x7b", "-123", 1, -1 }, { "%Qi", "0X0", "0", 1, -1 }, { "%Qi", "0X7b", "123", 1, -1 }, { "%Qi", "0X7b", "123", 1, -1 }, { "%Qi", "+0X0", "0", 1, -1 }, { "%Qi", "+0X7b", "123", 1, -1 }, { "%Qi", "+0X7b", "123", 1, -1 }, { "%Qi", "-0X0", "-0", 1, -1 }, { "%Qi", "-0X7b", "-123", 1, -1 }, { "%Qi", "-0X7b", "-123", 1, -1 }, { "%Qi", "0x0", "0", 1, -1 }, { "%Qi", "0x7B", "123", 1, -1 }, { "%Qi", "0x7B", "123", 1, -1 }, { "%Qi", "+0x0", "0", 1, -1 }, { "%Qi", "+0x7B", "123", 1, -1 }, { "%Qi", "+0x7B", "123", 1, -1 }, { "%Qi", "-0x0", "-0", 1, -1 }, { "%Qi", "-0x7B", "-123", 1, -1 }, { "%Qi", "-0x7B", "-123", 1, -1 }, { "%Qi", "0X0", "0", 1, -1 }, { "%Qi", "0X7B", "123", 1, -1 }, { "%Qi", "0X7B", "123", 1, -1 }, { "%Qi", "+0X0", "0", 1, -1 }, { "%Qi", "+0X7B", "123", 1, -1 }, { "%Qi", "+0X7B", "123", 1, -1 }, { "%Qi", "-0X0", "-0", 1, -1 }, { "%Qi", "-0X7B", "-123", 1, -1 }, { "%Qi", "-0X7B", "-123", 1, -1 }, { "%Qd", " 0", "0", 1, -1 }, { "%Qd", " 0", "0", 1, -1 }, { "%Qd", " 0", "0", 1, -1 }, { "%Qd", "\t0", "0", 1, -1 }, { "%Qd", "\t\t0", "0", 1, -1 }, { "%Qd", "3/2", "3/2", 1, -1 }, { "%Qd", "+3/2", "3/2", 1, -1 }, { "%Qd", "-3/2", "-3/2", 1, -1 }, { "%Qx", "f/10", "15/16", 1, -1 }, { "%Qx", "F/10", "15/16", 1, -1 }, { "%QX", "f/10", "15/16", 1, -1 }, { "%QX", "F/10", "15/16", 1, -1 }, { "%Qo", "20/21", "16/17", 1, -1 }, { "%Qo", "-20/21", "-16/17", 1, -1 }, { "%Qi", "10/11", "10/11", 1, -1 }, { "%Qi", "+10/11", "10/11", 1, -1 }, { "%Qi", "-10/11", "-10/11", 1, -1 }, { "%Qi", "010/11", "8/11", 1, -1 }, { "%Qi", "+010/11", "8/11", 1, -1 }, { "%Qi", "-010/11", "-8/11", 1, -1 }, { "%Qi", "0x10/11", "16/11", 1, -1 }, { "%Qi", "+0x10/11", "16/11", 1, -1 }, { "%Qi", "-0x10/11", "-16/11", 1, -1 }, { "%Qi", "10/011", "10/9", 1, -1 }, { "%Qi", "+10/011", "10/9", 1, -1 }, { "%Qi", "-10/011", "-10/9", 1, -1 }, { "%Qi", "010/011", "8/9", 1, -1 }, { "%Qi", "+010/011", "8/9", 1, -1 }, { "%Qi", "-010/011", "-8/9", 1, -1 }, { "%Qi", "0x10/011", "16/9", 1, -1 }, { "%Qi", "+0x10/011", "16/9", 1, -1 }, { "%Qi", "-0x10/011", "-16/9", 1, -1 }, { "%Qi", "10/0x11", "10/17", 1, -1 }, { "%Qi", "+10/0x11", "10/17", 1, -1 }, { "%Qi", "-10/0x11", "-10/17", 1, -1 }, { "%Qi", "010/0x11", "8/17", 1, -1 }, { "%Qi", "+010/0x11", "8/17", 1, -1 }, { "%Qi", "-010/0x11", "-8/17", 1, -1 }, { "%Qi", "0x10/0x11", "16/17", 1, -1 }, { "%Qi", "+0x10/0x11", "16/17", 1, -1 }, { "%Qi", "-0x10/0x11", "-16/17", 1, -1 }, { "hello%Qd", "hello0", "0", 1, -1 }, { "hello%Qd", "hello 0", "0", 1, -1 }, { "hello%Qd", "hello \t0", "0", 1, -1 }, { "hello%Qdworld", "hello 0world", "0", 1, -1 }, { "hello%Qd", "hello3/2", "3/2", 1, -1 }, { "hello%*Qd", "hello0", "-999/121", 0, -1 }, { "hello%*Qd", "hello 0", "-999/121", 0, -1 }, { "hello%*Qd", "hello \t0", "-999/121", 0, -1 }, { "hello%*Qdworld", "hello 0world", "-999/121", 0, -1 }, { "hello%*Qdworld", "hello3/2world", "-999/121", 0, -1 }, { "%Qd", "", "-999/121", -1, -1 }, { "%Qd", " ", "-999/121", -1, -1 }, { " %Qd", "", "-999/121", -1, -1 }, { "xyz%Qd", "", "-999/121", -1, -1 }, { "%*Qd", "", "-999/121", -1, -1 }, { " %*Qd", "", "-999/121", -1, -1 }, { "xyz%*Qd", "", "-999/121", -1, -1 }, /* match something, but invalid */ { "%Qd", "-", "-999/121", 0, 1 }, { "%Qd", "+", "-999/121", 0, 1 }, { "%Qd", "/-", "-999/121", 0, 1 }, { "%Qd", "/+", "-999/121", 0, 1 }, { "%Qd", "-/", "-999/121", 0, 1 }, { "%Qd", "+/", "-999/121", 0, 1 }, { "%Qd", "-/-", "-999/121", 0, 1 }, { "%Qd", "-/+", "-999/121", 0, 1 }, { "%Qd", "+/+", "-999/121", 0, 1 }, { "%Qd", "/123", "-999/121", 0, 1 }, { "%Qd", "-/123", "-999/121", 0, 1 }, { "%Qd", "+/123", "-999/121", 0, 1 }, { "%Qd", "123/", "-999/121", 0, 1 }, { "%Qd", "123/-", "-999/121", 0, 1 }, { "%Qd", "123/+", "-999/121", 0, 1 }, { "xyz%Qd", "xyz-", "-999/121", 0, 4 }, { "xyz%Qd", "xyz+", "-999/121", 0, 4 }, { "%1Qi", "12/57", "1", 1, 1 }, { "%2Qi", "12/57", "12", 1, 2 }, { "%3Qi", "12/57", "-999/121", 0, -1 }, { "%4Qi", "12/57", "12/5", 1, 4 }, { "%5Qi", "12/57", "12/57", 1, 5 }, { "%6Qi", "12/57", "12/57", 1, 5 }, { "%7Qi", "12/57", "12/57", 1, 5 }, { "%1Qi", "012/057", "0", 1, 1 }, { "%2Qi", "012/057", "01", 1, 2 }, { "%3Qi", "012/057", "012", 1, 3 }, { "%4Qi", "012/057", "-999/121", 0, -1 }, { "%5Qi", "012/057", "012/0", 1, 5 }, { "%6Qi", "012/057", "012/5", 1, 6 }, { "%7Qi", "012/057", "012/057", 1, 7 }, { "%8Qi", "012/057", "012/057", 1, 7 }, { "%9Qi", "012/057", "012/057", 1, 7 }, { "%1Qi", "0x12/0x57", "0", 1, 1 }, { "%2Qi", "0x12/0x57", "-999", 0, 2 }, { "%3Qi", "0x12/0x57", "0x1", 1, 3 }, { "%4Qi", "0x12/0x57", "0x12", 1, 4 }, { "%5Qi", "0x12/0x57", "-999/121", 0, 5 }, { "%6Qi", "0x12/0x57", "0x12/0", 1, 6 }, { "%7Qi", "0x12/0x57", "-999/121", 0, 7 }, { "%8Qi", "0x12/0x57", "0x12/0x5", 1, 8 }, { "%9Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, { "%10Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, { "%11Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, { "%Qd", "xyz", "0", 0, 0 }, }; int i, j, ignore, got_ret, want_ret, got_upto, want_upto; mpq_t got, want; long got_l, want_ftell; int error = 0; fun_t fun; const char *name; char fmt[128]; mpq_init (got); mpq_init (want); for (i = 0; i < numberof (data); i++) { mpq_set_str_or_abort (want, data[i].want, 0); ASSERT_ALWAYS (strlen (data[i].fmt) + 2 < sizeof (fmt)); strcpy (fmt, data[i].fmt); strcat (fmt, "%n"); ignore = (strchr (fmt, '*') != NULL); for (j = 0; j <= 3; j++) { want_ret = data[i].ret; want_ftell = data[i].ftell; if (want_ftell == -1) want_ftell = strlen (data[i].input); want_upto = want_ftell; if (want_ret == -1 || (want_ret == 0 && ! ignore)) { want_ftell = -1; want_upto = -555; } switch (j) { case 0: name = "gmp_sscanf"; fun = fun_gmp_sscanf; break; case 1: name = "gmp_fscanf"; fun = fun_gmp_fscanf; break; case 2: if (strchr (data[i].input, '/') != NULL) continue; if (! libc_scanf_convert (fmt)) continue; name = "standard sscanf"; fun = fun_sscanf; break; case 3: if (strchr (data[i].input, '/') != NULL) continue; if (! libc_scanf_convert (fmt)) continue; name = "standard fscanf"; fun = fun_fscanf; break; default: ASSERT_ALWAYS (0); break; } got_upto = -555; got_ftell = -1; switch (j) { case 0: case 1: mpq_set_si (got, -999L, 121L); if (ignore) got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); else got_ret = (*fun) (data[i].input, fmt, got, &got_upto); break; case 2: case 3: got_l = -999L; if (ignore) got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); else got_ret = (*fun) (data[i].input, fmt, &got_l, &got_upto); mpq_set_si (got, got_l, (got_l == -999L ? 121L : 1L)); break; default: ASSERT_ALWAYS (0); break; } MPZ_CHECK_FORMAT (mpq_numref (got)); MPZ_CHECK_FORMAT (mpq_denref (got)); if (got_ret != want_ret) { printf ("%s wrong return value\n", name); error = 1; } /* use direct mpz compares, since some of the test data is non-canonical and can trip ASSERTs in mpq_equal */ if (want_ret == 1 && ! (mpz_cmp (mpq_numref(want), mpq_numref(got)) == 0 && mpz_cmp (mpq_denref(want), mpq_denref(got)) == 0)) { printf ("%s wrong result\n", name); error = 1; } if (got_upto != want_upto) { printf ("%s wrong upto\n", name); error = 1; } if (got_ftell != -1 && want_ftell != -1 && got_ftell != want_ftell) { printf ("%s wrong ftell\n", name); error = 1; } if (error) { printf (" fmt \"%s\"\n", data[i].fmt); printf (" input \"%s\"\n", data[i].input); printf (" ret want=%d\n", want_ret); printf (" got =%d\n", got_ret); mpq_trace (" value want", want); mpq_trace (" got ", got); printf (" upto want=%d\n", want_upto); printf (" got =%d\n", got_upto); if (got_ftell != -1) { printf (" ftell want =%ld\n", want_ftell); printf (" got =%ld\n", got_ftell); } abort (); } } } mpq_clear (got); mpq_clear (want); }
void check_data (void) { static const struct { const char *q; mpir_si n; mpir_ui d; int want; } data[] = { { "0", 0, 1, 0 }, { "0", 0, 123, 0 }, { "0", 0, GMP_UI_MAX, 0 }, { "1", 0, 1, 1 }, { "1", 0, 123, 1 }, { "1", 0, GMP_UI_MAX, 1 }, { "-1", 0, 1, -1 }, { "-1", 0, 123, -1 }, { "-1", 0, GMP_UI_MAX, -1 }, { "123", 123, 1, 0 }, { "124", 123, 1, 1 }, { "122", 123, 1, -1 }, { "-123", 123, 1, -1 }, { "-124", 123, 1, -1 }, { "-122", 123, 1, -1 }, { "123", -123, 1, 1 }, { "124", -123, 1, 1 }, { "122", -123, 1, 1 }, { "-123", -123, 1, 0 }, { "-124", -123, 1, -1 }, { "-122", -123, 1, 1 }, { "5/7", 3,4, -1 }, { "5/7", -3,4, 1 }, { "-5/7", 3,4, -1 }, { "-5/7", -3,4, 1 }, }; mpq_t q; int i, got; mpq_init (q); for (i = 0; i < numberof (data); i++) { mpq_set_str_or_abort (q, data[i].q, 0); MPQ_CHECK_FORMAT (q); got = mpq_cmp_si (q, data[i].n, data[i].d); if (SGN(got) != data[i].want) { printf ("mpq_cmp_si wrong\n"); error: mpq_trace (" q", q); printf (" n=%Md\n", data[i].n); printf (" d=%Mu\n", data[i].d); printf (" got=%d\n", got); printf (" want=%Md\n", data[i].want); abort (); } if (data[i].n == 0) { got = mpq_cmp_si (q, 0L, data[i].d); if (SGN(got) != data[i].want) { printf ("mpq_cmp_si wrong\n"); goto error; } } } mpq_clear (q); }
void check_data (void) { static const struct { const char *inp; int base; const char *want; int want_nread; } data[] = { { "0", 10, "0", 1 }, { "0/1", 10, "0", 3 }, { "0/", 10, "0", 0 }, { "/123", 10, "0", 0 }, { "blah", 10, "0", 0 }, { "123/blah", 10, "0", 0 }, { "5 /8", 10, "5", 1 }, { "5/ 8", 10, "0", 0 }, { "ff", 16, "255", 2 }, { "-ff", 16, "-255", 3 }, { "FF", 16, "255", 2 }, { "-FF", 16, "-255", 3 }, { "z", 36, "35", 1 }, { "Z", 36, "35", 1 }, { "0x0", 0, "0", 3 }, { "0x10", 0, "16", 4 }, { "-0x0", 0, "0", 4 }, { "-0x10", 0, "-16", 5 }, { "-0x10/5", 0, "-16/5", 7 }, { "00", 0, "0", 2 }, { "010", 0, "8", 3 }, { "-00", 0, "0", 3 }, { "-010", 0, "-8", 4 }, }; mpq_t got, want; long ftell_nread; int i, post, j, got_nread; FILE *fp; mpq_init (got); mpq_init (want); for (i = 0; i < numberof (data); i++) { for (post = 0; post <= 2; post++) { mpq_set_str_or_abort (want, data[i].want, 0); MPQ_CHECK_FORMAT (want); fp = fopen (FILENAME, "w+"); ASSERT_ALWAYS (fp != NULL); fputs (data[i].inp, fp); for (j = 0; j < post; j++) putc (' ', fp); fflush (fp); ASSERT_ALWAYS (! ferror(fp)); rewind (fp); got_nread = mpq_inp_str (got, fp, data[i].base); if (got_nread != 0) { ftell_nread = ftell (fp); if (got_nread != ftell_nread) { printf ("mpq_inp_str nread wrong\n"); printf (" inp \"%s\"\n", data[i].inp); printf (" base %d\n", data[i].base); printf (" got_nread %d\n", got_nread); printf (" ftell_nread %ld\n", ftell_nread); abort (); } } if (post == 0 && data[i].want_nread == strlen(data[i].inp)) { int c = getc(fp); if (c != EOF) { printf ("mpq_inp_str didn't read to EOF\n"); printf (" inp \"%s\"\n", data[i].inp); printf (" base %d\n", data[i].base); printf (" c '%c' %#x\n", c, c); abort (); } } if (got_nread != data[i].want_nread) { printf ("mpq_inp_str nread wrong\n"); printf (" inp \"%s\"\n", data[i].inp); printf (" base %d\n", data[i].base); printf (" got_nread %d\n", got_nread); printf (" want_nread %d\n", data[i].want_nread); abort (); } MPQ_CHECK_FORMAT (got); if (! mpq_equal (got, want)) { printf ("mpq_inp_str wrong result\n"); printf (" inp \"%s\"\n", data[i].inp); printf (" base %d\n", data[i].base); mpq_trace (" got ", got); mpq_trace (" want", want); abort (); } ASSERT_ALWAYS (fclose (fp) == 0); } } mpq_clear (got); mpq_clear (want); }
void check_q (void) { static const struct { const char *fmt; const char *q; const char *want; } data[] = { { "%Qd", "0", "0" }, { "%Qd", "1", "1" }, { "%Qd", "123", "123" }, { "%Qd", "-1", "-1" }, { "%Qd", "-123", "-123" }, { "%Qd", "3/2", "3/2" }, { "%Qd", "-3/2", "-3/2" }, { "%+Qd", "0", "+0" }, { "%+Qd", "123", "+123" }, { "%+Qd", "-123", "-123" }, { "%+Qd", "5/8", "+5/8" }, { "%+Qd", "-5/8", "-5/8" }, { "%Qx", "123", "7b" }, { "%QX", "123", "7B" }, { "%Qx", "15/16", "f/10" }, { "%QX", "15/16", "F/10" }, { "%Qx", "-123", "-7b" }, { "%QX", "-123", "-7B" }, { "%Qx", "-15/16", "-f/10" }, { "%QX", "-15/16", "-F/10" }, { "%Qo", "123", "173" }, { "%Qo", "-123", "-173" }, { "%Qo", "16/17", "20/21" }, { "%Qo", "-16/17", "-20/21" }, { "%#Qx", "0", "0" }, { "%#QX", "0", "0" }, { "%#Qx", "123", "0x7b" }, { "%#QX", "123", "0X7B" }, { "%#Qx", "5/8", "0x5/0x8" }, { "%#QX", "5/8", "0X5/0X8" }, { "%#Qx", "-123", "-0x7b" }, { "%#QX", "-123", "-0X7B" }, { "%#Qx", "-5/8", "-0x5/0x8" }, { "%#QX", "-5/8", "-0X5/0X8" }, { "%#Qo", "0", "0" }, { "%#Qo", "123", "0173" }, { "%#Qo", "-123", "-0173" }, { "%#Qo", "5/7", "05/07" }, { "%#Qo", "-5/7", "-05/07" }, /* zero denominator and showbase */ { "%#10Qo", "0/0", " 0/0" }, { "%#10Qd", "0/0", " 0/0" }, { "%#10Qx", "0/0", " 0/0" }, { "%#10Qo", "123/0", " 0173/0" }, { "%#10Qd", "123/0", " 123/0" }, { "%#10Qx", "123/0", " 0x7b/0" }, { "%#10QX", "123/0", " 0X7B/0" }, { "%#10Qo", "-123/0", " -0173/0" }, { "%#10Qd", "-123/0", " -123/0" }, { "%#10Qx", "-123/0", " -0x7b/0" }, { "%#10QX", "-123/0", " -0X7B/0" }, { "%10Qd", "0", " 0" }, { "%-10Qd", "0", "0 " }, { "%10Qd", "123", " 123" }, { "%-10Qd", "123", "123 " }, { "%10Qd", "-123", " -123" }, { "%-10Qd", "-123", "-123 " }, { "%+10Qd", "123", " +123" }, { "%+-10Qd", "123", "+123 " }, { "%+10Qd", "-123", " -123" }, { "%+-10Qd", "-123", "-123 " }, { "%08Qd", "0", "00000000" }, { "%08Qd", "123", "00000123" }, { "%08Qd", "-123", "-0000123" }, { "%+08Qd", "0", "+0000000" }, { "%+08Qd", "123", "+0000123" }, { "%+08Qd", "-123", "-0000123" }, { "%#08Qx", "0", "00000000" }, { "%#08Qx", "123", "0x00007b" }, { "%#08Qx", "-123", "-0x0007b" }, { "%+#08Qx", "0", "+0000000" }, { "%+#08Qx", "123", "+0x0007b" }, { "%+#08Qx", "-123", "-0x0007b" }, }; int i; mpq_t q; mpq_init (q); for (i = 0; i < numberof (data); i++) { mpq_set_str_or_abort (q, data[i].q, 0); check_one (data[i].want, data[i].fmt, q); } mpq_clear (q); }