From f64f75fde5b828446ec674ae12a9e0ff89ae1172 Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Tue, 16 Mar 1999 16:02:05 +0000 Subject: [PATCH] Added a test for the G_(U)?INT(16|32|64)_FORMAT and 1999-03-16 Sebastian Wilhelmi * tests/type-test.c: Added a test for the G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) macros. --- ChangeLog | 4 +++ ChangeLog.pre-2-0 | 4 +++ ChangeLog.pre-2-10 | 4 +++ ChangeLog.pre-2-12 | 4 +++ ChangeLog.pre-2-2 | 4 +++ ChangeLog.pre-2-4 | 4 +++ ChangeLog.pre-2-6 | 4 +++ ChangeLog.pre-2-8 | 4 +++ tests/type-test.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 99 insertions(+) diff --git a/ChangeLog b/ChangeLog index cc2fb08d5..2d5584667 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index cc2fb08d5..2d5584667 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 1999-03-16 Sebastian Wilhelmi + * tests/type-test.c: Added a test for the + G_(U)?INT(16|32|64)_FORMAT and G_(MIN|MAX|MAXU)(SHORT|INT|LONG) + macros. + * configure.in: Removed G_(U)?INT8_FORMAT again, as it can't be used for scanf. diff --git a/tests/type-test.c b/tests/type-test.c index 94b9cab22..eeba19730 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -36,11 +36,24 @@ int main (int argc, char *argv[]) { + gchar *string; + gushort gus; + guint gui; + gulong gul; + gshort gs; + gint gi; + glong gl; + gint16 gi16t1; + gint16 gi16t2; + gint32 gi32t1; + gint32 gi32t2; guint16 gu16t1 = 0x44afU, gu16t2 = 0xaf44U; guint32 gu32t1 = 0x02a7f109U, gu32t2 = 0x09f1a702U; #ifdef G_HAVE_GINT64 guint64 gu64t1 = G_GINT64_CONSTANT(0x1d636b02300a7aa7U), gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU); + gint64 gi64t1; + gint64 gi64t2; #endif /* type sizes */ @@ -57,5 +70,59 @@ main (int argc, g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2); #endif + /* Test the G_(MIN|MAX|MAXU)(SHORT|INT|LONG) macros */ + + gus = G_MAXUSHORT; + gus++; + g_assert (gus == 0); + + gui = G_MAXUINT; + gui++; + g_assert (gui == 0); + + gul = G_MAXULONG; + gul++; + g_assert (gul == 0); + + gs = G_MAXSHORT; + gs++; + g_assert (gs == G_MINSHORT); + + gi = G_MAXINT; + gi++; + g_assert (gi == G_MININT); + + gl = G_MAXLONG; + gl++; + g_assert (gl == G_MINLONG); + + /* Test the G_G(U)?INT(16|32|64)_FORMAT macros */ + + gi16t1 = -0x3AFA; + gu16t1 = 0xFAFA; + gi32t1 = -0x3AFAFAFA; + gu32t1 = 0xFAFAFAFA; + +#define FORMAT "%" G_GINT16_FORMAT " %" G_GINT32_FORMAT \ + " %" G_GUINT16_FORMAT " %" G_GUINT32_FORMAT "\n" + string = g_strdup_printf (FORMAT, gi16t1, gi32t1, gu16t1, gu32t1); + sscanf (string, FORMAT, &gi16t2, &gi32t2, &gu16t2, &gu32t2); + g_free (string); + g_assert (gi16t1 == gi16t2); + g_assert (gi32t1 == gi32t2); + g_assert (gu16t1 == gu16t2); + g_assert (gu32t1 == gu32t2); + +#ifdef G_HAVE_GINT64 + gi64t1 = G_GINT64_CONSTANT (-0x3AFAFAFAFAFAFAFA); + gu64t1 = G_GINT64_CONSTANT (0xFAFAFAFAFAFAFAFA); +#define FORMAT64 "%" G_GINT64_FORMAT " %" G_GUINT64_FORMAT "\n" + string = g_strdup_printf (FORMAT64, gi64t1, gu64t1); + sscanf (string, FORMAT64, &gi64t2, &gu64t2); + g_free (string); + g_assert (gi64t1 == gi64t2); + g_assert (gu64t1 == gu64t2); +#endif + return 0; }