diff options
author | Manish Singh <yosh@gimp.org> | 2003-11-20 23:12:05 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 2003-11-20 23:12:05 +0000 |
commit | b5ae75aa4af1f046ee3bc1342c934dcf1c412494 (patch) | |
tree | cc1b55e223d689bc5136167cd60eba3dee283636 /tests | |
parent | 193f1580013c3335408a2cb1c660c135ed013b4a (diff) |
Added G_GSIZE_FORMAT and friends.
Thu Nov 20 15:09:40 2003 Manish Singh <yosh@gimp.org>
* configure.in: Added G_GSIZE_FORMAT and friends.
* tests/printf-test.c
* tests/testglib.c
* tests/type-test.c: Add tests for the above.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/printf-test.c | 2 | ||||
-rw-r--r-- | tests/testglib.c | 10 | ||||
-rw-r--r-- | tests/type-test.c | 14 |
3 files changed, 21 insertions, 5 deletions
diff --git a/tests/printf-test.c b/tests/printf-test.c index b9b061c07..5dabe077b 100644 --- a/tests/printf-test.c +++ b/tests/printf-test.c @@ -93,6 +93,8 @@ main (int argc, TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT32_FORMAT, (guint32)5) == 1 && !strcmp (buf, "5")); TEST (NULL, g_snprintf (buf, 128, "%" G_GINT64_FORMAT, (gint64)-5) == 2 && !strcmp (buf, "-5")); TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT64_FORMAT, (guint64)5) == 1 && !strcmp (buf, "5")); + TEST (NULL, g_snprintf (buf, 128, "%" G_GSSIZE_FORMAT, (gssize)-5) == 2 && !strcmp (buf, "-5")); + TEST (NULL, g_snprintf (buf, 128, "%" G_GSIZE_FORMAT, (gsize)5) == 1 && !strcmp (buf, "5")); /* %d, flags */ TEST (NULL, g_snprintf (buf, 128, "%-d", 5) == 1 && !strcmp (buf, "5")); TEST (NULL, g_snprintf (buf, 128, "%-+d", 5) == 2 && !strcmp (buf, "+5")); diff --git a/tests/testglib.c b/tests/testglib.c index 2bc2d8bd9..c4a8c2c45 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -425,14 +425,14 @@ main (int argc, g_print ("tmp-dir: %s\n", g_get_tmp_dir ()); /* type sizes */ - g_print ("checking size of gint8: %d", (int)sizeof (gint8)); + g_print ("checking size of gint8: %" G_GSIZE_FORMAT, sizeof (gint8)); TEST (NULL, sizeof (gint8) == 1); - g_print ("\nchecking size of gint16: %d", (int)sizeof (gint16)); + g_print ("\nchecking size of gint16: %" G_GSIZE_FORMAT, sizeof (gint16)); TEST (NULL, sizeof (gint16) == 2); - g_print ("\nchecking size of gint32: %d", (int)sizeof (gint32)); + g_print ("\nchecking size of gint32: %" G_GSIZE_FORMAT, sizeof (gint32)); TEST (NULL, sizeof (gint32) == 4); - g_print ("\nchecking size of gsize: %d", (int)sizeof (gsize)); - g_print ("\nchecking size of gint64: %d", (int)sizeof (gint64)); + g_print ("\nchecking size of gsize: %" G_GSIZE_FORMAT, sizeof (gsize)); + g_print ("\nchecking size of gint64: %" G_GSIZE_FORMAT, sizeof (gint64)); TEST (NULL, sizeof (gint64) == 8); g_print ("\n"); diff --git a/tests/type-test.c b/tests/type-test.c index e0d17d0a0..5163b1f82 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -54,6 +54,10 @@ main (int argc, gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU); gint64 gi64t1; gint64 gi64t2; + gssize gsst1; + gssize gsst2; + gsize gst1; + gsize gst2; /* type sizes */ g_assert (sizeof (gint8) == 1); @@ -117,6 +121,16 @@ main (int argc, g_free (string); g_assert (gi64t1 == gi64t2); g_assert (gu64t1 == gu64t2); + + gsst1 = -0x3AFAFAFA; + gst1 = 0xFAFAFAFA; + +#define FORMATSIZE "%" G_GSSIZE_FORMAT " %" G_GSIZE_FORMAT "\n" + string = g_strdup_printf (FORMATSIZE, gsst1, gst1); + sscanf (string, FORMAT64, &gsst2, &gst2); + g_free (string); + g_assert (gsst1 == gsst2); + g_assert (gst1 == gst2); return 0; } |