diff options
author | Jeff Garzik <jgarzik@src.gnome.org> | 1999-01-02 01:51:08 +0000 |
---|---|---|
committer | Jeff Garzik <jgarzik@src.gnome.org> | 1999-01-02 01:51:08 +0000 |
commit | 58aaa9d32bd86132afb0a9eedd69f8b0299d556b (patch) | |
tree | 8eaecf6938efa501bc906b334f930e4aa567b764 /testglib.c | |
parent | 00e064d2af719c4a630156cef361de6365342aae (diff) | |
download | glib-58aaa9d32bd86132afb0a9eedd69f8b0299d556b.tar.gz |
added g_strndup_a macro
* glib.h: added g_strndup_a macro
* testglib.c:
Added tests for new alloca-based string routines.
Reformatted a couple strings.
Diffstat (limited to 'testglib.c')
-rw-r--r-- | testglib.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/testglib.c b/testglib.c index e443a8592..3eb25133a 100644 --- a/testglib.c +++ b/testglib.c @@ -39,6 +39,9 @@ else \ #define C2P(c) ((gpointer) ((long) (c))) #define P2C(p) ((gchar) ((long) (p))) +#define GLIB_TEST_STRING "el dorado " +#define GLIB_TEST_STRING_5 "el do" + static gboolean node_build_string (GNode *node, gpointer data) @@ -859,16 +862,35 @@ main (int argc, g_print ("endian macro tests..."); #if G_BYTE_ORDER == G_BIG_ENDIAN - g_print ("big endian..."); + g_print ("big endian...\n"); #else - g_print ("little endian..."); + g_print ("little endian...\n"); #endif g_assert (GUINT16_SWAP_LE_BE (gu16t1) == gu16t2); g_assert (GUINT32_SWAP_LE_BE (gu32t1) == gu32t2); #ifdef G_HAVE_GINT64 g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2); #endif + +#ifdef G_HAVE_ALLOCA + /* test alloca()-based string duplication routines */ + g_strdup_a(string, GLIB_TEST_STRING); + g_assert(string != NULL); + g_assert(strcmp(string, GLIB_TEST_STRING) == 0); + + g_strndup_a(string, GLIB_TEST_STRING, 5); + g_assert(string != NULL); + g_assert(strlen(string) == 5); + g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0); + + g_strconcat_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING); + g_assert(string != NULL); + g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING + GLIB_TEST_STRING) == 0); +#endif + g_print ("ok\n"); return 0; } + |