summaryrefslogtreecommitdiff
path: root/testglib.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@src.gnome.org>1999-01-02 03:05:36 +0000
committerJeff Garzik <jgarzik@src.gnome.org>1999-01-02 03:05:36 +0000
commitbbbfe78d7051d23b0c833489b97a1a6b76e5e334 (patch)
tree09dc565cb770cafa8afbd5b30f919d6f778c7516 /testglib.c
parent3de4d2b78162c7611d7e4823436d240e9d518cbe (diff)
downloadglib-bbbfe78d7051d23b0c833489b97a1a6b76e5e334.tar.gz
glib-bbbfe78d7051d23b0c833489b97a1a6b76e5e334.tar.bz2
glib-bbbfe78d7051d23b0c833489b97a1a6b76e5e334.zip
Handle NULL strings like g_strdup. s/g_strconcat_a/g_strconcat3_a/ to
* glib.h: (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup. s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args * testglib.c: Added g_strdup, g_strconcat checks. Added str==NULL checks for alloca string macros. s/g_strconcat_a/g_strconcat3_a/
Diffstat (limited to 'testglib.c')
-rw-r--r--testglib.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/testglib.c b/testglib.c
index 852d5582a..70e9ee85e 100644
--- a/testglib.c
+++ b/testglib.c
@@ -748,6 +748,29 @@ main (int argc,
g_print ("ok\n");
+ g_print ("checking g_strdup...");
+ g_assert(g_strdup(NULL) == NULL);
+ string = g_strdup(GLIB_TEST_STRING);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
+ g_print ("checking g_strconcat...");
+ string = g_strconcat(GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+ string = g_strconcat(GLIB_TEST_STRING, GLIB_TEST_STRING,
+ GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
+ GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
/* g_debug (argv[0]); */
/* Relation tests */
@@ -879,13 +902,17 @@ main (int argc,
g_strdup_a(string, GLIB_TEST_STRING);
g_assert(string != NULL);
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_strdup_a(string, NULL);
+ g_assert(string == NULL);
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_strndup_a(string, NULL, 20);
+ g_assert(string == NULL);
- g_strconcat_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
+ g_strconcat3_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);